This section summarizes how the import and export of Excel files containing macros is handled in DsExcel Java. Using DsExcel Java, users can load and save Excel files containing macros (.xlsm files) without any issues. Please note that DsExcel 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 DsExcel 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. DsExcel Java also provides various import and export options, which can be accessed from the properties present in XlsmOpenOptions and XlsmSaveOptions classes. For more information about import and export options provided by DsExcel, see Import and Export Excel Options.
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"); |