Documents for Excel, Java Edition Documentation
File Operations / Import and Export Macros
In This Topic
    Import and Export Macros
    In This Topic

    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.

    Note: While preserving the macros on import or export of Excel files, GcExcel will not execute these macros.

    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");
            

    Note: The following limitations must be kept in mind while exporting Excel files with vertical text to PDF -
    • The orientation can only be set to 0, 90, -90 and 255. Other values will be treated as 0 while rendering the PDF file.
    • If the font name starts with "@" and the orientation is 255, GcExcel will ignore the "@".