You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Me._Workbook.SaveToFile(Me.FilePath)'NOTE: _Workbook.Save is forbidden since the file path might have changed in background due to a workaround required for RemoveVbaProject
Me._Workbook.SaveToFile(Me.FilePath)'NOTE: _Workbook.Save is forbidden since the file path might have changed in background due to a workaround required for RemoveVbaProject
''' <remarks>Depending on <c ref="AutoCalculationResetToEnabledForAllSavedWorkbooks">AutoCalculationResetToEnabledForAllSavedWorkbooks</c>, <c ref="AutoCalculationEnabledWorkbookSetting">AutoCalculationEnabledWorkbookSetting</c> will be reset to True in saved workbook</remarks>
''' <remarks>Depending on <c ref="AutoCalculationResetToEnabledForAllSavedWorkbooks">AutoCalculationResetToEnabledForAllSavedWorkbooks</c>, <c ref="AutoCalculationEnabledWorkbookSetting">AutoCalculationEnabledWorkbookSetting</c> will be reset to True in saved workbook</remarks>
''' Save workbook as another file, but keep current file path and read-only status
513
+
''' </summary>
514
+
''' <param name="filePath"></param>
515
+
''' <remarks>Depending on <c ref="AutoCalculationResetToEnabledForAllSavedWorkbooks">AutoCalculationResetToEnabledForAllSavedWorkbooks</c>, <c ref="AutoCalculationEnabledWorkbookSetting">AutoCalculationEnabledWorkbookSetting</c> will be reset to True in saved workbook</remarks>
''' <remarks>Depending on <c ref="AutoCalculationResetToEnabledForAllSavedWorkbooks">AutoCalculationResetToEnabledForAllSavedWorkbooks</c>, <c ref="AutoCalculationEnabledWorkbookSetting">AutoCalculationEnabledWorkbookSetting</c> will be reset to True in saved workbook</remarks>
''' <remarks>Depending on <c ref="AutoCalculationResetToEnabledForAllSavedWorkbooks">AutoCalculationResetToEnabledForAllSavedWorkbooks</c>, <c ref="AutoCalculationEnabledWorkbookSetting">AutoCalculationEnabledWorkbookSetting</c> will be reset to True in saved workbook</remarks>
IfsaveMode=SaveMethodMode.SaveThenThrowNewNotImplementedException("SaveMethodMode.Save not fully implemented / Save method still calls Save_Internal instead of SaveAs_Internal")
ThrowNewNotSupportedException("VBA projects are not supported for .xlsx files, run RemoveVbaProject() method, first")
513
551
EndIf
552
+
553
+
DimOriginalFilePathAsString=Me._FilePath
554
+
DimOriginalReadOnlyStatusAsBoolean=Me.ReadOnly
555
+
DimSaveFilePathAsNewSystem.IO.FileInfo(filePath)
556
+
514
557
IffilePath.ToLowerInvariant.EndsWith(".xlsx",False,System.Globalization.CultureInfo.InvariantCulture)Then'remove any last bit of a VBA project (HasVbaModule is not 100% sure)
'Keep original file path and read-only status - or force both to original values in case of temporary change in SaveAsInternal (e.g. for workarounds with RemoveVbaProject)
580
+
Me._FilePath=OriginalFilePath
581
+
Me.ReadOnly=OriginalReadOnlyStatus
582
+
CaseSaveMethodMode.SaveAs
583
+
'Accept new file path and set read-only status to false
584
+
Me._FilePath=SaveFilePath.FullName
585
+
Me.ReadOnly=False
586
+
CaseSaveMethodMode.SaveCopyAs
587
+
'Update file path and read-only status only if not in SaveAsCopy mode, otherwise keep original file path and read-only status (as in SaveAsCopy mode, the file is just saved to another location, but the current file path and read-only status of the engine instance should not be changed)
588
+
Me._FilePath=OriginalFilePath
589
+
Me.ReadOnly=OriginalReadOnlyStatus
590
+
CaseElse
591
+
ThrowNewNotImplementedException("Invalid save mode: "&saveMode.ToString)
'Wb.ReloadFromFile() '==> if not reloading with Epplus4, following Save() call would fail with System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
0 commit comments