I use Epplus to export excel as following
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();
}
The result excel show TRUE and FALSE
How can I show those cells as Yes/No
Highlight the cell range, Click on Conditional Formatting > Highlight Cell Rules > Text that Contains to create the Rule, then type YES in the Text that Contains dialog box.
To format a cell in Microsoft Excel, start by highlighting the specific cell you want to format. Then, right-click on the cell and click on "Format Cells." Choose whatever formatting you want for the cell from the different options, then click "Okay." That's all there is to it!
You should use excel template with custom format "Yes";;"No";
Then load that template and write 1/0 instead of 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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With