Open AWAS666 opened 1 year ago
Excel fails to open a generated file if you add cells in non linear order.
For example:
var cells = new List<Cell>(); cells.Add(new Cell(1, "Value1")); cells.Add(new Cell(3, "Value3")); cells.Add(new Cell(2, "Value2"));
This won't open in excel and excel simply suggests "repairing" the file which means deleting the whole column and you are left wondering what happend.
So you either have to order it like this:
var cells = new List<Cell>(); cells.Add(new Cell(1, "Value1")); cells.Add(new Cell(2, "Value2")); cells.Add(new Cell(3, "Value3"));
Or you can overwrite it like this after writing all cell data:
cells = cells.OrderBy(y => y.ColumnNumber);
Excel fails to open a generated file if you add cells in non linear order.
For example:
This won't open in excel and excel simply suggests "repairing" the file which means deleting the whole column and you are left wondering what happend.
So you either have to order it like this:
Or you can overwrite it like this after writing all cell data: