RomanPavelko / SwiftExcel

Lightweight, extremely fast and memory efficient Excel output library for .NET and .NET Core applications that streams data directly to the file.
https://swiftexcel.pro/
MIT License
42 stars 16 forks source link

Files are broken when they are long #9

Open rangoBro opened 1 year ago

rangoBro commented 1 year ago

My code works, when the files don´t get too long. But I often write large files with 50.000 lines. My code doesn´t throw an exception but when I open the file with https://onedrive.live.com/ or with office 365 I get a notification, that the file is broken. I can´t find out what exactly the problem is.

Here is my code:

Sheet s = new Sheet()
{
    Name = this.SheetName,
    RightToLeft = this.RightToLeft,
    WrapText = this.WrapText,
    ColumnsWidth = this.ColumnsWidth
};

this._excelWriter = new ExcelWriter(Path, s);

for (var row = 1; row <= this.Table.Columns.Count; row++)
{
    for (var col = 1; col <= this.Table.Columns[row - 1].Count; col++)
    {
        _excelWriter.Write(this.Table.Columns[row - 1][col - 1], col, row + 1);
    }
}

this._excelWriter.Save();
RomanPavelko commented 1 year ago

Hi @rangoBro, code looks fine, except perhaps the property Columns. I would expect it to be called Rows as you iterate Rows in your outer loop and then Columns in given Row in you inner loop but I assume this is just a naming issue. Is it possible to attach your file so I could look at its internals?

rangoBro commented 1 year ago

Hey, I´ve tried some things and I tried to use another library. For some reason I get the same Error. It say´s

Reparierte Datensätze: Eigenschaften der Tabelle von /xl/workbook.xml-Part (Arbeitsmappe) [ Repaired datasets: Property of the table from /xl/workbook.xml-Part (Workbook) ]

It seems like I have another problem and it´s not an issue with your library. Still, do you know what the problem could be? You probably know way more about excel than I do

RomanPavelko commented 1 year ago

@rangoBro like I mentioned before, in order to try to identify the issue I'd need to see the file, parse it and then I could probably be able to see what's going on. Is there a way you can include your result file for me for investigation?

jojoman2 commented 2 months ago

I have created excels with way more than 50 000 rows and it worked fine. However, I have also gotten similar errors when the DataType has been set at DataType.Number when it wasn't a valid number. In my case, it was because I was using the wrong decimal separator (, instead of .).

RomanPavelko commented 2 months ago

@jojoman2 good observation. In general, that error message is very generic for Excel. It throws it every time when the data is misconfigured so it tries to fix the document. Unfortunately there are too many things that could cause the misconfiguration and that message won't tell you explicitly what's wrong, you have to narrow it down and find yourself like you did with , vs . thing.