Skip to content

Instantly share code, notes, and snippets.

@sontx
Created August 23, 2016 06:46
Show Gist options
  • Save sontx/24a35f21582ba7e787830c86e273772d to your computer and use it in GitHub Desktop.
Save sontx/24a35f21582ba7e787830c86e273772d to your computer and use it in GitHub Desktop.
Demo using ClosedXML
using ClosedXML.Excel;
using System.Windows.Forms;
namespace ExcelCSharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// create new excel workbook
var workbook = new XLWorkbook();
// set author for this workbook
workbook.Author = "www.sontx.in";
// create a sheet
var worksheet = workbook.Worksheets.Add("new worksheet");
// set value for A1 cell in this worksheet
worksheet.Cell("A1").Value = "This is value in A1 cell";
// export excel file to disk
workbook.SaveAs("my_report.xlsx");
// clean up
workbook.Dispose();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment