C# ライブラリEPPlusでExcelを保存する
Topic
- Excelの保存方法
- EPPlus ver 4.5.3.3
Usage
using (var package = new ExcelPackage())
{
ExcelWorksheet ws = package.Workbook.Worksheets.Add("new_sheet");
ws.Cells["A1"].Value = "Hello World";
package.SaveAs(new FileInfo("new_file_name.xlsx"));
}
var file = new FileInfo("sample.xlsx");
using (var package = new ExcelPackage(file))
{
ExcelWorksheet ws = package.Workbook.Worksheets["sheet1"];
ws.Cells["A1"].Value = "Hello World";
package.Save();
}
using (var package = new ExcelPackage())
{
var ws = package.Workbook.Worksheets.Add("sheet1");
ws.Cells["A1"].Value = "Hello World";
byte[] bytes = package.GetAsByteArray();
}
Reference