Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Improved remarks and code examples

...

Excerpt

Sets or returns whether ExcelWriter should remove macros from the generated workbook or leave them in when saved.

Signature
C#
C#
 public boolean ExcludeMacros{ get; set; }
Signature
vb.net
vb.net
Public Property ExcludeMacros() As Boolean
Remarks

When ExcludeMacro is set to true, buttons associated with macros may produce the error "Data may have been lost." Therefore, when excluding macros, remove all associated buttons from the spreadsheet. ExcelWriter, by default, will include macros in the generated workbookBy default this property is false, and setting it to false has no effect on the output.
This property has no effect until Save is called, at which point the macros will be permanently removed from the workbook if it is true.
If the workbook originally did not have any macros, this property has no effect.

Example
Code Block
csharp
csharp
titleC#

          //--- Get the ExcludeMacros value for the workbook
          bool exclude = wb.ExcludeMacros;

          //--- Set the ExcludeMacros value for the workbook
          wb.ExcludeMacros = true;
//--- Save a new version with no macros
wb.Save("output.xlsx")
Code Block
vb.net
vb.net
titlevb.net

          '--- Get the ExcludeMacros value for the workbook
          Dim exclude As Boolean = wb.ExcludeMacros

          '--- Set the ExcludeMacros value for the workbook
          wb.ExcludeMacros = True
'--- Save a new version with no macros
wb.Save("output.xlsx")