From d71dd36d56268319df13efe4a24819d4984a79dd Mon Sep 17 00:00:00 2001 From: Davis Henckel <51898571+DavisHenckel@users.noreply.github.com> Date: Fri, 26 Nov 2021 12:17:39 -0800 Subject: [PATCH] First version of file, with Image. --- FAQ/How to Write to an Existing Excel File.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/FAQ/How to Write to an Existing Excel File.md b/FAQ/How to Write to an Existing Excel File.md index e69de29..15120e0 100644 --- a/FAQ/How to Write to an Existing Excel File.md +++ b/FAQ/How to Write to an Existing Excel File.md @@ -0,0 +1,19 @@ +# Write to an Existing Excel File +### Enumerate the Excel File +```powershell +$ExcelPkgFile = Open-ExcelPackage -Path "C:\Test\file.xlsx" +``` +Contents of file.xlsx: +![ExcelFileContents](/images/FAQ_Images/ExcelFileContents.png) +### Enumerate the Worksheet to View or Modify the Data +```powershell +$WorkSheet = $ExcelPkgFile.Workbook.Worksheets["sheet1"].Cells #open excel worksheet cells from worksheet "sheet1" +``` +Visual of Data Structure: +![DataStructureExcelPkg](/images/FAQ_Images/DataStructureExcelPkg.png) + +Modify a specific value by accessing row/col like a 2D Array: +```powershell +$WorkSheet[1,4].Value = "New Column Header" #Starts at index 1 not 0 +``` +