Preservation of macros

GemBox.Spreadsheet supports most Microsoft Excel and Libre Office (or Open Office) features, but not all. You can preserve unsupported features when reading a workbook so that they are not lost when writing to a workbook of the same format.

You can read more about GemBox.Spreadsheet's preservation feature on the Preservation help page.

The following example shows how you can preserve macros in an Excel file from input to output.

Reading and writing Excel file with preserved macros
Screenshot of Excel file with preserved macros
Upload your file (Drag file here)
using GemBox.Spreadsheet;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        // Load Excel file with preservation feature enabled.
        var loadOptions = new XlsxLoadOptions() { PreserveUnsupportedFeatures = true };
        var workbook = ExcelFile.Load("%InputFileName%", loadOptions);

        // Save Excel file to output file of same format together with
        // preserved information (unsupported features) from input file.
        workbook.Save("Preserved Output.xlsm");
    }
}
Imports GemBox.Spreadsheet

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

        ' Load Excel file with preservation feature enabled.
        Dim loadOptions As New XlsxLoadOptions() With {.PreserveUnsupportedFeatures = True}
        Dim workbook = ExcelFile.Load("%InputFileName%", loadOptions)

        ' Save Excel file to output file of same format together with
        ' preserved information (unsupported features) from input file.
        workbook.Save("Preserved Output.xlsm")

    End Sub
End Module

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Spreadsheet yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.