diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/IXLCell.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/IXLCell.cs index 4ca1e98..7eaaf5d 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/IXLCell.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/IXLCell.cs @@ -173,5 +173,7 @@ //IXLCell CopyFrom(IXLCell otherCell); IXLCell CopyTo(IXLCell target); + + String ValueCached { get; } } } diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs index 9f87f82..6f993e2 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs @@ -1552,5 +1552,7 @@ target.Value = this; return target; } + + public String ValueCached { get; internal set; } } } diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs index 47520dc..2cfeb78 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs @@ -241,6 +241,9 @@ xlCell.FormulaA1 = formula; sharedFormulasR1C1.Add(cell.CellFormula.SharedIndex.Value, xlCell.FormulaR1C1); + + if (dCell.CellValue != null) + xlCell.ValueCached = dCell.CellValue.Text; } else if (dCell.CellFormula != null) { @@ -258,6 +261,9 @@ xlCell.FormulaA1 = formula; } + + if (dCell.CellValue != null) + xlCell.ValueCached = dCell.CellValue.Text; } else if (dCell.DataType != null) { diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs index 1d56301..c8808ff 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs @@ -3373,14 +3373,14 @@ // drawingsPart.WorksheetDrawing = new Xdr.WorksheetDrawing(); // var worksheetDrawing = drawingsPart.WorksheetDrawing; - + // if (!worksheetDrawing.NamespaceDeclarations.Contains(new KeyValuePair("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"))) // worksheetDrawing.AddNamespaceDeclaration("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); // if (!worksheetDrawing.NamespaceDeclarations.Contains(new KeyValuePair("a", "http://schemas.openxmlformats.org/drawingml/2006/main"))) // worksheetDrawing.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); - - // foreach (var chart in worksheet.Charts.OrderBy(c=>c.ZOrder).Select(c=>c)) + + // foreach (var chart in worksheet.Charts.OrderBy(c => c.ZOrder).Select(c => c)) // { // Xdr.TwoCellAnchor twoCellAnchor = new Xdr.TwoCellAnchor(); // worksheetDrawing.Append(twoCellAnchor); @@ -3623,17 +3623,9 @@ // C.StringReference stringReference1 = new C.StringReference(); // C.Formula formula1 = new C.Formula(); // formula1.Text = "Sheet1!$B$1"; - // C.StringCache stringCache1 = new C.StringCache(); - // C.PointCount pointCount1 = new C.PointCount() { Val = (UInt32Value)1U }; - // C.StringPoint stringPoint1 = new C.StringPoint() { Index = (UInt32Value)0U }; - // C.NumericValue numericValue1 = new C.NumericValue(); - // numericValue1.Text = "Value"; - - // stringPoint1.Append(numericValue1); - // stringCache1.Append(pointCount1); - // stringCache1.Append(stringPoint1); + // stringReference1.Append(formula1); - // stringReference1.Append(stringCache1); + // seriesText1.Append(stringReference1); // C.CategoryAxisData categoryAxisData1 = new C.CategoryAxisData(); diff --git a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs index 261a8cb..7d70228 100644 --- a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs +++ b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs @@ -15,8 +15,8 @@ static void Main(string[] args) { //var fileName = "BasicTable"; - //var fileName = "Sandbox"; - var fileName = "Issue_6609"; + var fileName = "Sandbox"; + //var fileName = "Issue_6609"; var wb = new XLWorkbook(String.Format(@"c:\Excel Files\ForTesting\{0}.xlsx", fileName)); //var wb = new XLWorkbook(); //var ws = wb.Worksheets.Add("Sheet1"); @@ -32,7 +32,7 @@ var ws = wb.Worksheet(1); - String a = ws.Cell("A9").GetValue(); + String a = ws.Cell("c1").ValueCached; wb.SaveAs(String.Format(@"c:\Excel Files\ForTesting\{0}_Saved.xlsx", fileName)); //Console.ReadKey();