Skip to content

Commit d3e1c0a

Browse files
committed
Merge branch 'SupportForClosedXml_0.94'
2 parents b72e92f + 5e5e2a2 commit d3e1c0a

File tree

12 files changed

+40
-31
lines changed

12 files changed

+40
-31
lines changed

ExcelReportGenerator.Samples/ExcelReportGenerator.Samples.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@
5252
<LangVersion>5</LangVersion>
5353
</PropertyGroup>
5454
<ItemGroup>
55-
<Reference Include="ClosedXML, Version=0.93.1.0, Culture=neutral, processorArchitecture=MSIL">
56-
<HintPath>..\packages\ClosedXML.0.93.1\lib\net40\ClosedXML.dll</HintPath>
55+
<Reference Include="ClosedXML, Version=0.94.0.0, Culture=neutral, processorArchitecture=MSIL">
56+
<HintPath>..\packages\ClosedXML.0.94.0\lib\net40\ClosedXML.dll</HintPath>
5757
</Reference>
5858
<Reference Include="DocumentFormat.OpenXml, Version=2.7.2.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
5959
<HintPath>..\packages\DocumentFormat.OpenXml.2.7.2\lib\net40\DocumentFormat.OpenXml.dll</HintPath>
6060
</Reference>
6161
<Reference Include="ExcelNumberFormat, Version=1.0.3.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL">
6262
<HintPath>..\packages\ExcelNumberFormat.1.0.3\lib\net20\ExcelNumberFormat.dll</HintPath>
6363
</Reference>
64-
<Reference Include="FastMember.Signed, Version=1.3.0.0, Culture=neutral, PublicKeyToken=9e8f22703bef9a29, processorArchitecture=MSIL">
65-
<HintPath>..\packages\FastMember.Signed.1.3.0\lib\net45\FastMember.Signed.dll</HintPath>
64+
<Reference Include="FastMember, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
65+
<HintPath>..\packages\FastMember.1.3.0\lib\net45\FastMember.dll</HintPath>
6666
</Reference>
6767
<Reference Include="SimpleInjector, Version=4.4.2.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
6868
<HintPath>..\packages\SimpleInjector.4.4.2\lib\net45\SimpleInjector.dll</HintPath>
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="ClosedXML" version="0.93.1" targetFramework="net45" />
3+
<package id="ClosedXML" version="0.94.0" targetFramework="net45" />
44
<package id="DocumentFormat.OpenXml" version="2.7.2" targetFramework="net45" />
55
<package id="ExcelNumberFormat" version="1.0.3" targetFramework="net45" />
6-
<package id="FastMember.Signed" version="1.3.0" targetFramework="net45" />
6+
<package id="FastMember" version="1.3.0" targetFramework="net45" />
77
<package id="SimpleInjector" version="4.4.2" targetFramework="net45" />
88
<package id="System.ValueTuple" version="4.3.0" targetFramework="net45" />
99
</packages>

ExcelReportGenerator.Tests/CustomAsserts/ExcelAssert.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ public static void AreWorksheetsContentEquals(IXLWorksheet expected, IXLWorkshee
1313
return;
1414
}
1515

16-
Assert.AreEqual(expected.CellsUsed(true).Count(), actual.CellsUsed(true).Count(), "Cells used count failed");
16+
Assert.AreEqual(expected.CellsUsed(XLCellsUsedOptions.All).Count(), actual.CellsUsed(XLCellsUsedOptions.All).Count(), "Cells used count failed");
1717

18-
IXLCell expectedFirstCellUsed = expected.FirstCellUsed(true);
19-
IXLCell actualFirstCellUsed = actual.FirstCellUsed(true);
18+
IXLCell expectedFirstCellUsed = expected.FirstCellUsed(XLCellsUsedOptions.All);
19+
IXLCell actualFirstCellUsed = actual.FirstCellUsed(XLCellsUsedOptions.All);
2020
Assert.AreEqual(expectedFirstCellUsed.Address, actualFirstCellUsed.Address, "First cell used failed");
21-
IXLCell expectedLastCellUsed = expected.LastCellUsed(true);
22-
IXLCell actualLastCellUsed = actual.LastCellUsed(true);
21+
IXLCell expectedLastCellUsed = expected.LastCellUsed(XLCellsUsedOptions.All);
22+
IXLCell actualLastCellUsed = actual.LastCellUsed(XLCellsUsedOptions.All);
2323
Assert.AreEqual(expectedLastCellUsed.Address, actualLastCellUsed.Address, "Last cell used failed");
2424

2525
IXLRange range = expected.Range(expectedFirstCellUsed, expectedLastCellUsed);

ExcelReportGenerator.Tests/Extensions/XLRangeBaseExtensionsTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public void TestCellsUsedWithoutFormulas()
2323
ws.Cell(25, 30).FormulaA1 = "=A1+B2";
2424

