This section summarizes how the import and export of Excel files containing macros is handled in GcExcel Java. Using GcExcel Java, users can load and save Excel files containing macros (.xlsm files) without any issues. Please note that GcExcel Java will not execute these macros.
Typically, this feature allows users to load and save the macro-enabled spreadsheets. Macros help automate repetitive tasks and hence, reduce significant amount of time while working with spreadsheets. Now, users can load such spreadsheets in GcExcel Java directly as Xlsm files, modify them easily and quickly and then save them back.
During the execution of import and export operations on the Excel files, all the macros will also be preserved concurrently along with the data. While opening and saving the Excel workbooks or Excel macro-enabled workbooks, macros will always be imported and exported respectively. The form controls and ActiveX controls are also supported during the import and export operations.
When the OpenFileFormat is Xlsm, macros will be imported. When the SaveFileFormat is Xlsm, macros will be exported.
Refer to the following example code in order to import and export macros in spreadsheet documents.
Java |
Copy Code |
---|---|
// Initialize workbook Workbook workbook = new Workbook(); // Opening excel file contaning macros workbook.open("testfile.xlsm"); // Saving workbook with macros workbook.save("5-LoadAndSaveMacros.xlsm"); |