[英]Calculate specific Date in powershell
I'm a beginner in powershell 我是Powershell的初学者
$test = ("=7*" + $newWorkSheet.Cells.Item($indexDate,9).Text + "+DATE(" + $newWorkSheet.Cells.Item($indexDate,8).Text + ";1;3)-WEEKDAY(DATE(" + $newWorkSheet.Cells.Item($indexDate,8).Text + ";1;3))-2")
$newWorkSheet.Cells.Item($indexDate,1) = $test
Result to an incomprehensive error : Exception de HRESULT : 0x800A03EC 结果导致错误:异常de HRESULT:0x800A03EC
this is what I want to put in my cell : 这就是我要放在单元格中的内容:
echo $test
=7*40+DATE(2014;1;3)-WEEKDAY(DATE(2014;1;3))-2
How can i resolve it ? 我该如何解决? Thx !
谢谢 ! and sorry for my poor english :'(
为我的英语不好而抱歉:'(
Edit 编辑
I did : 我做了:
$test = '=7*' + $newWorkSheet.Cells.Item($indexDate,9).Text + '+DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3)-WEEKDAY(DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3))-2'
if I echo $test I got what I want : 如果我回显$ test我得到了我想要的:
=7*40+DATE(2014;1;3)-WEEKDAY(DATE(2014;1;3))-2
but when i put $test into my cell like this : 但是当我像这样将$ test放入我的单元格时:
$newWorkSheet.Cells.Item($indexDate,1) = $test
Result an error : 结果错误:
Exception de HRESULT : 0x800A03EC
Au caractère D:\Users\sadm\Documents\salesforce_1.ps1:839 : 1
+ $newWorkSheet.Cells.Item($indexDate,1) = $tmp1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
I search to display a specific date with a number of week and a year. 我搜索显示特定的日期,其中包含一周和一年的时间。
Number of week and year are containing in cells of an excel. excel单元格中包含的星期和年份数。
$newWorkSheet.Cells.Item($indexDate,9) = $idsem ##Here is my number of week
$newWorkSheet.Cells.Item($indexDate,8) = $tempDate3.ToString("yyyy")
$test = "=" + "7*" + $newWorkSheet.Cells.Item($indexDate,9).Text + '+DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3)-JOURSEM(DATE(' + $newWorkSheet.Cells.Item($indexDate,8).Text + ';1;3))-2'
$newWorkSheet.Cells.Item($indexDate,1) = $test
$newWorkSheet.Cells.Item($indexDate,1).NumberFormat = "jj/mm/aaaa"
$global:indexDate++
When I launch the script with powershell 5.0 I had this error : 当我使用Powershell 5.0启动脚本时,出现以下错误:
Exception de HRESULT : 0x800A03EC
Au caractère D:\Users\sadm\Documents\salesforce_1.ps1:831 : 1
+ $newWorkSheet.Cells.Item($indexDate,1) = $test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
with 2.0 that works... 与2.0一起工作...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.