Adding a worksheet to existing file #1476
-
The code below shows how I created two separate Excel files with sheets and pivot tables, $excel and $newexcel . What is the correct syntax to add my $newexcel, INBDate sheet to the existing $excel file? Thanks for an awesome tool!
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I believe that if the Excel file $FinalFilePath exists and the worksheet in -WorksheetName does not exist - it will be just added in the existing file.
to manipulate elements of the NewSheet (format, values, formulae):
When finished:
Let me know if this works for you. |
Beta Was this translation helpful? Give feedback.
-
Eyeballing that, it looks good. Would need data and a short script that repros what you are looking for in the end result. |
Beta Was this translation helpful? Give feedback.
I believe that if the Excel file $FinalFilePath exists and the worksheet in -WorksheetName does not exist - it will be just added in the existing file.
In my case I prepare a $DataTable extract from SQL and copy an existing "template" file into the working directory as $FinalFilePath
Then I run:
$DataTable | Export-Excel $FinalFilePath -WorksheetName "NewSheet"
This adds the new NewSheet and populates it.
Once this is done I use
to manipulate elements of the NewSheet (format, values, formulae):