The IronXL library can be used to create Excel documents from in XLS and XLSX formats.
Using the IronXL API it is intuitive to populate your workbook and save it.
C#:
using IronXL;
//Create new Excel WorkBook document.
//The default file format is XLSX, but we can override that for legacy support
WorkBook xlsWorkbook = WorkBook.Create(ExcelFileFormat.XLS);
xlsWorkbook.Metadata.Author = "IronXL";
//Add a blank WorkSheet
WorkSheet xlsSheet = xlsWorkbook.CreateWorkSheet("new_sheet");
//Add data and styles to the new worksheet
xlsSheet["A1"].Value = "Hello World";
xlsSheet["A2"].Style.BottomBorder.SetColor("#ff6600");
xlsSheet["A2"].Style.BottomBorder.Type = IronXL.Styles.BorderType.Double;
//Save the excel file
xlsWorkbook.SaveAs("NewExcelFile.xls");
VB:
Imports IronXL
'Create new Excel WorkBook document.
'The default file format is XLSX, but we can override that for legacy support
Private xlsWorkbook As WorkBook = WorkBook.Create(ExcelFileFormat.XLS)
xlsWorkbook.Metadata.Author = "IronXL"
'Add a blank WorkSheet
Dim xlsSheet As WorkSheet = xlsWorkbook.CreateWorkSheet("new_sheet")
'Add data and styles to the new worksheet
xlsSheet("A1").Value = "Hello World"
xlsSheet("A2").Style.BottomBorder.SetColor("#ff6600")
xlsSheet("A2").Style.BottomBorder.Type = IronXL.Styles.BorderType.Double
'Save the excel file
xlsWorkbook.SaveAs("NewExcelFile.xls")
Top comments (0)