This project has moved. For the latest updates, please go here.

Error found in Rows().AdjustToContents()

Nov 27, 2012 at 3:31 PM
Edited Nov 27, 2012 at 3:34 PM

I've noticed that the implementation of Rows().AdjustToContents() is faulty.

Some rows are resized correctly, while others are not resized or resized to fit the content only partially. I do not know what causes it, or why it happens, just wanted to notify you guys.

Kind regards, S1

Nov 27, 2012 at 4:36 PM

How can I reproduce it? The following works fine:

            var wb = new XLWorkbook();
            var ws = wb.AddWorksheet("Sheet1");
            ws.Cell("A1").SetValue("Line 1")
                .CellRight().SetValue("Line 1" + Environment.NewLine + "Line 2")
                .CellRight().SetValue("Line 1");
Nov 28, 2012 at 8:14 AM

I tried to reproduce it (manually) as well, but didn't manage to do so, so I took the data that caused trouble and noticed something interesting:

The problematic lines are broken with \n instead of \r\n.

It would be cool, if ClosedXML could work with only \n as well, but in the meantime (now that I know what's wrong), I'll just replace all \n with \r\n using Regex.

Thank you for your time,

Kind regards, S1