diff --git a/ClosedXML.sln b/ClosedXML.sln
index b58a074..cd1cd87 100644
--- a/ClosedXML.sln
+++ b/ClosedXML.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio 15
+VisualStudioVersion = 15.0.26730.3
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClosedXML_Sandbox", "ClosedXML_Sandbox\ClosedXML_Sandbox.csproj", "{38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClosedXML_Sandbox", "ClosedXML_Sandbox\ClosedXML_Sandbox.csproj", "{38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5C94E22C-85AA-48FD-B082-CF929FFC6C31}"
ProjectSection(SolutionItems) = preProject
@@ -11,11 +11,11 @@
ClosedXML.vsmdi = ClosedXML.vsmdi
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClosedXML_Examples", "ClosedXML_Examples\ClosedXML_Examples.csproj", "{03A518D0-1CB7-488E-861C-C4E782B27A46}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClosedXML_Examples", "ClosedXML_Examples\ClosedXML_Examples.csproj", "{03A518D0-1CB7-488E-861C-C4E782B27A46}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClosedXML", "ClosedXML\ClosedXML.csproj", "{BD5E6BFE-E837-4A35-BCA9-39667D873A20}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClosedXML", "ClosedXML\ClosedXML.csproj", "{BD5E6BFE-E837-4A35-BCA9-39667D873A20}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClosedXML_Tests", "ClosedXML_Tests\ClosedXML_Tests.csproj", "{09B066ED-E4A7-4545-A1A4-FF03DD524BDF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClosedXML_Tests", "ClosedXML_Tests\ClosedXML_Tests.csproj", "{09B066ED-E4A7-4545-A1A4-FF03DD524BDF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{073CFB1C-43DC-4ADC-9D12-BB8D7B10C099}"
ProjectSection(SolutionItems) = preProject
@@ -49,6 +49,9 @@
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {2E35B7D8-9690-408F-B52A-F4FC485A6B09}
+ EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = ClosedXML.vsmdi
EndGlobalSection
diff --git a/ClosedXML/Attributes/XLColumnAttribute.cs b/ClosedXML/Attributes/XLColumnAttribute.cs
index 526dcb0..a86a1be 100644
--- a/ClosedXML/Attributes/XLColumnAttribute.cs
+++ b/ClosedXML/Attributes/XLColumnAttribute.cs
@@ -1,8 +1,7 @@
+using ClosedXML.Excel;
using System;
using System.Linq;
using System.Reflection;
-using ClosedXML;
-using ClosedXML.Excel;
namespace ClosedXML.Attributes
{
@@ -23,7 +22,7 @@
{
var attribute = GetXLColumnAttribute(mi);
if (attribute == null) return null;
- return String.IsNullOrWhiteSpace(attribute.Header) ? null : attribute.Header;
+ return XLHelper.IsNullOrWhiteSpace(attribute.Header) ? null : attribute.Header;
}
internal static Int32 GetOrder(MemberInfo mi)
diff --git a/ClosedXML/ClosedXML.csproj b/ClosedXML/ClosedXML.csproj
index 3125799..8f3cc12 100644
--- a/ClosedXML/ClosedXML.csproj
+++ b/ClosedXML/ClosedXML.csproj
@@ -1,385 +1,53 @@
-
-
+
+
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- {BD5E6BFE-E837-4A35-BCA9-39667D873A20}
- Library
- Properties
- ClosedXML
- ClosedXML
- v4.0
- 512
- ..\
- true
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- 1591
- false
- 6
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- bin\Release\ClosedXML.xml
- 1591
- false
- 6
-
-
+ netstandard2.0;net40;net46
+ 0.9
+ Manuel de Leon, Amir Ghezelbash, Francois Botha
+
+
+ ClosedXML makes it easier for developers to create Excel 2007+ (.xlsx, .xlsm, etc) files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and VisualBasic.NET.
+ MIT
+ https://github.com/ClosedXML/ClosedXML/blob/master/LICENSE
+ https://github.com/ClosedXML/ClosedXML
+ https://github.com/ClosedXML/ClosedXML
true
-
-
ClosedXML.snk
+ $(NoWarn);NU1605;CS1591
+ true
-
-
- ..\packages\DocumentFormat.OpenXml.2.7.2\lib\net40\DocumentFormat.OpenXml.dll
- True
-
-
- ..\packages\ExcelNumberFormat.1.0.3\lib\net20\ExcelNumberFormat.dll
- True
-
-
- ..\packages\FastMember.Signed.1.3.0\lib\net40\FastMember.Signed.dll
- True
-
+
+
+ $(DefineConstants);_NETSTANDARD_;_NETSTANDARD2_0_
+
+
+
+ $(DefineConstants);_NETFRAMEWORK_;_NET40_
+
+
+
+ $(DefineConstants);_NETFRAMEWORK_;_NET46_
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
- .editorconfig
-
-
-
+
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
diff --git a/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs b/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs
index da2f83b..86155cb 100644
--- a/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs
+++ b/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs
@@ -101,7 +101,7 @@
{
_evaluating = true;
var f = cell.FormulaA1;
- if (String.IsNullOrWhiteSpace(f))
+ if (XLHelper.IsNullOrWhiteSpace(f))
return cell.Value;
else
return new XLCalcEngine(cell.Worksheet).Evaluate(f);
diff --git a/ClosedXML/Excel/Cells/XLCell.cs b/ClosedXML/Excel/Cells/XLCell.cs
index 58afd37..1debabd 100644
--- a/ClosedXML/Excel/Cells/XLCell.cs
+++ b/ClosedXML/Excel/Cells/XLCell.cs
@@ -353,7 +353,7 @@
return cValue;
}
else
- return cValue;
+ return cValue;
}
///
@@ -366,7 +366,7 @@
get
{
var fA1 = FormulaA1;
- if (!String.IsNullOrWhiteSpace(fA1))
+ if (!XLHelper.IsNullOrWhiteSpace(fA1))
{
if (IsEvaluating)
throw new InvalidOperationException("Circular Reference");
@@ -524,7 +524,7 @@
if (!hasTitles)
{
var fieldName = XLColumnAttribute.GetHeader(itemType);
- if (String.IsNullOrWhiteSpace(fieldName))
+ if (XLHelper.IsNullOrWhiteSpace(fieldName))
fieldName = itemType.Name;
_worksheet.SetValue(fieldName, fRo, co);
@@ -602,7 +602,7 @@
if (!hasTitles)
{
foreach (var fieldName in from DataColumn column in row.Table.Columns
- select String.IsNullOrWhiteSpace(column.Caption)
+ select XLHelper.IsNullOrWhiteSpace(column.Caption)
? column.ColumnName
: column.Caption)
{
@@ -655,7 +655,7 @@
if (!(mi is IEnumerable))
{
var fieldName = XLColumnAttribute.GetHeader(mi);
- if (String.IsNullOrWhiteSpace(fieldName))
+ if (XLHelper.IsNullOrWhiteSpace(fieldName))
fieldName = mi.Name;
_worksheet.SetValue(fieldName, fRo, co);
@@ -1083,9 +1083,9 @@
{
get
{
- if (String.IsNullOrWhiteSpace(_formulaA1))
+ if (XLHelper.IsNullOrWhiteSpace(_formulaA1))
{
- if (!String.IsNullOrWhiteSpace(_formulaR1C1))
+ if (!XLHelper.IsNullOrWhiteSpace(_formulaR1C1))
{
_formulaA1 = GetFormulaA1(_formulaR1C1);
return FormulaA1;
@@ -1105,7 +1105,7 @@
set
{
- _formulaA1 = String.IsNullOrWhiteSpace(value) ? null : value;
+ _formulaA1 = XLHelper.IsNullOrWhiteSpace(value) ? null : value;
_formulaR1C1 = null;
}
@@ -1115,7 +1115,7 @@
{
get
{
- if (String.IsNullOrWhiteSpace(_formulaR1C1))
+ if (XLHelper.IsNullOrWhiteSpace(_formulaR1C1))
_formulaR1C1 = GetFormulaR1C1(FormulaA1);
return _formulaR1C1;
@@ -1123,7 +1123,7 @@
set
{
- _formulaR1C1 = String.IsNullOrWhiteSpace(value) ? null : value;
+ _formulaR1C1 = XLHelper.IsNullOrWhiteSpace(value) ? null : value;
_formulaA1 = null;
}
@@ -1763,7 +1763,7 @@
{
var style = GetStyleForRead();
return _dataType == XLDataType.Number
- && String.IsNullOrWhiteSpace(style.NumberFormat.Format)
+ && XLHelper.IsNullOrWhiteSpace(style.NumberFormat.Format)
&& ((style.NumberFormat.NumberFormatId >= 14
&& style.NumberFormat.NumberFormatId <= 22)
|| (style.NumberFormat.NumberFormatId >= 45
@@ -1774,7 +1774,7 @@
{
var format = String.Empty;
var style = GetStyleForRead();
- if (String.IsNullOrWhiteSpace(style.NumberFormat.Format))
+ if (XLHelper.IsNullOrWhiteSpace(style.NumberFormat.Format))
{
var formatCodes = XLPredefinedFormat.FormatCodes;
if (formatCodes.ContainsKey(style.NumberFormat.NumberFormatId))
@@ -2039,7 +2039,7 @@
private string GetFormula(string strValue, FormulaConversionType conversionType, int rowsToShift,
int columnsToShift)
{
- if (String.IsNullOrWhiteSpace(strValue))
+ if (XLHelper.IsNullOrWhiteSpace(strValue))
return String.Empty;
var value = ">" + strValue + "<";
@@ -2321,7 +2321,7 @@
internal static String ShiftFormulaRows(String formulaA1, XLWorksheet worksheetInAction, XLRange shiftedRange,
int rowsShifted)
{
- if (String.IsNullOrWhiteSpace(formulaA1)) return String.Empty;
+ if (XLHelper.IsNullOrWhiteSpace(formulaA1)) return String.Empty;
var value = formulaA1;
@@ -2470,7 +2470,7 @@
internal static String ShiftFormulaColumns(String formulaA1, XLWorksheet worksheetInAction, XLRange shiftedRange,
int columnsShifted)
{
- if (String.IsNullOrWhiteSpace(formulaA1)) return String.Empty;
+ if (XLHelper.IsNullOrWhiteSpace(formulaA1)) return String.Empty;
var value = formulaA1;
@@ -2739,7 +2739,7 @@
#endregion XLCell Right
- public Boolean HasFormula { get { return !String.IsNullOrWhiteSpace(FormulaA1); } }
+ public Boolean HasFormula { get { return !XLHelper.IsNullOrWhiteSpace(FormulaA1); } }
public Boolean HasArrayFormula { get { return FormulaA1.StartsWith("{"); } }
diff --git a/ClosedXML/Excel/Columns/XLColumn.cs b/ClosedXML/Excel/Columns/XLColumn.cs
index cb8aae5..9a94c32 100644
--- a/ClosedXML/Excel/Columns/XLColumn.cs
+++ b/ClosedXML/Excel/Columns/XLColumn.cs
@@ -297,6 +297,7 @@
public IXLColumn AdjustToContents(Int32 startRow, Int32 endRow, Double minWidth, Double maxWidth)
{
var fontCache = new Dictionary();
+
Double colMaxWidth = minWidth;
List autoFilterRows = new List();
diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFColorScaleConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFColorScaleConverter.cs
index 5fc548c..bddd195 100644
--- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFColorScaleConverter.cs
+++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFColorScaleConverter.cs
@@ -1,5 +1,5 @@
-using System;
using DocumentFormat.OpenXml.Spreadsheet;
+using System;
namespace ClosedXML.Excel
{
diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFDataBarConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFDataBarConverter.cs
index 29300fa..67b19a0 100644
--- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFDataBarConverter.cs
+++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFDataBarConverter.cs
@@ -1,7 +1,7 @@
-using System;
-using System.Linq;
using ClosedXML.Extensions;
using DocumentFormat.OpenXml.Spreadsheet;
+using System;
+using System.Linq;
namespace ClosedXML.Excel
{
@@ -25,9 +25,11 @@
case XLColorType.Color:
color.Rgb = cf.Colors[1].Color.ToHex();
break;
+
case XLColorType.Theme:
color.Theme = System.Convert.ToUInt32(cf.Colors[1].ThemeColor);
break;
+
case XLColorType.Indexed:
color.Indexed = System.Convert.ToUInt32(cf.Colors[1].Indexed);
break;
@@ -37,7 +39,6 @@
dataBar.Append(conditionalFormatValueObject2);
dataBar.Append(color);
-
conditionalFormattingRule.Append(dataBar);
if (cf.Colors.Count > 1)
diff --git a/ClosedXML/Excel/DataValidation/XLDataValidation.cs b/ClosedXML/Excel/DataValidation/XLDataValidation.cs
index 3ee5896..8c189db 100644
--- a/ClosedXML/Excel/DataValidation/XLDataValidation.cs
+++ b/ClosedXML/Excel/DataValidation/XLDataValidation.cs
@@ -48,9 +48,9 @@
return
AllowedValues != XLAllowedValues.AnyValue
|| (ShowInputMessage &&
- (!String.IsNullOrWhiteSpace(InputTitle) || !String.IsNullOrWhiteSpace(InputMessage)))
+ (!XLHelper.IsNullOrWhiteSpace(InputTitle) || !XLHelper.IsNullOrWhiteSpace(InputMessage)))
||(ShowErrorMessage &&
- (!String.IsNullOrWhiteSpace(ErrorTitle) || !String.IsNullOrWhiteSpace(ErrorMessage)));
+ (!XLHelper.IsNullOrWhiteSpace(ErrorTitle) || !XLHelper.IsNullOrWhiteSpace(ErrorMessage)));
}
diff --git a/ClosedXML/Excel/Drawings/PictureEnums.cs b/ClosedXML/Excel/Drawings/PictureEnums.cs
index 3d76e73..f00f85b 100644
--- a/ClosedXML/Excel/Drawings/PictureEnums.cs
+++ b/ClosedXML/Excel/Drawings/PictureEnums.cs
@@ -14,9 +14,9 @@
Tiff = 3,
Icon = 4,
Pcx = 5,
- Jpeg = 6,
- Emf = 7,
- Wmf = 8
+ Jpeg = 6
+ //Emf = 7,
+ //Wmf = 8
}
public enum XLPicturePlacement
diff --git a/ClosedXML/Excel/Drawings/XLPictures.cs b/ClosedXML/Excel/Drawings/XLPictures.cs
index c539d0e..705ccb1 100644
--- a/ClosedXML/Excel/Drawings/XLPictures.cs
+++ b/ClosedXML/Excel/Drawings/XLPictures.cs
@@ -73,9 +73,9 @@
public IXLPicture Add(string imageFile)
{
- using (var bitmap = Image.FromFile(imageFile) as Bitmap)
+ using (var fs = File.Open(imageFile, FileMode.Open))
{
- var picture = new XLPicture(_worksheet, bitmap);
+ var picture = new XLPicture(_worksheet, fs);
_pictures.Add(picture);
picture.Name = GetNextPictureName();
return picture;
diff --git a/ClosedXML/Excel/IXLTheme.cs b/ClosedXML/Excel/IXLTheme.cs
index 17e4e57..b506e22 100644
--- a/ClosedXML/Excel/IXLTheme.cs
+++ b/ClosedXML/Excel/IXLTheme.cs
@@ -1,6 +1,3 @@
-using ClosedXML.Excel;
-using System.Drawing;
-
namespace ClosedXML.Excel
{
public interface IXLTheme
diff --git a/ClosedXML/Excel/Misc/XLFormula.cs b/ClosedXML/Excel/Misc/XLFormula.cs
index 8027667..34cea84 100644
--- a/ClosedXML/Excel/Misc/XLFormula.cs
+++ b/ClosedXML/Excel/Misc/XLFormula.cs
@@ -44,7 +44,7 @@
else
{
_value = value.Trim();
- IsFormula = !String.IsNullOrWhiteSpace(_value) && _value.TrimStart()[0] == '=' ;
+ IsFormula = !XLHelper.IsNullOrWhiteSpace(_value) && _value.TrimStart()[0] == '=' ;
if (IsFormula)
_value = _value.Substring(1);
}
diff --git a/ClosedXML/Excel/PageSetup/XLHFText.cs b/ClosedXML/Excel/PageSetup/XLHFText.cs
index f9530a3..6659cd6 100644
--- a/ClosedXML/Excel/PageSetup/XLHFText.cs
+++ b/ClosedXML/Excel/PageSetup/XLHFText.cs
@@ -6,11 +6,13 @@
internal class XLHFText
{
private readonly XLHFItem _hfItem;
+
public XLHFText(XLRichString richText, XLHFItem hfItem)
{
RichText = richText;
_hfItem = hfItem;
}
+
public XLRichString RichText { get; private set; }
public String GetHFText(String prevText)
@@ -98,6 +100,5 @@
return sb.ToString();
}
-
}
}
diff --git a/ClosedXML/Excel/Ranges/XLRangeBase.cs b/ClosedXML/Excel/Ranges/XLRangeBase.cs
index 5c9e661..84948c3 100644
--- a/ClosedXML/Excel/Ranges/XLRangeBase.cs
+++ b/ClosedXML/Excel/Ranges/XLRangeBase.cs
@@ -1126,7 +1126,7 @@
{
foreach (XLWorksheet ws in Worksheet.Workbook.WorksheetsInternal)
{
- foreach (XLCell cell in ws.Internals.CellsCollection.GetCells(c => !String.IsNullOrWhiteSpace(c.FormulaA1)))
+ foreach (XLCell cell in ws.Internals.CellsCollection.GetCells(c => !XLHelper.IsNullOrWhiteSpace(c.FormulaA1)))
using (var asRange = AsRange())
cell.ShiftFormulaColumns(asRange, numberOfColumns);
}
@@ -1342,7 +1342,7 @@
using (var asRange = AsRange())
foreach (XLWorksheet ws in Worksheet.Workbook.WorksheetsInternal)
{
- foreach (XLCell cell in ws.Internals.CellsCollection.GetCells(c => !String.IsNullOrWhiteSpace(c.FormulaA1)))
+ foreach (XLCell cell in ws.Internals.CellsCollection.GetCells(c => !XLHelper.IsNullOrWhiteSpace(c.FormulaA1)))
cell.ShiftFormulaRows(asRange, numberOfRows);
}
@@ -1503,7 +1503,7 @@
XLCell cell in
Worksheet.Workbook.Worksheets.Cast().SelectMany(
xlWorksheet => (xlWorksheet).Internals.CellsCollection.GetCells(
- c => !String.IsNullOrWhiteSpace(c.FormulaA1))))
+ c => !XLHelper.IsNullOrWhiteSpace(c.FormulaA1))))
{
if (shiftDeleteCells == XLShiftDeletedCells.ShiftCellsUp)
cell.ShiftFormulaRows((XLRange)shiftedRangeFormula, numberOfRows * -1);
@@ -1791,7 +1791,7 @@
public IXLRangeBase Sort(String columnsToSortBy, XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true)
{
SortColumns.Clear();
- if (String.IsNullOrWhiteSpace(columnsToSortBy))
+ if (XLHelper.IsNullOrWhiteSpace(columnsToSortBy))
{
columnsToSortBy = DefaultSortString();
}
diff --git a/ClosedXML/Excel/Rows/XLRow.cs b/ClosedXML/Excel/Rows/XLRow.cs
index e7f4cd8..697801e 100644
--- a/ClosedXML/Excel/Rows/XLRow.cs
+++ b/ClosedXML/Excel/Rows/XLRow.cs
@@ -285,6 +285,7 @@
public IXLRow AdjustToContents(Int32 startColumn, Int32 endColumn, Double minHeight, Double maxHeight)
{
var fontCache = new Dictionary();
+
Double rowMaxHeight = minHeight;
foreach (XLCell c in from XLCell c in Row(startColumn, endColumn).CellsUsed() where !c.IsMerged() select c)
{
diff --git a/ClosedXML/Excel/SaveOptions.cs b/ClosedXML/Excel/SaveOptions.cs
index 7dcd9a1..62edb53 100644
--- a/ClosedXML/Excel/SaveOptions.cs
+++ b/ClosedXML/Excel/SaveOptions.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ClosedXML.Excel
{
@@ -19,6 +15,7 @@
this.EvaluateFormulasBeforeSaving = false;
this.GenerateCalculationChain = true;
}
+
public Boolean ValidatePackage;
public Boolean EvaluateFormulasBeforeSaving;
public Boolean GenerateCalculationChain;
diff --git a/ClosedXML/Excel/Style/Colors/XLColor_Internal.cs b/ClosedXML/Excel/Style/Colors/XLColor_Internal.cs
index a5aeafc..dcea153 100644
--- a/ClosedXML/Excel/Style/Colors/XLColor_Internal.cs
+++ b/ClosedXML/Excel/Style/Colors/XLColor_Internal.cs
@@ -65,4 +65,4 @@
_colorType = XLColorType.Theme;
}
}
-}
\ No newline at end of file
+}
diff --git a/ClosedXML/Excel/Style/Colors/XLColor_Public.cs b/ClosedXML/Excel/Style/Colors/XLColor_Public.cs
index 4d0d9d3..ce6031a 100644
--- a/ClosedXML/Excel/Style/Colors/XLColor_Public.cs
+++ b/ClosedXML/Excel/Style/Colors/XLColor_Public.cs
@@ -105,7 +105,7 @@
if (ColorType == XLColorType.Indexed)
throw new InvalidOperationException("Cannot extract theme tint from an indexed color.");
- return _color.A/255.0;
+ return _color.A / 255.0;
}
}
@@ -132,11 +132,11 @@
return false;
}
- #endregion
+ #endregion IEquatable Members
public override bool Equals(object obj)
{
- return Equals((XLColor) obj);
+ return Equals((XLColor)obj);
}
public override int GetHashCode()
diff --git a/ClosedXML/Excel/Style/Colors/XLColor_Static.cs b/ClosedXML/Excel/Style/Colors/XLColor_Static.cs
index 3c8ec59..efd6b7c 100644
--- a/ClosedXML/Excel/Style/Colors/XLColor_Static.cs
+++ b/ClosedXML/Excel/Style/Colors/XLColor_Static.cs
@@ -39,10 +39,12 @@
return FromColor(Color.FromArgb(a, r, g, b));
}
+#if _NETFRAMEWORK_
public static XLColor FromKnownColor(KnownColor color)
{
return FromColor(Color.FromKnownColor(color));
}
+#endif
public static XLColor FromName(String name)
{
diff --git a/ClosedXML/Excel/Style/IXLFontBase.cs b/ClosedXML/Excel/Style/IXLFontBase.cs
index 629cab1..77ac7a1 100644
--- a/ClosedXML/Excel/Style/IXLFontBase.cs
+++ b/ClosedXML/Excel/Style/IXLFontBase.cs
@@ -2,9 +2,7 @@
namespace ClosedXML.Excel
{
-
-
- public interface IXLFontBase
+ public interface IXLFontBase
{
Boolean Bold { get; set; }
Boolean Italic { get; set; }
diff --git a/ClosedXML/Excel/Tables/XLTable.cs b/ClosedXML/Excel/Tables/XLTable.cs
index 97f5c5f..d42ddf1 100644
--- a/ClosedXML/Excel/Tables/XLTable.cs
+++ b/ClosedXML/Excel/Tables/XLTable.cs
@@ -96,7 +96,7 @@
continue;
}
- if (String.IsNullOrWhiteSpace(name))
+ if (XLHelper.IsNullOrWhiteSpace(name))
{
name = GetUniqueName("Column", cellPos + 1, true);
cell.SetValue(name);
@@ -347,7 +347,7 @@
var co = 1;
foreach (var c in firstRow.Cells())
{
- if (String.IsNullOrWhiteSpace(((XLCell)c).InnerText))
+ if (XLHelper.IsNullOrWhiteSpace(((XLCell)c).InnerText))
c.Value = GetUniqueName("Column", co, true);
var header = c.GetString();
@@ -393,7 +393,7 @@
{
f.UpdateUnderlyingCellFormula();
var c = this.TotalsRow().Cell(f.Index + 1);
- if (!String.IsNullOrWhiteSpace(f.TotalsRowLabel))
+ if (!XLHelper.IsNullOrWhiteSpace(f.TotalsRowLabel))
{
c.DataType = XLDataType.Text;
@@ -566,7 +566,7 @@
Int32 co = 1;
foreach (IXLCell c in range.Row(1).Cells())
{
- if (String.IsNullOrWhiteSpace(((XLCell)c).InnerText))
+ if (XLHelper.IsNullOrWhiteSpace(((XLCell)c).InnerText))
c.Value = GetUniqueName("Column", co, true);
_uniqueNames.Add(c.GetString());
co++;
@@ -619,7 +619,7 @@
Int32 co = 1;
foreach (IXLCell c in headersRow.Cells())
{
- if (String.IsNullOrWhiteSpace(((XLCell)c).InnerText))
+ if (XLHelper.IsNullOrWhiteSpace(((XLCell)c).InnerText))
c.Value = GetUniqueName("Column", co, true);
_uniqueNames.Add(c.GetString());
co++;
diff --git a/ClosedXML/Excel/XLWorkbook.cs b/ClosedXML/Excel/XLWorkbook.cs
index b3eb5ad..3a22085 100644
--- a/ClosedXML/Excel/XLWorkbook.cs
+++ b/ClosedXML/Excel/XLWorkbook.cs
@@ -53,60 +53,60 @@
{
return _defaultStyle
?? (_defaultStyle = new XLStyle(null)
+ {
+ Font = new XLFont(null, null)
{
- 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",
- FontFamilyNumbering = XLFontFamilyNumberingValues.Swiss,
- FontCharSet = XLFontCharSet.Default
- },
- 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
- },
- NumberFormat = new XLNumberFormat(null, null) { NumberFormatId = 0 },
- Alignment = new XLAlignment(null)
- {
- Indent = 0,
- Horizontal = XLAlignmentHorizontalValues.General,
- JustifyLastLine = false,
- ReadingOrder = XLAlignmentReadingOrderValues.ContextDependent,
- RelativeIndent = 0,
- ShrinkToFit = false,
- TextRotation = 0,
- Vertical = XLAlignmentVerticalValues.Bottom,
- WrapText = false
- },
- Protection = new XLProtection(null)
- {
- Locked = true,
- Hidden = false
- }
- });
+ Bold = false,
+ Italic = false,
+ Underline = XLFontUnderlineValues.None,
+ Strikethrough = false,
+ VerticalAlignment = XLFontVerticalTextAlignmentValues.Baseline,
+ FontSize = 11,
+ FontColor = XLColor.FromArgb(0, 0, 0),
+ FontName = "Calibri",
+ FontFamilyNumbering = XLFontFamilyNumberingValues.Swiss,
+ FontCharSet = XLFontCharSet.Default
+ },
+ 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
+ },
+ NumberFormat = new XLNumberFormat(null, null) { NumberFormatId = 0 },
+ Alignment = new XLAlignment(null)
+ {
+ Indent = 0,
+ Horizontal = XLAlignmentHorizontalValues.General,
+ JustifyLastLine = false,
+ ReadingOrder = XLAlignmentReadingOrderValues.ContextDependent,
+ RelativeIndent = 0,
+ ShrinkToFit = false,
+ TextRotation = 0,
+ Vertical = XLAlignmentVerticalValues.Bottom,
+ WrapText = false
+ },
+ Protection = new XLProtection(null)
+ {
+ Locked = true,
+ Hidden = false
+ }
+ });
}
}
@@ -513,7 +513,6 @@
{
CopyStream(_originalStream, fileStream);
CreatePackage(fileStream, false, _spreadsheetDocumentType, options);
- fileStream.Close();
}
}
@@ -606,7 +605,6 @@
using (var fileStream = new FileStream(_originalFile, FileMode.Open, FileAccess.Read))
{
CopyStream(fileStream, stream);
- fileStream.Close();
}
CreatePackage(stream, false, _spreadsheetDocumentType, options);
}
diff --git a/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/Excel/XLWorkbook_Load.cs
index 8aa12c5..a322ce2 100644
--- a/ClosedXML/Excel/XLWorkbook_Load.cs
+++ b/ClosedXML/Excel/XLWorkbook_Load.cs
@@ -1,5 +1,3 @@
-#region
-
using ClosedXML.Extensions;
using ClosedXML.Utils;
using DocumentFormat.OpenXml;
@@ -17,19 +15,13 @@
using Op = DocumentFormat.OpenXml.CustomProperties;
using Xdr = DocumentFormat.OpenXml.Drawing.Spreadsheet;
-#endregion
-
namespace ClosedXML.Excel
{
- #region
-
using Ap;
using Drawings;
using Op;
using System.Drawing;
- #endregion
-
public partial class XLWorkbook
{
private readonly Dictionary _colorList = new Dictionary();
@@ -287,7 +279,7 @@
String reference = dTable.Reference.Value;
String tableName = dTable?.Name ?? dTable.DisplayName ?? string.Empty;
- if (String.IsNullOrWhiteSpace(tableName))
+ if (XLHelper.IsNullOrWhiteSpace(tableName))
throw new InvalidDataException("The table name is missing.");
var xlTable = ws.Range(reference).CreateTable(tableName, false) as XLTable;
@@ -362,7 +354,7 @@
xlTable.AutoFilter.Range = xlTable.Worksheet.Range(xlTable.RangeAddress);
}
- #endregion
+ #endregion LoadTables
LoadDrawings(worksheetPart, ws);
@@ -418,7 +410,7 @@
}
}
- #endregion
+ #endregion LoadComments
}
var workbook = dSpreadsheet.WorkbookPart.Workbook;
@@ -489,10 +481,10 @@
{
var pt = ws.PivotTables.AddNew(pivotTableDefinition.Name, target, source) as XLPivotTable;
- if (!String.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.ColumnHeaderCaption ?? String.Empty)))
+ if (!XLHelper.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.ColumnHeaderCaption ?? String.Empty)))
pt.SetColumnHeaderCaption(StringValue.ToString(pivotTableDefinition.ColumnHeaderCaption));
- if (!String.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.RowHeaderCaption ?? String.Empty)))
+ if (!XLHelper.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.RowHeaderCaption ?? String.Empty)))
pt.SetRowHeaderCaption(StringValue.ToString(pivotTableDefinition.RowHeaderCaption));
pt.RelId = worksheetPart.GetIdOfPart(pivotTablePart);
@@ -760,7 +752,7 @@
}
}
- #endregion
+ #endregion Pivot tables
}
private static void LoadFieldOptions(PivotField pf, IXLPivotField pivotField)
@@ -825,10 +817,12 @@
var imagePart = drawingsPart.GetPartById(imgId);
using (var stream = imagePart.GetStream())
+ using (var ms = new MemoryStream())
{
+ stream.CopyTo(ms);
var vsdp = GetPropertiesFromAnchor(anchor);
- var picture = (ws as XLWorksheet).AddPicture(stream, vsdp.Name, Convert.ToInt32(vsdp.Id.Value)) as XLPicture;
+ var picture = (ws as XLWorksheet).AddPicture(ms, vsdp.Name, Convert.ToInt32(vsdp.Id.Value)) as XLPicture;
picture.RelId = imgId;
Xdr.ShapeProperties spPr = anchor.Descendants().First();
@@ -940,7 +934,7 @@
return shape;
}
- #endregion
+ #endregion Comment Helpers
private String GetTableColumnName(string name)
{
@@ -1384,7 +1378,7 @@
{
if (cell.CellFormula.SharedIndex != null)
xlCell.FormulaR1C1 = sharedFormulasR1C1[cell.CellFormula.SharedIndex.Value];
- else if (!String.IsNullOrWhiteSpace(cell.CellFormula.Text))
+ else if (!XLHelper.IsNullOrWhiteSpace(cell.CellFormula.Text))
{
String formula;
if (cell.CellFormula.FormulaType != null && cell.CellFormula.FormulaType == CellFormulaValues.Array)
@@ -1429,7 +1423,7 @@
}
else if (cell.DataType == CellValues.SharedString)
{
- if (cell.CellValue != null && !String.IsNullOrWhiteSpace(cell.CellValue.Text))
+ if (cell.CellValue != null && !XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text))
{
var sharedString = sharedStrings[Int32.Parse(cell.CellValue.Text, XLHelper.NumberStyle, XLHelper.ParseCulture)];
ParseCellValue(sharedString, xlCell);
@@ -1441,7 +1435,7 @@
}
else if (cell.DataType == CellValues.Date)
{
- if (cell.CellValue != null && !String.IsNullOrWhiteSpace(cell.CellValue.Text))
+ if (cell.CellValue != null && !XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text))
xlCell._cellValue = Double.Parse(cell.CellValue.Text, XLHelper.NumberStyle, XLHelper.ParseCulture).ToInvariantString();
xlCell._dataType = XLDataType.DateTime;
}
@@ -1453,7 +1447,7 @@
}
else if (cell.DataType == CellValues.Number)
{
- if (cell.CellValue != null && !String.IsNullOrWhiteSpace(cell.CellValue.Text))
+ if (cell.CellValue != null && !XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text))
xlCell._cellValue = Double.Parse(cell.CellValue.Text, XLHelper.NumberStyle, XLHelper.ParseCulture).ToInvariantString();
if (s == null)
@@ -1471,7 +1465,7 @@
else
{
var numberFormatId = ((CellFormat)(s.CellFormats).ElementAt(styleIndex)).NumberFormatId;
- if (!String.IsNullOrWhiteSpace(cell.CellValue.Text))
+ if (!XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text))
xlCell._cellValue = Double.Parse(cell.CellValue.Text, CultureInfo.InvariantCulture).ToInvariantString();
if (s.NumberingFormats != null &&
@@ -1542,7 +1536,7 @@
LoadFont(pp, xlCell.RichText.Phonetics);
}
- #endregion
+ #endregion Load PhoneticProperties
#region Load Phonetic Runs
@@ -1552,7 +1546,7 @@
(Int32)pr.EndingBaseIndex.Value);
}
- #endregion
+ #endregion Load Phonetic Runs
}
private void LoadNumberFormat(NumberingFormat nfSource, IXLNumberFormat nf)
@@ -1793,7 +1787,7 @@
return XLDataType.Text;
else
{
- if (!String.IsNullOrWhiteSpace(numberFormat.Format))
+ if (!XLHelper.IsNullOrWhiteSpace(numberFormat.Format))
{
var dataType = GetDataTypeFromFormat(numberFormat.Format);
return dataType.HasValue ? dataType.Value : XLDataType.Number;
@@ -1873,7 +1867,7 @@
{
case XLFilterOperator.Equal:
if (isText)
- condition = o => o.ToString().Equals(xlFilter.Value.ToString(), StringComparison.InvariantCultureIgnoreCase);
+ condition = o => o.ToString().Equals(xlFilter.Value.ToString(), StringComparison.OrdinalIgnoreCase);
else
condition = o => (o as IComparable).CompareTo(xlFilter.Value) == 0;
break;
@@ -1884,7 +1878,7 @@
case XLFilterOperator.LessThan: condition = o => (o as IComparable).CompareTo(xlFilter.Value) < 0; break;
case XLFilterOperator.NotEqual:
if (isText)
- condition = o => !o.ToString().Equals(xlFilter.Value.ToString(), StringComparison.InvariantCultureIgnoreCase);
+ condition = o => !o.ToString().Equals(xlFilter.Value.ToString(), StringComparison.OrdinalIgnoreCase);
else
condition = o => (o as IComparable).CompareTo(xlFilter.Value) != 0;
break;
@@ -1927,7 +1921,7 @@
if (isText)
{
xlFilter.Value = filter.Val.Value;
- condition = o => o.ToString().Equals(xlFilter.Value.ToString(), StringComparison.InvariantCultureIgnoreCase);
+ condition = o => o.ToString().Equals(xlFilter.Value.ToString(), StringComparison.OrdinalIgnoreCase);
}
else
{
@@ -2094,7 +2088,7 @@
foreach (DataValidation dvs in dataValidations.Elements())
{
String txt = dvs.SequenceOfReferences.InnerText;
- if (String.IsNullOrWhiteSpace(txt)) continue;
+ if (XLHelper.IsNullOrWhiteSpace(txt)) continue;
foreach (var rangeAddress in txt.Split(' '))
{
using (var range = ws.Range(rangeAddress))
@@ -2150,7 +2144,7 @@
if (conditionalFormat.ConditionalFormatType == XLConditionalFormatType.CellIs && fr.Operator != null)
conditionalFormat.Operator = fr.Operator.Value.ToClosedXml();
- if (fr.Text != null && !String.IsNullOrWhiteSpace(fr.Text))
+ if (fr.Text != null && !XLHelper.IsNullOrWhiteSpace(fr.Text))
conditionalFormat.Values.Add(GetFormula(fr.Text.Value));
if (conditionalFormat.ConditionalFormatType == XLConditionalFormatType.Top10)
@@ -2182,8 +2176,8 @@
conditionalFormat.ShowBarOnly = !dataBar.ShowValue.Value;
var id = fr.Descendants().FirstOrDefault();
- if (id != null && id.Text != null && !String.IsNullOrWhiteSpace(id.Text))
- conditionalFormat.Id = Guid.Parse(id.Text.Substring(1, id.Text.Length - 2));
+ if (id != null && id.Text != null && !XLHelper.IsNullOrWhiteSpace(id.Text))
+ conditionalFormat.Id = new Guid(id.Text.Substring(1, id.Text.Length - 2));
ExtractConditionalFormatValueObjects(conditionalFormat, dataBar);
}
diff --git a/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/Excel/XLWorkbook_Save.cs
index 9e536de..0ba0cdc 100644
--- a/ClosedXML/Excel/XLWorkbook_Save.cs
+++ b/ClosedXML/Excel/XLWorkbook_Save.cs
@@ -235,12 +235,12 @@
// Ensure all RelId's have been added to the context
context.RelIdGenerator.AddValues(workbookPart.Parts.Select(p => p.RelationshipId), RelType.Workbook);
- context.RelIdGenerator.AddValues(WorksheetsInternal.Cast().Where(ws => !String.IsNullOrWhiteSpace(ws.RelId)).Select(ws => ws.RelId), RelType.Workbook);
- context.RelIdGenerator.AddValues(WorksheetsInternal.Cast().Where(ws => !String.IsNullOrWhiteSpace(ws.LegacyDrawingId)).Select(ws => ws.LegacyDrawingId), RelType.Workbook);
+ context.RelIdGenerator.AddValues(WorksheetsInternal.Cast().Where(ws => !XLHelper.IsNullOrWhiteSpace(ws.RelId)).Select(ws => ws.RelId), RelType.Workbook);
+ context.RelIdGenerator.AddValues(WorksheetsInternal.Cast().Where(ws => !XLHelper.IsNullOrWhiteSpace(ws.LegacyDrawingId)).Select(ws => ws.LegacyDrawingId), RelType.Workbook);
context.RelIdGenerator.AddValues(WorksheetsInternal
.Cast()
.SelectMany(ws => ws.Tables.Cast())
- .Where(t => !String.IsNullOrWhiteSpace(t.RelId))
+ .Where(t => !XLHelper.IsNullOrWhiteSpace(t.RelId))
.Select(t => t.RelId), RelType.Workbook);
var extendedFilePropertiesPart = document.ExtendedFilePropertiesPart ??
@@ -292,7 +292,7 @@
var vmlDrawingPart = worksheetPart.VmlDrawingParts.FirstOrDefault();
if (vmlDrawingPart == null)
{
- if (String.IsNullOrWhiteSpace(worksheet.LegacyDrawingId))
+ if (XLHelper.IsNullOrWhiteSpace(worksheet.LegacyDrawingId))
{
worksheet.LegacyDrawingId = context.RelIdGenerator.GetNext(RelType.Workbook);
worksheet.LegacyDrawingIsNew = true;
@@ -358,7 +358,8 @@
// Only delete the VmlDrawingParts for comments.
if (vmlDrawingPart != null)
{
- var xdoc = XDocumentExtensions.Load(vmlDrawingPart.GetStream(FileMode.Open));
+ var vmlStream = vmlDrawingPart.GetStream(FileMode.Open);
+ var xdoc = XDocumentExtensions.Load(vmlStream);
//xdoc.Root.Elements().Where(e => e.Name.LocalName == "shapelayout").Remove();
xdoc.Root.Elements().Where(
e => e.Name.LocalName == "shapetype" && (string)e.Attribute("id") == @"_x0000_t202").Remove();
@@ -388,6 +389,7 @@
legacyParts.ForEach(p => vmlDrawingPartNew.AddPart(p, vmlDrawingPart.GetIdOfPart(p)));
}
+ vmlStream.Close();
worksheetPart.DeletePart(vmlDrawingPart);
if (hasNewPart && rId != worksheetPart.GetIdOfPart(vmlDrawingPartNew))
@@ -508,7 +510,7 @@
if (Properties.Manager != null)
{
- if (!String.IsNullOrWhiteSpace(Properties.Manager))
+ if (!XLHelper.IsNullOrWhiteSpace(Properties.Manager))
{
if (properties.Manager == null)
properties.Manager = new Manager();
@@ -521,7 +523,7 @@
if (Properties.Company == null) return;
- if (!String.IsNullOrWhiteSpace(Properties.Company))
+ if (!XLHelper.IsNullOrWhiteSpace(Properties.Company))
{
if (properties.Company == null)
properties.Company = new Company();
@@ -651,7 +653,7 @@
foreach (var xlSheet in WorksheetsInternal.Cast().OrderBy(w => w.Position))
{
string rId;
- if (xlSheet.SheetId == 0 && String.IsNullOrWhiteSpace(xlSheet.RelId))
+ if (xlSheet.SheetId == 0 && XLHelper.IsNullOrWhiteSpace(xlSheet.RelId))
{
rId = context.RelIdGenerator.GetNext(RelType.Workbook);
@@ -663,7 +665,7 @@
}
else
{
- if (String.IsNullOrWhiteSpace(xlSheet.RelId))
+ if (XLHelper.IsNullOrWhiteSpace(xlSheet.RelId))
{
rId = String.Concat("rId", xlSheet.SheetId);
context.RelIdGenerator.AddValues(new List { rId }, RelType.Workbook);
@@ -810,7 +812,7 @@
if (!nr.Visible)
definedName.Hidden = BooleanValue.FromBoolean(true);
- if (!String.IsNullOrWhiteSpace(nr.Comment))
+ if (!XLHelper.IsNullOrWhiteSpace(nr.Comment))
definedName.Comment = nr.Comment;
definedNames.AppendChild(definedName);
}
@@ -864,7 +866,7 @@
if (!nr.Visible)
definedName.Hidden = BooleanValue.FromBoolean(true);
- if (!String.IsNullOrWhiteSpace(nr.Comment))
+ if (!XLHelper.IsNullOrWhiteSpace(nr.Comment))
definedName.Comment = nr.Comment;
definedNames.AppendChild(definedName);
}
@@ -910,7 +912,7 @@
w.Internals.CellsCollection.GetCells(
c => ((c.DataType == XLDataType.Text && c.ShareString) || c.HasRichText)
&& (c as XLCell).InnerText.Length > 0
- && String.IsNullOrWhiteSpace(c.FormulaA1)
+ && XLHelper.IsNullOrWhiteSpace(c.FormulaA1)
)))
{
c.DataType = XLDataType.Text;
@@ -1061,7 +1063,7 @@
var cellsWithoutFormulas = new HashSet();
foreach (var c in worksheet.Internals.CellsCollection.GetCells())
{
- if (String.IsNullOrWhiteSpace(c.FormulaA1))
+ if (XLHelper.IsNullOrWhiteSpace(c.FormulaA1))
cellsWithoutFormulas.Add(c.Address.ToStringRelative());
else
{
@@ -1803,6 +1805,20 @@
var modified = Properties.Modified == DateTime.MinValue ? DateTime.Now : Properties.Modified;
document.PackageProperties.Created = created;
document.PackageProperties.Modified = modified;
+
+#if true // Workaround: https://github.com/OfficeDev/Open-XML-SDK/issues/235
+
+ if (Properties.LastModifiedBy == null) document.PackageProperties.LastModifiedBy = "";
+ if (Properties.Author == null) document.PackageProperties.Creator = "";
+ if (Properties.Title == null) document.PackageProperties.Title = "";
+ if (Properties.Subject == null) document.PackageProperties.Subject = "";
+ if (Properties.Category == null) document.PackageProperties.Category = "";
+ if (Properties.Keywords == null) document.PackageProperties.Keywords = "";
+ if (Properties.Comments == null) document.PackageProperties.Description = "";
+ if (Properties.Status == null) document.PackageProperties.ContentStatus = "";
+
+#endif
+
document.PackageProperties.LastModifiedBy = Properties.LastModifiedBy;
document.PackageProperties.Creator = Properties.Author;
@@ -1891,7 +1907,7 @@
while (formula.StartsWith("=") && formula.Length > 1)
formula = formula.Substring(1);
- if (!String.IsNullOrWhiteSpace(formula))
+ if (!XLHelper.IsNullOrWhiteSpace(formula))
{
tableColumn.CalculatedColumnFormula = new CalculatedColumnFormula
{
@@ -1912,7 +1928,7 @@
tableColumn.TotalsRowFormula = new TotalsRowFormula(xlField.TotalsRowFormulaA1);
}
- if (!String.IsNullOrWhiteSpace(xlField.TotalsRowLabel))
+ if (!XLHelper.IsNullOrWhiteSpace(xlField.TotalsRowLabel))
tableColumn.TotalsRowLabel = xlField.TotalsRowLabel;
}
tableColumns.AppendChild(tableColumn);
@@ -1975,7 +1991,7 @@
PivotCache pivotCache;
PivotTableCacheDefinitionPart pivotTableCacheDefinitionPart;
- if (!String.IsNullOrWhiteSpace(pt.WorkbookCacheRelId))
+ if (!XLHelper.IsNullOrWhiteSpace(pt.WorkbookCacheRelId))
{
pivotCache = pivotCaches.Cast().Single(pc => pc.Id.Value == pt.WorkbookCacheRelId);
pivotTableCacheDefinitionPart = workbookPart.GetPartById(pt.WorkbookCacheRelId) as PivotTableCacheDefinitionPart;
@@ -1989,18 +2005,18 @@
GeneratePivotTableCacheDefinitionPartContent(pivotTableCacheDefinitionPart, pt, context);
- if (String.IsNullOrWhiteSpace(pt.WorkbookCacheRelId))
+ if (XLHelper.IsNullOrWhiteSpace(pt.WorkbookCacheRelId))
pivotCaches.AppendChild(pivotCache);
PivotTablePart pivotTablePart;
- if (String.IsNullOrWhiteSpace(pt.RelId))
+ if (XLHelper.IsNullOrWhiteSpace(pt.RelId))
pivotTablePart = worksheetPart.AddNewPart(context.RelIdGenerator.GetNext(RelType.Workbook));
else
pivotTablePart = worksheetPart.GetPartById(pt.RelId) as PivotTablePart;
GeneratePivotTablePartContent(pivotTablePart, pt, pivotCache.CacheId, context);
- if (String.IsNullOrWhiteSpace(pt.RelId))
+ if (XLHelper.IsNullOrWhiteSpace(pt.RelId))
pivotTablePart.AddPart(pivotTableCacheDefinitionPart, context.RelIdGenerator.GetNext(RelType.Workbook));
}
}
@@ -2124,8 +2140,8 @@
ptfi.DataType = XLDataType.DateTime;
ptfi.MixedDataType = false;
ptfi.DistinctValues = fieldValueCells
- .Select(cell => cell.GetDateTime())
- .Distinct()
+ .Select(cell => cell.GetDateTime())
+ .Distinct()
.Cast