Loading and saving workbook on Mac OS

24 Jul 20262 minutes to read

Prerequisites

  • Visual Studio 2022 for Mac (17.0 or later) or Visual Studio Code with the C# extension.
  • Install the Syncfusion.XlsIO.Net.Core NuGet package in your project.
  • Register your Syncfusion® license key in your project. Refer to the licensing overview for details.

NOTE

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, you also have to add the Syncfusion.Licensing assembly reference and include a license key in your projects. Please refer to this link to know about registering the Syncfusion® license key in your applications to use our components.

Opening an existing workbook

You can open an existing workbook by using the overloads of Open methods of IWorkbooks interface.

// Create a new instance of ExcelEngine
using (ExcelEngine excelEngine = new ExcelEngine())
{
    // Initialize IApplication
    IApplication application = excelEngine.Excel;

    // Open an existing workbook through the Open method of IWorkbooks
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
}

Saving an Excel workbook

You can also save the created or manipulated workbook using overloads of SaveAs methods.

// Create a new instance of ExcelEngine
using (ExcelEngine excelEngine = new ExcelEngine())
{
    // Initialize IApplication
    IApplication application = excelEngine.Excel;

    // Open an existing workbook
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

    // To-Do: some manipulation

    // Set the version of the workbook
    workbook.Version = ExcelVersion.Xlsx;

    // Save the workbook
    workbook.SaveAs("Output.xlsx");
}

See Also