Skip to content

Commit

Permalink
Upgrade to ClosedXML 0.102 (#322)
Browse files Browse the repository at this point in the history
* Upgrade to ClosedXML 0.102

* Drop needless SetCalcEngineCacheExpressions as it uses inaccessible field
  • Loading branch information
Pankraty authored Jul 27, 2023
1 parent a530ce9 commit 2193707
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ClosedXML.Report/ClosedXML.Report.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.101.0" />
<PackageReference Include="ClosedXML" Version="0.102.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="morelinq" Version="3.4.1" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.0" />
Expand Down
1 change: 0 additions & 1 deletion ClosedXML.Report/Excel/TempSheetBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ private void Init()
if (!_wb.TryGetWorksheet(SheetName, out _sheet))
{
_sheet = _wb.AddWorksheet(SheetName);
_sheet.SetCalcEngineCacheExpressions(false);
}
_sheet.Visibility = XLWorksheetVisibility.VeryHidden;
}
Expand Down
7 changes: 0 additions & 7 deletions ClosedXML.Report/Excel/XlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,6 @@ public static IXLCell Offset(this IXLAddress addr, IXLAddress offset)
addr.ColumnNumber + offset.ColumnNumber - 1);
}

public static void SetCalcEngineCacheExpressions(this IXLWorksheet worksheet, bool value)
{
var wsType = worksheet.GetType();
var calcEngine = wsType.GetProperty("CalcEngine", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(worksheet, new object[] { });
calcEngine.GetType().GetProperty("CacheExpressions").SetValue(calcEngine, value, new object[] { });
}

/* ClosedXML issue #686 */
public static void ReplaceCFFormulaeToR1C1(this IXLWorksheet worksheet)
{
Expand Down
16 changes: 8 additions & 8 deletions ClosedXML.Report/Options/PivotTag.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
PivotTable Options Package
================================================
OPTION PARAMS OBJECTS
OPTION PARAMS OBJECTS
================================================
"Pivot" "Name=" Range
"Pivot" "Name=" Range
"Dst="
"RowGrand"
"ColumnGrand"
Expand All @@ -15,10 +15,10 @@ OPTION PARAMS OBJECTS
"AutofitColumns"
"NoSort"
"Data" Column
"Row" Column
"Column" Column
"Page" Column
"Data" Column
"Row" Column
"Column" Column
"Page" Column
================================================
*/

Expand Down Expand Up @@ -200,9 +200,9 @@ private IXLPivotTable CreatePivot(PivotTag pivot, ProcessingContext context, XLP
pt.PreserveCellFormatting = !pivot.HasParameter("NoPreserveFormatting");
pt.ShowGrandTotalsColumns = pivot.HasParameter("ColumnGrand");
pt.ShowGrandTotalsRows = pivot.HasParameter("RowGrand");
pt.SaveSourceData = true;
pt.PivotCache.SaveSourceData = true;
pt.FilterAreaOrder = XLFilterAreaOrder.DownThenOver;
pt.RefreshDataOnOpen = true;
pt.PivotCache.RefreshDataOnOpen = true;
return pt;
}

Expand Down
7 changes: 2 additions & 5 deletions ClosedXML.Report/RangeInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,9 @@ string EvalString(string str)
}

// refresh ranges for pivot tables
foreach (var pt in range.Worksheet.Workbook.Worksheets.SelectMany(sh => sh.PivotTables))
foreach (var pivotCache in range.Worksheet.Workbook.PivotCaches)
{
if (pt.SourceRange.Intersects(growedRange))
{
pt.SourceRange = growedRange.Offset(-1, 1, growedRange.RowCount() + 1, growedRange.ColumnCount() - 1);
}
pivotCache.Refresh();
}
}
}
Expand Down

0 comments on commit 2193707

Please sign in to comment.