Here's my code:
ExcelPackage pck = new ExcelPackage(stream);
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Rules");
ws.Cells["A1"].LoadFromDataTable(_rules, true);
ws.Cells[ws.Dimension.Address].AutoFitColumns();
ws.Cells[ws.Dimension.Address].Style.WrapText = true;
pck.Save();
The _rules
DataTable has rows whose text contains an ampersand: &. Let's say AT&T
for example. When viewing the file in Excel, the text appears as AT&T
. I drilled down on the sharedStrings.xml and found the text was double-escaped to AT&T
.
How can I prevent this behavior? I've tried wrapping the text in double-quotes as well as commenting out the AutoFitColumns()
and WrapText
lines.