FastExcel
FastExcel copied to clipboard
Cells in List have to be ordered by colum
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);