From 4d6193f5494d99f7a166f64e220619672db6f5c4 Mon Sep 17 00:00:00 2001 From: Davis Henckel <51898571+DavisHenckel@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:28:04 -0800 Subject: [PATCH] Complete Majority of Write to ExistingExcelFile md --- FAQ/How to Write to an Existing Excel File.md | 12 ++++++++++++ 1 file changed, 12 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 e8f6361..e4e5fcc 100644 --- a/FAQ/How to Write to an Existing Excel File.md +++ b/FAQ/How to Write to an Existing Excel File.md @@ -16,4 +16,16 @@ 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 ``` +Contents of file.xlsx after modifying: +![ExcelFileContentsPostAdd](/images/FAQ_Images/ExcelFileContentsPostAdd.png) +Can also load a value at a specific index: +```powershell +$ValueAtIndex = $WorkSheet[2,1].Value #Loads the value at row 2, column A +``` +### Save File After Modifying +The changes will not display in the Excel file until Close-ExcelPackage is called. +```powershell +Close-ExcelPackage $ExcelPkgFile #close and save changes made to the Excel file. +``` +**Note**: If the file is currently in use, Close-ExcelPackage will return an error and will not save the information.