2525
Assert.AreEqual(5, ws.CellsUsed().Count());
26-
Assert.AreEqual(6, ws.CellsUsed(true).Count());
26+
Assert.AreEqual(6, ws.CellsUsed(XLCellsUsedOptions.All).Count());
2727
Assert.AreEqual(2, ws.CellsUsedWithoutFormulas().Count());
28-
Assert.AreEqual(3, ws.CellsUsedWithoutFormulas(true).Count());
28+
Assert.AreEqual(3, ws.CellsUsedWithoutFormulas(XLCellsUsedOptions.All).Count());
2929
Assert.AreEqual(2, ws.CellsUsed(c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
3030
Assert.AreEqual(1, ws.CellsUsedWithoutFormulas(c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
31-
Assert.AreEqual(3, ws.CellsUsed(true, c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
32-
Assert.AreEqual(2, ws.CellsUsedWithoutFormulas(true, c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
31+
Assert.AreEqual(3, ws.CellsUsed(XLCellsUsedOptions.All, c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
32+
Assert.AreEqual(2, ws.CellsUsedWithoutFormulas(XLCellsUsedOptions.All, c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
3333
}
3434

3535
[Test]

ExcelReportGenerator.Tests/Rendering/Panels/ExcelPanels/PanelRenderTests/DataSourceDynamicPanelRenderTests/DataSourceDynamicPanelDataSetRenderTest.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
using System.Linq;
2-
using ClosedXML.Excel;
1+
using ClosedXML.Excel;
32
using ExcelReportGenerator.Enums;
43
using ExcelReportGenerator.Rendering.Panels.ExcelPanels;
54
using ExcelReportGenerator.Tests.CustomAsserts;
65
using NUnit.Framework;
6+
using System;
7+
using System.IO;
8+
using System.Linq;
79

810
namespace ExcelReportGenerator.Tests.Rendering.Panels.ExcelPanels.PanelRenderTests.DataSourceDynamicPanelRenderTests
911
{
10-
1112
public class DataSourceDynamicPanelDataSetRenderTest
1213
{
1314
[Test]
@@ -45,14 +46,15 @@ public void TestRenderDataSetWithEvents()
4546

4647
Assert.AreEqual(ws.Range(2, 2, 7, 8), panel.ResultRange);
4748

48-
// Bug of ClosedXml - invalid determine of FirstCellUsed and LastCellUsed if merged ranges exist
49-
ws.Cell(1, 1).Value = "Stub";
50-
ws.Range(1, 1, 1, 1).Merge();
51-
ws.Cell(8, 9).Value = "Stub";
52-
ws.Range(8, 9, 8, 9).Merge();
49+
// The test doesn't pass if we compare the expected workbook with the in-memory workbook (since ClosedXml 0.94.0)
50+
string actualWorkbookName = $"{Guid.NewGuid()}.xlsx";
51+
report.Workbook.SaveAs(actualWorkbookName);
52+
var actualWorkbook = new XLWorkbook(actualWorkbookName);
5353

5454
ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourceDynamicPanelDataSetRenderTest),
55-
nameof(TestRenderDataSetWithEvents)), ws.Workbook);
55+
nameof(TestRenderDataSetWithEvents)), actualWorkbook);
56+
57+
File.Delete(actualWorkbookName);
5658

5759
//report.Workbook.SaveAs("test.xlsx");
5860
}
@@ -90,8 +92,15 @@ public void TestRenderDataSetWithEvents_HorizontalPanel()
9092

9193
Assert.AreEqual(ws.Range(2, 2, 8, 6), panel.ResultRange);
9294

95+
// The test doesn't pass if we compare the expected workbook with the in-memory workbook (since ClosedXml 0.94.0)
96+
string actualWorkbookName = $"{Guid.NewGuid()}.xlsx";
97+
report.Workbook.SaveAs(actualWorkbookName);
98+
var actualWorkbook = new XLWorkbook(actualWorkbookName);
99+
93100
ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourceDynamicPanelDataSetRenderTest),
94-
nameof(TestRenderDataSetWithEvents_HorizontalPanel)), ws.Workbook);
101+
nameof(TestRenderDataSetWithEvents_HorizontalPanel)), actualWorkbook);
102+
103+
File.Delete(actualWorkbookName);
95104

96105
//report.Workbook.SaveAs("test.xlsx");
97106
}
Binary file not shown.
Binary file not shown.

ExcelReportGenerator/Excel/ExcelHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public static bool IsRangeInvalid(IXLRange range)
280280
range.FirstColumn().ColumnNumber();
281281
range.LastColumn().ColumnNumber();
282282
}
283-
catch (IndexOutOfRangeException)
283+
catch (ArgumentOutOfRangeException)
284284
{
285285
return true;
286286
}

0 commit comments

Comments
 (0)