我使用Epplus如下导出excel
FileInfo newFile = new FileInfo(@"sample6.xlsx");
using (ExcelPackage pck = new ExcelPackage(newFile))
{
var ws = pck.Workbook.Worksheets.Add("Content");
ws.Cells["A1"].Value = true;
ws.Cells["A2"].Value = false;
pck.Save();
}
结果excel显示TRUE和FALSE
如何将这些单元格显示为是/否
最佳答案
您应该使用具有自定义格式的excel模板"is" ;;“否”;
然后加载该模板并写入1/0,而不是True/False
FileInfo newFile = new FileInfo(@"sample6.xlsx");
using (ExcelPackage pck = new ExcelPackage(newFile))
{
var ws = pck.Workbook.Worksheets["Content"];
ws.Cells["A1"].Value = 1;
ws.Cells["A2"].Value = 0;
pck.Save();
}