using SpreadsheetLight; // create a new SLDocument object SLDocument doc = new SLDocument(); // set the contents of cell A1 to "Hello World" doc.SetCellValue("A1", "Hello World"); // save the document doc.SaveAs("example.xlsx");
using OfficeOpenXml; // create a new ExcelPackage object ExcelPackage package = new ExcelPackage(); // get a reference to the worksheet ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Sheet1"); // set the contents of cell B2 to 42 worksheet.Cells["B2"].Value = 42; // save the document package.SaveAs(new FileInfo("example.xlsx"));Brief description of examples: The first example uses the SpreadsheetLight library to create a new spreadsheet document, set the contents of cell A1 to "Hello World", and save the document. The second example uses the ExcelPackage library to create a new spreadsheet document, add a new worksheet, set the contents of cell B2 to 42, and save the document. Package Library: The first example uses the SpreadsheetLight library, while the second example uses the ExcelPackage library.