Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated extra line breaks #1709

Open
H0LIXI opened this issue Nov 21, 2024 · 3 comments
Open

Generated extra line breaks #1709

H0LIXI opened this issue Nov 21, 2024 · 3 comments

Comments

@H0LIXI
Copy link

H0LIXI commented Nov 21, 2024

Hello, I found that after fix this issue [https://github.com//issues/1655], another issue appeared.

When the newline character in the previous file was x000D\r\n, opening it in Excel would show only one line break.
After saving with version Epp.7.5.0, x000D\r\n becomes \r\r\n, and opening it in Excel results in two line breaks. After saving in Excel, it becomes \r\n\r\n.

If it's a newly created file, there might not be an issue, but if it's a file that was handled by an older version, upgrading the plugin might cause an increase in newline characters.

I'm not sure if directly removing \r when saving the text, or adjusting \r...\r\n to \r\n, is a feasible solution.

You can use this file to test. Observe the changes in cell A3.
Test-rrn.xlsx

// Read any cell and then save.
using (var excel = new ExcelPackage(newPath))
{
    var sheet = excel.Workbook.Worksheets.FirstOrDefault();
    var excelName = sheet.Name;

    for (var i = 1; i <= 2; i++)
    {
        for (var j = 1; j <= sheet.Dimension.Columns; j++)
        {
            var cellVal = sheet.Cells[i, j].Text;
        }
    }

    excel.Save();
}
@JanKallman
Copy link
Contributor

Thanks for reporting. I'll have a look at it.

@JanKallman
Copy link
Contributor

I'm not sure why Excel makes a difference on x000D\r\n and \r\r\n. This seems weird.

@H0LIXI
Copy link
Author

H0LIXI commented Nov 26, 2024

I tried using Microsoft's Microsoft.Office.Interop.Excel library to read the cell, and x000D\r\n was read as \r\n. It seems that x000D was ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants