Other API Samples

Live SpreadsheetGear API Samples

Workbook Saving Excel 2007-2019 Open XML (*.xlsx)

This sample demonstrates saving to the Excel 2007-2019 Open XML (*.xlsx) file format using the FileFormat.OpenXMLWorkbook enumeration option.

// Create a new workbook and some local variables for convenience.
SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets["Sheet1"];
SpreadsheetGear.IRange cells = worksheet.Cells;

// Rename the worksheet.
worksheet.Name = "My Worksheet";

// Add some cell data.
cells["A1"].Value = "Hello World!";

// Save to Excel 2007 and later compatible Open XML (*.xlsx) file.
Run This Sample
Download File

Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.