question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dimension property not updated after modifying an Excel file with a frozen row

See original GitHub issue

Read and complete the full issue template

Do not randomly delete sections. They are here for a reason.

Do you want to request a feature or report a bug?

  • Bug
  • Feature
  • Question

Did you test against the latest CI build?

  • Yes
  • No

Tested against 0.95.999.2326, currently latest.

If you answered No, please test with the latest development build first.

Version of ClosedXML

0.95.4

What is the current behavior?

Small example:

  • Use Excel to create an xlsx file, write the string “A1” to the A1 cell and “D6” to the D6 cell.
  • Freeze the first row (this step is needed).
  • Use ClosedXML to open the file, write the string “Generated” to cells between A1 and B10 and save the file.
  • The created file displays correctly in Excel, however parsing it with another library, with e.g. https://oss.sheetjs.com/ will only parse between A1 and D6. The content under row D is missing.

Excel: image

Parsed: image

What is the expected behavior or new feature?

Third party parsers should be able to parse the output Excel file from ClosedXML below the last manually modified cell.

I understand that the third party parser I’m using could also have a bug, however since the issue happens below the last manually modified cell, I believe there is some information present in the Excel file about the last row / last column that is non-empty which is not overwritten by ClosedXML on save and this information could be used by the third party parsers to iterate the rows/columns, but not by Excel itself. I’m not sure why this only happens if the first row is frozen in the input file.

The reason why I’m trying to do this is that my team uses ClosedXML on the backend of a website to generate Excel worksheets from a template file and user data and we are trying to run end-to-end tests written in TypeScript on the frontend to validate the results, so I’m using another Excel library that is written in JavaScript to parse the results back.

Is this a regression from the previous version?

No, I have tested with 0.94.2 and it happens there too.

Reproducibility

This is an important section. Read it carefully. Failure to do so will cause a ‘RTFM’ comment.

Without a code sample, it is unlikely that your issue will get attention. Don’t be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be minimal complete and verifiable. Sample spreadsheets should be attached whenever applicable. Remove sensitive information.

Code to reproduce problem:

using System.Linq;
using ClosedXML.Excel;

namespace ClosedXMLTest
{
    class Program
    {
        static void Main()
        {
            var workbook = new XLWorkbook(@"C:\...\test.xlsx");
            var sheet = workbook.Worksheets.First();
            for (int i=1; i<=10; ++i)
            {
                var row = sheet.Row(i);
                for(int j=1; j<=2; ++j)
                {
                    row.Cell(j).SetValue("Generated");
                }
            }
            workbook.SaveAs(@"C:\...\test_out.xlsx", true, true);
        }
    }
}
  • I attached a sample spreadsheet. (You can drag files on to this issue)

test.xlsx

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
igiturcommented, Jun 29, 2021

OK, good catch. I’ll look into it.

0reactions
nemkincommented, Jun 29, 2021

Thank you! I updated the title to reflect the issue better.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel freezes when resizing columns or rows
Excel (all open files) freeze with the cursor stuck in 'resize' mode, with the row/column width dialogue box visible in the excel that...
Read more >
Data is shifting in Excel, Frozen Panes do not match with ...
Hello, I am using the Shared Documents folder within SharePoint to host an Excel file. I have frozen columns A-C and row 1....
Read more >
Prevent Images and Shapes from Resizing or Moving in ...
This will allow you to keep the dimensions of your images and shapes while allowing them to move with the spreadsheet when you...
Read more >
Expanding a set of grouped rows causing excel to freeze ...
When I go to ungroup the rows using the "+" sign, it freezes Excel -- BUT, it only freezes if I'm scrolled all...
Read more >
How to Lock Row Height & Column Width in Excel (Easy ...
Disable the 'Locked' property for all the cells; Protect the worksheet so that row height and column width for each cell is locked....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found