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.

Upgrade to ExcelNumberFormat 1.1.0 has caused the ClosedXML AdjustColumnWidths method to misbehave

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

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

Version of ClosedXML

0.95.4

What is the current behavior?

AdjustColumnWidths is not behaving appropriately since upgrading to ExcelNumberFormat 1.1.0. Some columns are wider than the data in the columns and some are narrower.

What is the expected behavior or new feature?

AdjustColumnWidths should behave appropriately - setting all columns to the width of the data in the column. This worked perfectly with ExcelNumberFormat 1.0.10, but fails since upgrading.

Is this a regression from the previous version?

Tested regression version of ExcelNumberFormat

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:

private static void Main(string[] args)
{
XLWorkbook wb = new XLWorkbook();
IXLWorksheet ws = wb.Worksheets.Add();

ws.Row(1).Style.Font.Bold = true;
ws.Column(1).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right);
ws.Column(2).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right);
ws.Column(3).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right);
ws.Cell(1, 1).SetValue("Date");
ws.Cell(2, 1).SetValue(DateTime.Now.Date);
ws.Cell(3, 1).SetValue(DateTime.Now.Date.AddDays(7));
ws.Cell(1, 2).SetValue($"First{Environment.NewLine}Amount");
ws.Cell(2, 2).SetValue(123456.78).Style.NumberFormat.Format = "[$$-en-US] #,##0.00";
ws.Cell(3, 2).SetValue(12345678).Style.NumberFormat.Format = "[$$-en-US] #,##0.00";
ws.Cell(1, 3).SetValue($"Second{Environment.NewLine}Amount");
ws.Cell(2, 3).SetValue(1.23).Style.NumberFormat.Format = "[$$-en-US] #,##0.00";
ws.Cell(3, 3).SetValue(123).Style.NumberFormat.Format = "[$$-en-US] #,##0.00";
ws.Cell(1, 4).SetValue("Text");
ws.Cell(2, 4).SetValue("Go");
ws.Cell(3, 4).SetValue("Go Go Go");

ws.Columns().AdjustToContents();

wb.SaveAs(@"c:\temp\test.xlsx");
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sekuether21commented, Apr 8, 2021

Here you go. It looks like cell.GetFormattedString() method is not returning the formatted string with ExcelNumberFormat 1.1.0 where with version 1.0.10 it was.

Using ExcelNumberFormat 1.0.10: test with old ExcelNumberFormat

Using ExcelNumberFormat 1.1.0: test with new ExcelNumberFormat

0reactions
igiturcommented, Apr 8, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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