< All Topics

Open Office XML

The Experior.Core.Data library includes a tool for creating Office Open XML spreadsheets

The sample below shows how to create a work book with a sheet called “Data”

FileInfo file = new FileInfo(@"c:\Test.xlsx");
if (file.Exists)
{
    file.Delete();  // ensures we create a new workbook
    file= new FileInfo(@"c:\Test.xlsx");
}

using (Experior.Core.Data.OfficeOpenXml.Excel excel = new Experior.Core.Data.OfficeOpenXml.Excel(newFile))
{
    Experior.Core.Data.OfficeOpenXml.ExcelWorksheet sheet = excel.Workbook.Worksheets.Add("Date");
    sheet.Cells[1, 1].Value = "Data";
    sheet.Cells[3, 1].Value = "1";
    sheet.Cells[3, 2].Value = "2";
    sheet.Cells[4, 1].Value = "3";
    sheet.Cells[4, 2].Value = "4";

    excel.Save();
}

Result:

Use the sheet:Cells[x,y].Style to set background color, font, border etc.

Was this article helpful?
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Previous Load class
Next Reports – create custom class