[英]Powershell Excel Activate Cell like with double click and send Enter
so i know this is a wierd on.所以我知道这很奇怪。 i had this same issue a long time ago in Excel but i think with VBA...
我很久以前在 Excel 中遇到过同样的问题,但我认为 VBA ......
so i put data from mails into Excel like this.所以我像这样将邮件中的数据放入 Excel 中。 (don't mind the format i'm german)
(不要介意我是德国人的格式)
$workbook.ActiveSheet.Cells.Item($LastRow, 3) = $MItem.ReceivedTime.ToString("dd.MM.yyyy")
The Date is written in the Cell.日期写在单元格中。 BUT it is shown on the left side of the cell.
但它显示在单元格的左侧。 and i can't use VLOOKUP and stuff
我不能使用 VLOOKUP 之类的
if i double click into the cell and press Enter, the Date jumps to the right side and everything works...如果我双击单元格并按 Enter,日期会跳到右侧,一切正常...
Excel knows already that it is a Date. Excel 已经知道它是一个日期。 But the Cell must be "revalidated" through the activation.
但是必须通过激活“重新验证”单元格。
i though i have to just我虽然我必须
$workbook.ActiveSheet.Cells.Item($LastRow, 3).Activate()
$workbook.ActiveSheet.Cells.Item($LastRow, 3).DoubleClick()
or something like it but i can't even get into the cell.或类似的东西,但我什至无法进入牢房。
i hope someone cann help me.我希望有人能帮助我。 regards
问候
A date in Excel is a formatted number, not a String
. Excel 中的日期是格式化的数字,而不是
String
。 The format and the underlying value are separate.格式和基础值是分开的。
Instead of writing a String
version of the date, write the actual date and then apply number formatting:不要编写日期的
String
版本,而是编写实际日期,然后应用数字格式:
$workbook.ActiveSheet.Cells.Item($LastRow, 3) = $MItem.ReceivedTime
$workbook.ActiveSheet.Cells.Item($LastRow, 3).NumberFormat = "dd.MM.yyyy"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.