ImportExcel icon indicating copy to clipboard operation
ImportExcel copied to clipboard

Append parameter not working

Open r-akshay opened this issue 8 years ago • 3 comments

I am running a simple script with append but it doesn't seems to work. I believe the Append issue is not completely fixed yet? SCRIPT:

'1'| export-excel "C:\powershell\t.xlsx" -WorkSheetname 'SheetName' -StartColumn 1 -Append
'2'| export-excel "C:\powershell\t.xlsx" -WorkSheetname 'SheetName' -StartColumn 1 -Append
""| export-excel "C:\powershell\t.xlsx" -WorkSheetname 'SheetName' 
'3'| export-excel "C:\powershell\t.xlsx" -WorkSheetname 'SheetName' -StartColumn 1 -Append
'4'| export-excel "C:\powershell\t.xlsx" -WorkSheetname 'SheetName' -StartColumn 1 -Append

ERROR:

Failed exporting worksheet 'SheetName' to 'C:\powershell\t.xlsx': The property 'Value' cannot be found on this object. Verify that the property exists and 
can be set.
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\5.0.0\Export-Excel.ps1:661 char:17
+ ...             throw "Failed exporting worksheet '$WorkSheetname' to '$P ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Failed exportin...and can be set.:String) [], RuntimeException
    + FullyQualifiedErrorId : Failed exporting worksheet 'SheetName' to 'C:\powershell\t.xlsx': The property 'Value' cannot be found on this object. Verify  
   that the property exists and can be set.

r-akshay avatar Jun 21 '18 07:06 r-akshay

Been having this issue for a while now so I decided to spend a few hours tracking down the problem. I tested it and it will now create files when using -Append and function normally otherwise. Hopefully my fix is adequate!

rentorar avatar Jun 21 '18 15:06 rentorar

When I first added -Append it was only intended to work with an existing file,; but I've go a change on the way - basically it now ignores the append switch if the sheet is empty.

jhoneill avatar Jun 22 '18 22:06 jhoneill

This changed will override https://github.com/dfinke/ImportExcel/pull/360

dfinke avatar Jun 24 '18 12:06 dfinke