3

As example I have such code:

DataTable table = new DataTable("Name");
table.Columns.Add("CASESENSITIVE", typeof(string));
table.Columns.Add("casesensitive", typeof(string));
table.Rows.Add("Indocin", "David");
table.Rows.Add("Enebrel", "Sam");

var wb = new XLWorkbook();
wb.Worksheets.Add(table);
wb.SaveAs("Excel.xlsx");

When I open just created file I see alert: "Excel found unreadable content in Excel.xlsx ...."

If I confirm this alert excel automaticaly add "2" for "casesensitive" column.

How solve this problem?

palaѕн
  • 72,112
  • 17
  • 116
  • 136
Igor Tabas
  • 31
  • 3

1 Answers1

1

I believe you cannot have two columns that have the same name even if the case is different. ClosedXML is probably not looking for that scenario -- so you could either download the sourcecode for ClosedXML and update it, or in your code you could check for that situation yourself and make sure it does not happen (e.g. by appending numbers after any potential duplicate column names until they are no longer duplicated, etc.).

Luther
  • 300
  • 1
  • 8