diff --git a/ClosedXML/ClosedXML.csproj b/ClosedXML/ClosedXML.csproj
index 0aa0a6a..4bc2ce0 100644
--- a/ClosedXML/ClosedXML.csproj
+++ b/ClosedXML/ClosedXML.csproj
@@ -82,6 +82,7 @@
+
diff --git a/ClosedXML/Excel/Cells/IXLCell.cs b/ClosedXML/Excel/Cells/IXLCell.cs
index 9e82e5a..8df2759 100644
--- a/ClosedXML/Excel/Cells/IXLCell.cs
+++ b/ClosedXML/Excel/Cells/IXLCell.cs
@@ -330,6 +330,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 ae3d84c..f5e9084 100644
--- a/ClosedXML/Excel/Cells/XLCell.cs
+++ b/ClosedXML/Excel/Cells/XLCell.cs
@@ -2648,6 +2648,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/SaveOptions.cs b/ClosedXML/Excel/SaveOptions.cs
new file mode 100644
index 0000000..7dcd9a1
--- /dev/null
+++ b/ClosedXML/Excel/SaveOptions.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ClosedXML.Excel
+{
+ public sealed class SaveOptions
+ {
+ public SaveOptions()
+ {
+#if DEBUG
+ this.ValidatePackage = true;
+#else
+ this.ValidatePackage = false;
+#endif
+
+ this.EvaluateFormulasBeforeSaving = false;
+ this.GenerateCalculationChain = true;
+ }
+ public Boolean ValidatePackage;
+ public Boolean EvaluateFormulasBeforeSaving;
+ public Boolean GenerateCalculationChain;
+ }
+}
diff --git a/ClosedXML/Excel/XLWorkbook.cs b/ClosedXML/Excel/XLWorkbook.cs
index c4848c2..bdcc86c 100644
--- a/ClosedXML/Excel/XLWorkbook.cs
+++ b/ClosedXML/Excel/XLWorkbook.cs
@@ -41,7 +41,7 @@
Simple = 1,
}
- public partial class XLWorkbook : IDisposable
+ public partial class XLWorkbook: IDisposable
{
#region Static
@@ -52,59 +52,59 @@
get
{
return _defaultStyle ?? (_defaultStyle = new XLStyle(null)
- {
- Font = new XLFont(null, null)
- {
- Bold = false,
- Italic = false,
- Underline = XLFontUnderlineValues.None,
- Strikethrough = false,
+ {
+ Font = new XLFont(null, null)
+ {
+ Bold = false,
+ Italic = false,
+ Underline = XLFontUnderlineValues.None,
+ Strikethrough = false,
VerticalAlignment = XLFontVerticalTextAlignmentValues.Baseline,
- FontSize = 11,
- FontColor = XLColor.FromArgb(0, 0, 0),
- FontName = "Calibri",
+ FontSize = 11,
+ FontColor = XLColor.FromArgb(0, 0, 0),
+ FontName = "Calibri",
FontFamilyNumbering = XLFontFamilyNumberingValues.Swiss
- },
- Fill = new XLFill(null)
- {
- BackgroundColor = XLColor.FromIndex(64),
- PatternType = XLFillPatternValues.None,
- PatternColor = XLColor.FromIndex(64)
- },
- Border = new XLBorder(null, null)
- {
+ },
+ Fill = new XLFill(null)
+ {
+ BackgroundColor = XLColor.FromIndex(64),
+ PatternType = XLFillPatternValues.None,
+ PatternColor = XLColor.FromIndex(64)
+ },
+ Border = new XLBorder(null, null)
+ {
BottomBorder = XLBorderStyleValues.None,
DiagonalBorder = XLBorderStyleValues.None,
- DiagonalDown = false,
- DiagonalUp = false,
- LeftBorder = XLBorderStyleValues.None,
- RightBorder = XLBorderStyleValues.None,
- TopBorder = XLBorderStyleValues.None,
- BottomBorderColor = XLColor.Black,
- DiagonalBorderColor = XLColor.Black,
- LeftBorderColor = XLColor.Black,
- RightBorderColor = XLColor.Black,
- TopBorderColor = XLColor.Black
- },
+ DiagonalDown = false,
+ DiagonalUp = false,
+ LeftBorder = XLBorderStyleValues.None,
+ RightBorder = XLBorderStyleValues.None,
+ TopBorder = XLBorderStyleValues.None,
+ BottomBorderColor = XLColor.Black,
+ DiagonalBorderColor = XLColor.Black,
+ LeftBorderColor = XLColor.Black,
+ RightBorderColor = XLColor.Black,
+ TopBorderColor = XLColor.Black
+ },
NumberFormat = new XLNumberFormat(null, null) { NumberFormatId = 0 },
- Alignment = new XLAlignment(null)
- {
- Indent = 0,
+ Alignment = new XLAlignment(null)
+ {
+ Indent = 0,
Horizontal = XLAlignmentHorizontalValues.General,
- JustifyLastLine = false,
+ JustifyLastLine = false,
ReadingOrder = XLAlignmentReadingOrderValues.ContextDependent,
- RelativeIndent = 0,
- ShrinkToFit = false,
- TextRotation = 0,
+ RelativeIndent = 0,
+ ShrinkToFit = false,
+ TextRotation = 0,
Vertical = XLAlignmentVerticalValues.Bottom,
- WrapText = false
- },
- Protection = new XLProtection(null)
- {
- Locked = true,
- Hidden = false
- }
- });
+ WrapText = false
+ },
+ Protection = new XLProtection(null)
+ {
+ Locked = true,
+ Hidden = false
+ }
+ });
}
}
@@ -116,24 +116,24 @@
get
{
var defaultPageOptions = new XLPageSetup(null, null)
- {
- PageOrientation = XLPageOrientation.Default,
- Scale = 100,
- PaperSize = XLPaperSize.LetterPaper,
- Margins = new XLMargins
- {
- Top = 0.75,
- Bottom = 0.5,
- Left = 0.75,
- Right = 0.75,
- Header = 0.5,
- Footer = 0.75
- },
- ScaleHFWithDocument = true,
- AlignHFWithMargins = true,
- PrintErrorValue = XLPrintErrorValues.Displayed,
- ShowComments = XLShowCommentsValues.None
- };
+ {
+ PageOrientation = XLPageOrientation.Default,
+ Scale = 100,
+ PaperSize = XLPaperSize.LetterPaper,
+ Margins = new XLMargins
+ {
+ Top = 0.75,
+ Bottom = 0.5,
+ Left = 0.75,
+ Right = 0.75,
+ Header = 0.5,
+ Footer = 0.75
+ },
+ ScaleHFWithDocument = true,
+ AlignHFWithMargins = true,
+ PrintErrorValue = XLPrintErrorValues.Displayed,
+ ShowComments = XLShowCommentsValues.None
+ };
return defaultPageOptions;
}
}
@@ -143,10 +143,10 @@
get
{
return new XLOutline(null)
- {
- SummaryHLocation = XLOutlineSummaryHLocation.Right,
- SummaryVLocation = XLOutlineSummaryVLocation.Bottom
- };
+ {
+ SummaryHLocation = XLOutlineSummaryHLocation.Right,
+ SummaryVLocation = XLOutlineSummaryVLocation.Bottom
+ };
}
}
@@ -188,7 +188,7 @@
return _stylesById[id];
}
- #region Nested Type: XLLoadSource
+ #region Nested Type: XLLoadSource
private enum XLLoadSource
{
@@ -323,20 +323,20 @@
private void InitializeTheme()
{
Theme = new XLTheme
- {
- Text1 = XLColor.FromHtml("#FF000000"),
- Background1 = XLColor.FromHtml("#FFFFFFFF"),
- Text2 = XLColor.FromHtml("#FF1F497D"),
- Background2 = XLColor.FromHtml("#FFEEECE1"),
- Accent1 = XLColor.FromHtml("#FF4F81BD"),
- Accent2 = XLColor.FromHtml("#FFC0504D"),
- Accent3 = XLColor.FromHtml("#FF9BBB59"),
- Accent4 = XLColor.FromHtml("#FF8064A2"),
- Accent5 = XLColor.FromHtml("#FF4BACC6"),
- Accent6 = XLColor.FromHtml("#FFF79646"),
- Hyperlink = XLColor.FromHtml("#FF0000FF"),
- FollowedHyperlink = XLColor.FromHtml("#FF800080")
- };
+ {
+ Text1 = XLColor.FromHtml("#FF000000"),
+ Background1 = XLColor.FromHtml("#FFFFFFFF"),
+ Text2 = XLColor.FromHtml("#FF1F497D"),
+ Background2 = XLColor.FromHtml("#FFEEECE1"),
+ Accent1 = XLColor.FromHtml("#FF4F81BD"),
+ Accent2 = XLColor.FromHtml("#FFC0504D"),
+ Accent3 = XLColor.FromHtml("#FF9BBB59"),
+ Accent4 = XLColor.FromHtml("#FF8064A2"),
+ Accent5 = XLColor.FromHtml("#FF4BACC6"),
+ Accent6 = XLColor.FromHtml("#FFF79646"),
+ Hyperlink = XLColor.FromHtml("#FF0000FF"),
+ FollowedHyperlink = XLColor.FromHtml("#FF800080")
+ };
}
internal XLColor GetXLColor(XLThemeColor themeColor)
@@ -442,16 +442,26 @@
///
public void Save(Boolean validate, Boolean evaluateFormulae = false)
{
+ Save(new SaveOptions
+ {
+ ValidatePackage = validate,
+ EvaluateFormulasBeforeSaving = evaluateFormulae,
+ GenerateCalculationChain = true
+ });
+ }
+
+ public void Save(SaveOptions options)
+ {
checkForWorksheetsPresent();
if (_loadSource == XLLoadSource.New)
- throw new InvalidOperationException("This is a new file, please use one of the SaveAs methods.");
+ throw new InvalidOperationException("This is a new file. Please use one of the 'SaveAs' methods.");
if (_loadSource == XLLoadSource.Stream)
{
- CreatePackage(_originalStream, false, _spreadsheetDocumentType, validate, evaluateFormulae);
+ CreatePackage(_originalStream, false, _spreadsheetDocumentType, options);
}
else
- CreatePackage(_originalFile, _spreadsheetDocumentType, validate, evaluateFormulae);
+ CreatePackage(_originalFile, _spreadsheetDocumentType, options);
}
///
@@ -471,6 +481,16 @@
///
public void SaveAs(String file, Boolean validate, Boolean evaluateFormulae = false)
{
+ SaveAs(file, new SaveOptions
+ {
+ ValidatePackage = validate,
+ EvaluateFormulasBeforeSaving = evaluateFormulae,
+ GenerateCalculationChain = true
+ });
+ }
+
+ public void SaveAs(String file, SaveOptions options)
+ {
checkForWorksheetsPresent();
PathHelper.CreateDirectory(Path.GetDirectoryName(file));
if (_loadSource == XLLoadSource.New)
@@ -478,14 +498,14 @@
if (File.Exists(file))
File.Delete(file);
- CreatePackage(file, GetSpreadsheetDocumentType(file), validate, evaluateFormulae);
+ CreatePackage(file, GetSpreadsheetDocumentType(file), options);
}
else if (_loadSource == XLLoadSource.File)
{
if (String.Compare(_originalFile.Trim(), file.Trim(), true) != 0)
File.Copy(_originalFile, file, true);
- CreatePackage(file, GetSpreadsheetDocumentType(file), validate, evaluateFormulae);
+ CreatePackage(file, GetSpreadsheetDocumentType(file), options);
}
else if (_loadSource == XLLoadSource.Stream)
{
@@ -494,8 +514,7 @@
using (var fileStream = File.Create(file))
{
CopyStream(_originalStream, fileStream);
- //fileStream.Position = 0;
- CreatePackage(fileStream, false, _spreadsheetDocumentType, validate, evaluateFormulae);
+ CreatePackage(fileStream, false, _spreadsheetDocumentType, options);
fileStream.Close();
}
}
@@ -546,6 +565,16 @@
///
public void SaveAs(Stream stream, Boolean validate, Boolean evaluateFormulae = false)
{
+ SaveAs(stream, new SaveOptions
+ {
+ ValidatePackage = validate,
+ EvaluateFormulasBeforeSaving = evaluateFormulae,
+ GenerateCalculationChain = true
+ });
+ }
+
+ public void SaveAs(Stream stream, SaveOptions options)
+ {
checkForWorksheetsPresent();
if (_loadSource == XLLoadSource.New)
{
@@ -556,13 +585,13 @@
if (stream.CanRead && stream.CanSeek && stream.CanWrite)
{
// all is fine the package can be created in a direct way
- CreatePackage(stream, true, _spreadsheetDocumentType, validate, evaluateFormulae);
+ CreatePackage(stream, true, _spreadsheetDocumentType, options);
}
else
{
// the harder way
MemoryStream ms = new MemoryStream();
- CreatePackage(ms, true, _spreadsheetDocumentType, validate, evaluateFormulae);
+ CreatePackage(ms, true, _spreadsheetDocumentType, options);
// not really nessesary, because I changed CopyStream too.
// but for better understanding and if somebody in the future
// provide an changed version of CopyStream
@@ -577,7 +606,7 @@
CopyStream(fileStream, stream);
fileStream.Close();
}
- CreatePackage(stream, false, _spreadsheetDocumentType, validate, evaluateFormulae);
+ CreatePackage(stream, false, _spreadsheetDocumentType, options);
}
else if (_loadSource == XLLoadSource.Stream)
{
@@ -585,7 +614,7 @@
if (_originalStream != stream)
CopyStream(_originalStream, stream);
- CreatePackage(stream, false, _spreadsheetDocumentType, validate, evaluateFormulae);
+ CreatePackage(stream, false, _spreadsheetDocumentType, options);
}
}
@@ -669,7 +698,7 @@
}
}
- #region Fields
+#region Fields
private readonly XLLoadSource _loadSource = XLLoadSource.New;
private readonly String _originalFile;
@@ -677,13 +706,13 @@
#endregion Fields
- #region Constructor
+#region Constructor
///
/// Creates a new Excel workbook.
///
public XLWorkbook()
- : this(XLEventTracking.Enabled)
+ :this(XLEventTracking.Enabled)
{
}
@@ -744,7 +773,7 @@
/// Opens an existing workbook from a stream.
///
/// The stream to open.
- public XLWorkbook(Stream stream) : this(stream, XLEventTracking.Enabled)
+ public XLWorkbook(Stream stream):this(stream, XLEventTracking.Enabled)
{
}
@@ -758,7 +787,7 @@
#endregion Constructor
- #region Nested type: UnsupportedSheet
+#region Nested type: UnsupportedSheet
internal sealed class UnsupportedSheet
{
diff --git a/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/Excel/XLWorkbook_Load.cs
index 0cdd0f9..be0d818 100644
--- a/ClosedXML/Excel/XLWorkbook_Load.cs
+++ b/ClosedXML/Excel/XLWorkbook_Load.cs
@@ -1192,7 +1192,11 @@
formula = cell.CellFormula.Text;
if (cell.CellFormula.Reference != null)
+ {
+ // Parent cell of shared formulas
+ // Child cells will use this shared index to set its R1C1 style formula
xlCell.FormulaReference = ws.Range(cell.CellFormula.Reference.Value).RangeAddress;
+ }
xlCell.FormulaA1 = formula;
sharedFormulasR1C1.Add(cell.CellFormula.SharedIndex.Value, xlCell.FormulaR1C1);
@@ -1204,7 +1208,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)
@@ -1216,7 +1220,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;
diff --git a/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/Excel/XLWorkbook_Save.cs
index da45762..57edc21 100644
--- a/ClosedXML/Excel/XLWorkbook_Save.cs
+++ b/ClosedXML/Excel/XLWorkbook_Save.cs
@@ -111,7 +111,7 @@
return true;
}
- private void CreatePackage(String filePath, SpreadsheetDocumentType spreadsheetDocumentType, bool validate, bool evaluateFormulae)
+ private void CreatePackage(String filePath, SpreadsheetDocumentType spreadsheetDocumentType, SaveOptions options)
{
PathHelper.CreateDirectory(Path.GetDirectoryName(filePath));
var package = File.Exists(filePath)
@@ -120,12 +120,12 @@
using (package)
{
- CreateParts(package, evaluateFormulae);
- if (validate) Validate(package);
+ CreateParts(package, options);
+ if (options.ValidatePackage) Validate(package);
}
}
- private void CreatePackage(Stream stream, bool newStream, SpreadsheetDocumentType spreadsheetDocumentType, bool validate, bool evaluateFormulae)
+ private void CreatePackage(Stream stream, bool newStream, SpreadsheetDocumentType spreadsheetDocumentType, SaveOptions options)
{
var package = newStream
? SpreadsheetDocument.Create(stream, spreadsheetDocumentType)
@@ -133,8 +133,8 @@
using (package)
{
- CreateParts(package, evaluateFormulae);
- if (validate) Validate(package);
+ CreateParts(package, options);
+ if (options.ValidatePackage) Validate(package);
}
}
@@ -215,7 +215,7 @@
}
// Adds child parts and generates content of the specified part.
- private void CreateParts(SpreadsheetDocument document, bool evaluateFormulae)
+ private void CreateParts(SpreadsheetDocument document, SaveOptions options)
{
var context = new SaveContext();
@@ -311,7 +311,7 @@
GenerateVmlDrawingPartContent(vmlDrawingPart, worksheet, context);
}
- GenerateWorksheetPartContent(worksheetPart, worksheet, evaluateFormulae, context);
+ GenerateWorksheetPartContent(worksheetPart, worksheet, options.EvaluateFormulasBeforeSaving, context);
if (worksheet.PivotTables.Any())
{
@@ -330,7 +330,10 @@
if (workbookPart.Workbook.PivotCaches != null && !workbookPart.Workbook.PivotCaches.Any())
workbookPart.Workbook.RemoveChild(workbookPart.Workbook.PivotCaches);
- GenerateCalculationChainPartContent(workbookPart, context);
+ if (options.GenerateCalculationChain)
+ GenerateCalculationChainPartContent(workbookPart, context);
+ else
+ DeleteCalculationChainPartContent(workbookPart, context);
if (workbookPart.ThemePart == null)
{
@@ -590,7 +593,7 @@
workbook.WorkbookProtection = null;
}
- #endregion
+ #endregion WorkbookProtection
if (workbook.BookViews == null)
workbook.BookViews = new BookViews();
@@ -1002,11 +1005,16 @@
return run;
}
+ private void DeleteCalculationChainPartContent(WorkbookPart workbookPart, SaveContext context)
+ {
+ if (workbookPart.CalculationChainPart != null)
+ workbookPart.DeletePart(workbookPart.CalculationChainPart);
+ }
+
private void GenerateCalculationChainPartContent(WorkbookPart workbookPart, SaveContext context)
{
- var thisRelId = context.RelIdGenerator.GetNext(RelType.Workbook);
if (workbookPart.CalculationChainPart == null)
- workbookPart.AddNewPart(thisRelId);
+ workbookPart.AddNewPart(context.RelIdGenerator.GetNext(RelType.Workbook));
if (workbookPart.CalculationChainPart.CalculationChain == null)
workbookPart.CalculationChainPart.CalculationChain = new CalculationChain();
@@ -1023,25 +1031,33 @@
cellsWithoutFormulas.Add(c.Address.ToStringRelative());
else
{
- if (c.FormulaA1.StartsWith("{"))
+ if (c.HasArrayFormula)
{
- var cc = new CalculationCell
- {
- CellReference = c.Address.ToString(),
- SheetId = worksheet.SheetId
- };
-
- if (c.FormulaReference == null)
- c.FormulaReference = c.AsRange().RangeAddress;
if (c.FormulaReference.FirstAddress.Equals(c.Address))
{
+ var cc = new CalculationCell
+ {
+ CellReference = c.Address.ToString(),
+ SheetId = worksheet.SheetId
+ };
+
+ if (c.FormulaReference == null)
+ c.FormulaReference = c.AsRange().RangeAddress;
+
cc.Array = true;
calculationChain.AppendChild(cc);
- calculationChain.AppendChild(new CalculationCell { CellReference = c.Address.ToString(), InChildChain = true });
- }
- else
- {
- calculationChain.AppendChild(cc);
+
+ foreach (var childCell in worksheet.Range(c.FormulaReference.ToString()).Cells())
+ {
+ calculationChain.AppendChild(
+ new CalculationCell
+ {
+ CellReference = childCell.Address.ToString(),
+ SheetId = worksheet.SheetId,
+ InChildChain = true
+ }
+ );
+ }
}
}
else
@@ -1055,17 +1071,34 @@
}
}
- //var cCellsToRemove = new List();
- var m = from cc in calculationChain.Elements()
- where !(cc.SheetId != null || cc.InChildChain != null)
- && calculationChain.Elements()
- .Where(c1 => c1.SheetId != null)
- .Select(c1 => c1.CellReference.Value)
- .Contains(cc.CellReference.Value)
- || cellsWithoutFormulas.Contains(cc.CellReference.Value)
- select cc;
- //m.ToList().ForEach(cc => cCellsToRemove.Add(cc));
- m.ToList().ForEach(cc => calculationChain.RemoveChild(cc));
+ // This part shouldn't be necessary anymore, but I'm keeping it in the DEBUG configuration until I'm 100% sure.
+
+#if DEBUG
+ var sheetCellReferences = calculationChain.Elements()
+ .Where(cc1 => cc1.SheetId != null)
+ .Select(cc1 => cc1.CellReference.Value)
+ .ToList();
+
+ // Remove orphaned calc chain cells
+ var cellsToRemove = calculationChain.Elements()
+ .Where(cc =>
+ {
+ return cc.SheetId == worksheet.SheetId
+ && cellsWithoutFormulas.Contains(cc.CellReference.Value)
+ || cc.SheetId == null
+ && cc.InChildChain == null
+ && sheetCellReferences.Contains(cc.CellReference.Value);
+ })
+ .ToArray();
+
+ // This shouldn't happen, because the calc chain should be correctly generated
+ System.Diagnostics.Debug.Assert(!cellsToRemove.Any());
+
+ foreach (var cc in cellsToRemove)
+ {
+ calculationChain.RemoveChild(cc);
+ }
+#endif
}
if (!calculationChain.Any())
@@ -4255,16 +4288,17 @@
}
cell.StyleIndex = styleId;
- var formula = xlCell.FormulaA1;
if (xlCell.HasFormula)
{
- if (formula.StartsWith("{"))
+ var formula = xlCell.FormulaA1;
+ if (xlCell.HasArrayFormula)
{
formula = formula.Substring(1, formula.Length - 2);
var f = new CellFormula { FormulaType = CellFormulaValues.Array };
if (xlCell.FormulaReference == null)
xlCell.FormulaReference = xlCell.AsRange().RangeAddress;
+
if (xlCell.FormulaReference.FirstAddress.Equals(xlCell.Address))
{
f.Text = formula;
@@ -4289,7 +4323,6 @@
if (!xlCell.HasFormula || evaluateFormulae)
SetCellValue(xlCell, cell);
-
}
}
xlWorksheet.Internals.CellsCollection.deleted.Remove(distinctRow);
diff --git a/ClosedXML/Excel/XLWorksheet.cs b/ClosedXML/Excel/XLWorksheet.cs
index d2e4bc0..c40ad1b 100644
--- a/ClosedXML/Excel/XLWorksheet.cs
+++ b/ClosedXML/Excel/XLWorksheet.cs
@@ -1530,6 +1530,11 @@
public String Author { get; set; }
+ public override string ToString()
+ {
+ return this.Name;
+ }
+
public IXLPictures Pictures { get; private set; }
public IXLPicture Picture(string pictureName)
diff --git a/ClosedXML_Examples/Misc/Formulas.cs b/ClosedXML_Examples/Misc/Formulas.cs
index 729cb9e..8066a81 100644
--- a/ClosedXML_Examples/Misc/Formulas.cs
+++ b/ClosedXML_Examples/Misc/Formulas.cs
@@ -54,6 +54,7 @@
// Just put the formula between curly braces
ws.Cell("A6").Value = "Array Formula: ";
ws.Cell("B6").FormulaA1 = "{A2+A3}";
+ ws.Range("C6:D6").FormulaA1 = "{TRANSPOSE(A2:A3)}";
ws.Range(1, 1, 1, 7).Style.Fill.BackgroundColor = XLColor.Cyan;
ws.Range(1, 1, 1, 7).Style.Font.Bold = true;
diff --git a/ClosedXML_Tests/Excel/Misc/SearchTests.cs b/ClosedXML_Tests/Excel/Misc/SearchTests.cs
index 0da76e2..21e299d 100644
--- a/ClosedXML_Tests/Excel/Misc/SearchTests.cs
+++ b/ClosedXML_Tests/Excel/Misc/SearchTests.cs
@@ -66,8 +66,8 @@
Assert.AreEqual("C2", foundCells.First().Address.ToString());
foundCells = ws.Search("A2", CompareOptions.Ordinal, true);
- Assert.AreEqual(4, foundCells.Count());
- Assert.AreEqual("C2,D2,B6,A11", string.Join(",", foundCells.Select(c => c.Address.ToString()).ToArray()));
+ Assert.AreEqual(6, foundCells.Count());
+ Assert.AreEqual("C2,D2,B6,C6,D6,A11", string.Join(",", foundCells.Select(c => c.Address.ToString()).ToArray()));
foundCells = ws.Search("RC", CompareOptions.Ordinal, true);
Assert.AreEqual(3, foundCells.Count());
diff --git a/ClosedXML_Tests/Resource/Examples/Misc/CopyingWorksheets.xlsx b/ClosedXML_Tests/Resource/Examples/Misc/CopyingWorksheets.xlsx
index 6d14038..28c4b9b 100644
--- a/ClosedXML_Tests/Resource/Examples/Misc/CopyingWorksheets.xlsx
+++ b/ClosedXML_Tests/Resource/Examples/Misc/CopyingWorksheets.xlsx
Binary files differ
diff --git a/ClosedXML_Tests/Resource/Examples/Misc/Formulas.xlsx b/ClosedXML_Tests/Resource/Examples/Misc/Formulas.xlsx
index dea7693..c49d20a 100644
--- a/ClosedXML_Tests/Resource/Examples/Misc/Formulas.xlsx
+++ b/ClosedXML_Tests/Resource/Examples/Misc/Formulas.xlsx
Binary files differ
diff --git a/ClosedXML_Tests/Resource/Examples/Misc/FormulasWithEvaluation.xlsx b/ClosedXML_Tests/Resource/Examples/Misc/FormulasWithEvaluation.xlsx
index 7a93ddb..f1dde09 100644
--- a/ClosedXML_Tests/Resource/Examples/Misc/FormulasWithEvaluation.xlsx
+++ b/ClosedXML_Tests/Resource/Examples/Misc/FormulasWithEvaluation.xlsx
Binary files differ
diff --git a/ClosedXML_Tests/Resource/Examples/Ranges/NamedRanges.xlsx b/ClosedXML_Tests/Resource/Examples/Ranges/NamedRanges.xlsx
index 8d4e6a2..2b450d6 100644
--- a/ClosedXML_Tests/Resource/Examples/Ranges/NamedRanges.xlsx
+++ b/ClosedXML_Tests/Resource/Examples/Ranges/NamedRanges.xlsx
Binary files differ