diff --git a/ClosedXML/Excel/Cells/IXLCell.cs b/ClosedXML/Excel/Cells/IXLCell.cs
index d685041..d3efb2e 100644
--- a/ClosedXML/Excel/Cells/IXLCell.cs
+++ b/ClosedXML/Excel/Cells/IXLCell.cs
@@ -260,7 +260,7 @@
IXLCells InsertCellsBefore(int numberOfColumns);
///
- /// Creates a named range out of this cell.
+ /// Creates a named range out of this cell.
/// If the named range exists, it will add this range to that named range.
/// The default scope for the named range is Workbook.
///
@@ -268,7 +268,7 @@
IXLCell AddToNamed(String rangeName);
///
- /// Creates a named range out of this cell.
+ /// Creates a named range out of this cell.
/// If the named range exists, it will add this range to that named range.
/// Name of the range.
/// The scope for the named range.
@@ -276,7 +276,7 @@
IXLCell AddToNamed(String rangeName, XLScope scope);
///
- /// Creates a named range out of this cell.
+ /// Creates a named range out of this cell.
/// If the named range exists, it will add this range to that named range.
/// Name of the range.
/// The scope for the named range.
@@ -322,6 +322,7 @@
IXLCell SetActive(Boolean value = true);
Boolean HasFormula { get; }
+ Boolean HasArrayFormula { get; }
IXLRangeAddress FormulaReference { get; set; }
}
diff --git a/ClosedXML/Excel/Cells/XLCell.cs b/ClosedXML/Excel/Cells/XLCell.cs
index fc5db80..5815958 100644
--- a/ClosedXML/Excel/Cells/XLCell.cs
+++ b/ClosedXML/Excel/Cells/XLCell.cs
@@ -2592,6 +2592,8 @@
public Boolean HasFormula { get { return !String.IsNullOrWhiteSpace(FormulaA1); } }
+ public Boolean HasArrayFormula { get { return FormulaA1.StartsWith("{"); } }
+
public IXLRangeAddress FormulaReference { get; set; }
}
}
diff --git a/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/Excel/XLWorkbook_Load.cs
index 2389524..45d86a7 100644
--- a/ClosedXML/Excel/XLWorkbook_Load.cs
+++ b/ClosedXML/Excel/XLWorkbook_Load.cs
@@ -1175,7 +1175,13 @@
formula = cell.CellFormula.Text;
if (cell.CellFormula.Reference != null)
- xlCell.FormulaReference = ws.Range(cell.CellFormula.Reference.Value).RangeAddress;
+ {
+ foreach (var childCell in ws.Range(cell.CellFormula.Reference.Value).Cells(c => c.FormulaReference == null))
+ {
+ childCell.FormulaReference = ws.Range(cell.CellFormula.Reference.Value).RangeAddress;
+ childCell.FormulaA1 = formula;
+ }
+ }
xlCell.FormulaA1 = formula;
sharedFormulasR1C1.Add(cell.CellFormula.SharedIndex.Value, xlCell.FormulaR1C1);
@@ -1187,7 +1193,7 @@
{
if (cell.CellFormula.SharedIndex != null)
xlCell.FormulaR1C1 = sharedFormulasR1C1[cell.CellFormula.SharedIndex.Value];
- else
+ else if (!String.IsNullOrWhiteSpace(cell.CellFormula.Text))
{
String formula;
if (cell.CellFormula.FormulaType != null && cell.CellFormula.FormulaType == CellFormulaValues.Array)
@@ -1199,7 +1205,16 @@
}
if (cell.CellFormula.Reference != null)
- xlCell.FormulaReference = ws.Range(cell.CellFormula.Reference.Value).RangeAddress;
+ {
+ foreach (var childCell in ws.Range(cell.CellFormula.Reference.Value).Cells(c => c.FormulaReference == null || !c.HasFormula))
+ {
+ if (childCell.FormulaReference == null)
+ childCell.FormulaReference = ws.Range(cell.CellFormula.Reference.Value).RangeAddress;
+
+ if (!childCell.HasFormula)
+ childCell.FormulaA1 = xlCell.FormulaA1;
+ }
+ }
if (cell.CellValue != null)
xlCell.ValueCached = cell.CellValue.Text;
@@ -2399,4 +2414,4 @@
return false;
}
}
-}
\ No newline at end of file
+}