Skip to content

Commit

Permalink
Code cleanup. Better comments, expression bodied properties...
Browse files Browse the repository at this point in the history
  • Loading branch information
jahav committed Sep 25, 2023
1 parent a35d338 commit ed21269
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
5 changes: 2 additions & 3 deletions ClosedXML/Excel/CalcEngine/DependencyTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ internal static DependencyTree CreateFrom(XLWorkbook workbook)
}
else
{
// TODO
throw new NotSupportedException();
// TODO: Implement other formulas. Don't throw on data table or shared formulas.
}
}
}
Expand Down Expand Up @@ -142,7 +141,7 @@ internal void RemoveFormula(XLCellFormula formula)
}
}

public void AddSheetTree(IXLWorksheet sheet)
internal void AddSheetTree(IXLWorksheet sheet)
{
_sheetTrees.Add(sheet.Name, new SheetDependencyTree());
}
Expand Down
4 changes: 2 additions & 2 deletions ClosedXML/Excel/CalcEngine/XLCalculationChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ internal static XLCalculationChain CreateFrom(XLWorkbook wb)
foreach (var sheet in wb.WorksheetsInternal)
{
var formulaSlice = sheet.Internals.CellsCollection.FormulaSlice;
using var e = formulaSlice.GetEnumerator(XLSheetRange.Full);
using var e = formulaSlice.GetForwardEnumerator(XLSheetRange.Full);
while (e.MoveNext())
chain.AddLast(new XLBookPoint(sheet.SheetId, e.Current));
chain.AddLast(new XLBookPoint(sheet.SheetId, e.Point));
}

return chain;
Expand Down
14 changes: 1 addition & 13 deletions ClosedXML/Excel/Cells/XLCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,19 +1061,7 @@ public IXLCell AddToNamed(string rangeName, XLScope scope, string comment)
/// <summary>
/// Flag indicating that previously calculated cell value may be not valid anymore and has to be re-evaluated.
/// </summary>
public bool NeedsRecalculation
{
get
{
if (Formula is null)
{
return false;
}

return Formula.IsDirty;
// return Formula.NeedsRecalculation(this);
}
}
public bool NeedsRecalculation => Formula is not null && Formula.IsDirty;

public XLCellValue CachedValue => SliceCellValue;

Expand Down
2 changes: 1 addition & 1 deletion ClosedXML/Excel/IXLWorksheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public interface IXLWorksheet : IXLRangeBase, IXLProtectable<IXLSheetProtection,
XLCellValue Evaluate(String expression, string formulaAddress = null);

/// <summary>
/// Force recalculation of all cell formulas in the sheet while leaving other sheets without change, even if they are dirty.
/// Force recalculation of all cell formulas in the sheet while leaving other sheets without change, even if their dirty cells.
/// </summary>
void RecalculateAllFormulas();

Expand Down
3 changes: 1 addition & 2 deletions ClosedXML/Excel/Ranges/XLRangeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ public String FormulaArrayA1
// If formula evaluates to a text, it is stored directly in a worksheet, not in SST. Thus
// when the switch to formula happens, disable shared string and enable when formula is removed.
var valueSlice = Worksheet.Internals.CellsCollection.ValueSlice;
var clearFormula = value is null;
for (var row = range.TopRow; row <= range.BottomRow; ++row)
{
for (var col = range.LeftColumn; col <= range.RightColumn; ++col)
{
valueSlice.SetShareString(new XLSheetPoint(row, col), clearFormula);
valueSlice.SetShareString(new XLSheetPoint(row, col), false);
}
}

Expand Down

0 comments on commit ed21269

Please sign in to comment.