Skip to content

Commit e1915f2

Browse files
authored
#172 Tag ColsFit isn't working for worksheet column (#176)
1 parent 1e225bd commit e1915f2

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

ClosedXML.Report/Options/ColsFitTag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public override void Execute(ProcessingContext context)
3636
.AdjustToContents(xlRange.FirstRowUsed().RowNumber()-1, xlRange.LastRowUsed().RowNumber());
3737
}
3838
// range column
39-
if (IsSpecialRangeRow(xlCell))
39+
else if (IsSpecialRangeRow(xlCell))
4040
{
4141
ws.Column(cellClmn).AdjustToContents(xlRange.FirstRowUsed().RowNumber(), xlRange.LastRowUsed().RowNumber());
4242
}

tests/ClosedXML.Report.Tests/ReportOptionsTests.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ public void OnlyValues_option_should_remove_formulas_on_sheet()
4242
});
4343
}
4444

45+
[Fact]
46+
public void ColsFit_option_should_FitWidth()
47+
{
48+
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ru-RU");
49+
XlTemplateTest("5_options.xlsx",
50+
tpl => { },
51+
wb =>
52+
{
53+
var worksheet = wb.Worksheet(1);
54+
worksheet.Column(4).Width.Should().BeInRange(4.969999, 497009);
55+
worksheet.Column(5).Width.Should().BeInRange(13.57999, 13.58001);
56+
});
57+
}
58+
4559
[Fact]
4660
public void Sort_option_should_sort_range()
4761
{
@@ -63,4 +77,4 @@ public ReportOptionsTests(ITestOutputHelper output) : base(output)
6377
{
6478
}
6579
}
66-
}
80+
}

tests/Templates/5_options.xlsx

86 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)