diff --git a/ClosedXML/Attributes/XLColumnAttribute.cs b/ClosedXML/Attributes/XLColumnAttribute.cs index a86a1be..67ab26f 100644 --- a/ClosedXML/Attributes/XLColumnAttribute.cs +++ b/ClosedXML/Attributes/XLColumnAttribute.cs @@ -22,7 +22,7 @@ { var attribute = GetXLColumnAttribute(mi); if (attribute == null) return null; - return XLHelper.IsNullOrWhiteSpace(attribute.Header) ? null : attribute.Header; + return String.IsNullOrWhiteSpace(attribute.Header) ? null : attribute.Header; } internal static Int32 GetOrder(MemberInfo mi) diff --git a/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs b/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs index 86155cb..da2f83b 100644 --- a/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs +++ b/ClosedXML/Excel/CalcEngine/XLCalcEngine.cs @@ -101,7 +101,7 @@ { _evaluating = true; var f = cell.FormulaA1; - if (XLHelper.IsNullOrWhiteSpace(f)) + if (String.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 1debabd..e11eaee 100644 --- a/ClosedXML/Excel/Cells/XLCell.cs +++ b/ClosedXML/Excel/Cells/XLCell.cs @@ -366,7 +366,7 @@ get { var fA1 = FormulaA1; - if (!XLHelper.IsNullOrWhiteSpace(fA1)) + if (!String.IsNullOrWhiteSpace(fA1)) { if (IsEvaluating) throw new InvalidOperationException("Circular Reference"); @@ -524,7 +524,7 @@ if (!hasTitles) { var fieldName = XLColumnAttribute.GetHeader(itemType); - if (XLHelper.IsNullOrWhiteSpace(fieldName)) + if (String.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 XLHelper.IsNullOrWhiteSpace(column.Caption) + select String.IsNullOrWhiteSpace(column.Caption) ? column.ColumnName : column.Caption) { @@ -655,7 +655,7 @@ if (!(mi is IEnumerable)) { var fieldName = XLColumnAttribute.GetHeader(mi); - if (XLHelper.IsNullOrWhiteSpace(fieldName)) + if (String.IsNullOrWhiteSpace(fieldName)) fieldName = mi.Name; _worksheet.SetValue(fieldName, fRo, co); @@ -1083,9 +1083,9 @@ { get { - if (XLHelper.IsNullOrWhiteSpace(_formulaA1)) + if (String.IsNullOrWhiteSpace(_formulaA1)) { - if (!XLHelper.IsNullOrWhiteSpace(_formulaR1C1)) + if (!String.IsNullOrWhiteSpace(_formulaR1C1)) { _formulaA1 = GetFormulaA1(_formulaR1C1); return FormulaA1; @@ -1105,7 +1105,7 @@ set { - _formulaA1 = XLHelper.IsNullOrWhiteSpace(value) ? null : value; + _formulaA1 = String.IsNullOrWhiteSpace(value) ? null : value; _formulaR1C1 = null; } @@ -1115,7 +1115,7 @@ { get { - if (XLHelper.IsNullOrWhiteSpace(_formulaR1C1)) + if (String.IsNullOrWhiteSpace(_formulaR1C1)) _formulaR1C1 = GetFormulaR1C1(FormulaA1); return _formulaR1C1; @@ -1123,7 +1123,7 @@ set { - _formulaR1C1 = XLHelper.IsNullOrWhiteSpace(value) ? null : value; + _formulaR1C1 = String.IsNullOrWhiteSpace(value) ? null : value; _formulaA1 = null; } @@ -1763,7 +1763,7 @@ { var style = GetStyleForRead(); return _dataType == XLDataType.Number - && XLHelper.IsNullOrWhiteSpace(style.NumberFormat.Format) + && String.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 (XLHelper.IsNullOrWhiteSpace(style.NumberFormat.Format)) + if (String.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 (XLHelper.IsNullOrWhiteSpace(strValue)) + if (String.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 (XLHelper.IsNullOrWhiteSpace(formulaA1)) return String.Empty; + if (String.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 (XLHelper.IsNullOrWhiteSpace(formulaA1)) return String.Empty; + if (String.IsNullOrWhiteSpace(formulaA1)) return String.Empty; var value = formulaA1; @@ -2739,7 +2739,7 @@ #endregion XLCell Right - public Boolean HasFormula { get { return !XLHelper.IsNullOrWhiteSpace(FormulaA1); } } + public Boolean HasFormula { get { return !String.IsNullOrWhiteSpace(FormulaA1); } } public Boolean HasArrayFormula { get { return FormulaA1.StartsWith("{"); } } diff --git a/ClosedXML/Excel/DataValidation/XLDataValidation.cs b/ClosedXML/Excel/DataValidation/XLDataValidation.cs index 8c189db..3ee5896 100644 --- a/ClosedXML/Excel/DataValidation/XLDataValidation.cs +++ b/ClosedXML/Excel/DataValidation/XLDataValidation.cs @@ -48,9 +48,9 @@ return AllowedValues != XLAllowedValues.AnyValue || (ShowInputMessage && - (!XLHelper.IsNullOrWhiteSpace(InputTitle) || !XLHelper.IsNullOrWhiteSpace(InputMessage))) + (!String.IsNullOrWhiteSpace(InputTitle) || !String.IsNullOrWhiteSpace(InputMessage))) ||(ShowErrorMessage && - (!XLHelper.IsNullOrWhiteSpace(ErrorTitle) || !XLHelper.IsNullOrWhiteSpace(ErrorMessage))); + (!String.IsNullOrWhiteSpace(ErrorTitle) || !String.IsNullOrWhiteSpace(ErrorMessage))); } diff --git a/ClosedXML/Excel/Misc/XLFormula.cs b/ClosedXML/Excel/Misc/XLFormula.cs index 34cea84..8027667 100644 --- a/ClosedXML/Excel/Misc/XLFormula.cs +++ b/ClosedXML/Excel/Misc/XLFormula.cs @@ -44,7 +44,7 @@ else { _value = value.Trim(); - IsFormula = !XLHelper.IsNullOrWhiteSpace(_value) && _value.TrimStart()[0] == '=' ; + IsFormula = !String.IsNullOrWhiteSpace(_value) && _value.TrimStart()[0] == '=' ; if (IsFormula) _value = _value.Substring(1); } diff --git a/ClosedXML/Excel/Ranges/XLRangeBase.cs b/ClosedXML/Excel/Ranges/XLRangeBase.cs index 84948c3..5c9e661 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 => !XLHelper.IsNullOrWhiteSpace(c.FormulaA1))) + foreach (XLCell cell in ws.Internals.CellsCollection.GetCells(c => !String.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 => !XLHelper.IsNullOrWhiteSpace(c.FormulaA1))) + foreach (XLCell cell in ws.Internals.CellsCollection.GetCells(c => !String.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 => !XLHelper.IsNullOrWhiteSpace(c.FormulaA1)))) + c => !String.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 (XLHelper.IsNullOrWhiteSpace(columnsToSortBy)) + if (String.IsNullOrWhiteSpace(columnsToSortBy)) { columnsToSortBy = DefaultSortString(); } diff --git a/ClosedXML/Excel/Tables/XLTable.cs b/ClosedXML/Excel/Tables/XLTable.cs index b5677e9..528eb6d 100644 --- a/ClosedXML/Excel/Tables/XLTable.cs +++ b/ClosedXML/Excel/Tables/XLTable.cs @@ -96,7 +96,7 @@ continue; } - if (XLHelper.IsNullOrWhiteSpace(name)) + if (String.IsNullOrWhiteSpace(name)) { name = GetUniqueName("Column", cellPos + 1, true); cell.SetValue(name); @@ -224,7 +224,7 @@ // Validation rules for table names var oldname = _name ?? string.Empty; - if (XLHelper.IsNullOrWhiteSpace(value)) + if (String.IsNullOrWhiteSpace(value)) throw new ArgumentException($"The table name '{value}' is invalid"); // Table names are case insensitive @@ -247,7 +247,7 @@ if (_fieldNames?.Any() ?? false) this.Fields.ForEach(f => (f as XLTableField).UpdateTableFieldTotalsRowFormula()); - if (!XLHelper.IsNullOrWhiteSpace(oldname)) + if (!String.IsNullOrWhiteSpace(oldname)) { Worksheet.Tables.Add(this); Worksheet.Tables.Remove(oldname); @@ -375,7 +375,7 @@ var co = 1; foreach (var c in firstRow.Cells()) { - if (XLHelper.IsNullOrWhiteSpace(((XLCell)c).InnerText)) + if (String.IsNullOrWhiteSpace(((XLCell)c).InnerText)) c.Value = GetUniqueName("Column", co, true); var header = c.GetString(); @@ -421,7 +421,7 @@ { f.UpdateTableFieldTotalsRowFormula(); var c = this.TotalsRow().Cell(f.Index + 1); - if (!XLHelper.IsNullOrWhiteSpace(f.TotalsRowLabel)) + if (!String.IsNullOrWhiteSpace(f.TotalsRowLabel)) { c.DataType = XLDataType.Text; @@ -594,7 +594,7 @@ Int32 co = 1; foreach (IXLCell c in range.Row(1).Cells()) { - if (XLHelper.IsNullOrWhiteSpace(((XLCell)c).InnerText)) + if (String.IsNullOrWhiteSpace(((XLCell)c).InnerText)) c.Value = GetUniqueName("Column", co, true); _uniqueNames.Add(c.GetString()); co++; @@ -647,7 +647,7 @@ Int32 co = 1; foreach (IXLCell c in headersRow.Cells()) { - if (XLHelper.IsNullOrWhiteSpace(((XLCell)c).InnerText)) + if (String.IsNullOrWhiteSpace(((XLCell)c).InnerText)) c.Value = GetUniqueName("Column", co, true); _uniqueNames.Add(c.GetString()); co++; diff --git a/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/Excel/XLWorkbook_Load.cs index a322ce2..7aa868f 100644 --- a/ClosedXML/Excel/XLWorkbook_Load.cs +++ b/ClosedXML/Excel/XLWorkbook_Load.cs @@ -279,7 +279,7 @@ String reference = dTable.Reference.Value; String tableName = dTable?.Name ?? dTable.DisplayName ?? string.Empty; - if (XLHelper.IsNullOrWhiteSpace(tableName)) + if (String.IsNullOrWhiteSpace(tableName)) throw new InvalidDataException("The table name is missing."); var xlTable = ws.Range(reference).CreateTable(tableName, false) as XLTable; @@ -481,10 +481,10 @@ { var pt = ws.PivotTables.AddNew(pivotTableDefinition.Name, target, source) as XLPivotTable; - if (!XLHelper.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.ColumnHeaderCaption ?? String.Empty))) + if (!String.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.ColumnHeaderCaption ?? String.Empty))) pt.SetColumnHeaderCaption(StringValue.ToString(pivotTableDefinition.ColumnHeaderCaption)); - if (!XLHelper.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.RowHeaderCaption ?? String.Empty))) + if (!String.IsNullOrWhiteSpace(StringValue.ToString(pivotTableDefinition?.RowHeaderCaption ?? String.Empty))) pt.SetRowHeaderCaption(StringValue.ToString(pivotTableDefinition.RowHeaderCaption)); pt.RelId = worksheetPart.GetIdOfPart(pivotTablePart); @@ -1378,7 +1378,7 @@ { if (cell.CellFormula.SharedIndex != null) xlCell.FormulaR1C1 = sharedFormulasR1C1[cell.CellFormula.SharedIndex.Value]; - else if (!XLHelper.IsNullOrWhiteSpace(cell.CellFormula.Text)) + else if (!String.IsNullOrWhiteSpace(cell.CellFormula.Text)) { String formula; if (cell.CellFormula.FormulaType != null && cell.CellFormula.FormulaType == CellFormulaValues.Array) @@ -1423,7 +1423,7 @@ } else if (cell.DataType == CellValues.SharedString) { - if (cell.CellValue != null && !XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text)) + if (cell.CellValue != null && !String.IsNullOrWhiteSpace(cell.CellValue.Text)) { var sharedString = sharedStrings[Int32.Parse(cell.CellValue.Text, XLHelper.NumberStyle, XLHelper.ParseCulture)]; ParseCellValue(sharedString, xlCell); @@ -1435,7 +1435,7 @@ } else if (cell.DataType == CellValues.Date) { - if (cell.CellValue != null && !XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text)) + if (cell.CellValue != null && !String.IsNullOrWhiteSpace(cell.CellValue.Text)) xlCell._cellValue = Double.Parse(cell.CellValue.Text, XLHelper.NumberStyle, XLHelper.ParseCulture).ToInvariantString(); xlCell._dataType = XLDataType.DateTime; } @@ -1447,7 +1447,7 @@ } else if (cell.DataType == CellValues.Number) { - if (cell.CellValue != null && !XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text)) + if (cell.CellValue != null && !String.IsNullOrWhiteSpace(cell.CellValue.Text)) xlCell._cellValue = Double.Parse(cell.CellValue.Text, XLHelper.NumberStyle, XLHelper.ParseCulture).ToInvariantString(); if (s == null) @@ -1465,7 +1465,7 @@ else { var numberFormatId = ((CellFormat)(s.CellFormats).ElementAt(styleIndex)).NumberFormatId; - if (!XLHelper.IsNullOrWhiteSpace(cell.CellValue.Text)) + if (!String.IsNullOrWhiteSpace(cell.CellValue.Text)) xlCell._cellValue = Double.Parse(cell.CellValue.Text, CultureInfo.InvariantCulture).ToInvariantString(); if (s.NumberingFormats != null && @@ -1787,7 +1787,7 @@ return XLDataType.Text; else { - if (!XLHelper.IsNullOrWhiteSpace(numberFormat.Format)) + if (!String.IsNullOrWhiteSpace(numberFormat.Format)) { var dataType = GetDataTypeFromFormat(numberFormat.Format); return dataType.HasValue ? dataType.Value : XLDataType.Number; @@ -2088,7 +2088,7 @@ foreach (DataValidation dvs in dataValidations.Elements()) { String txt = dvs.SequenceOfReferences.InnerText; - if (XLHelper.IsNullOrWhiteSpace(txt)) continue; + if (String.IsNullOrWhiteSpace(txt)) continue; foreach (var rangeAddress in txt.Split(' ')) { using (var range = ws.Range(rangeAddress)) @@ -2144,7 +2144,7 @@ if (conditionalFormat.ConditionalFormatType == XLConditionalFormatType.CellIs && fr.Operator != null) conditionalFormat.Operator = fr.Operator.Value.ToClosedXml(); - if (fr.Text != null && !XLHelper.IsNullOrWhiteSpace(fr.Text)) + if (fr.Text != null && !String.IsNullOrWhiteSpace(fr.Text)) conditionalFormat.Values.Add(GetFormula(fr.Text.Value)); if (conditionalFormat.ConditionalFormatType == XLConditionalFormatType.Top10) @@ -2176,7 +2176,7 @@ conditionalFormat.ShowBarOnly = !dataBar.ShowValue.Value; var id = fr.Descendants().FirstOrDefault(); - if (id != null && id.Text != null && !XLHelper.IsNullOrWhiteSpace(id.Text)) + if (id != null && id.Text != null && !String.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 47d6668..6bc0f59 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 => !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().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() .SelectMany(ws => ws.Tables.Cast()) - .Where(t => !XLHelper.IsNullOrWhiteSpace(t.RelId)) + .Where(t => !String.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 (XLHelper.IsNullOrWhiteSpace(worksheet.LegacyDrawingId)) + if (String.IsNullOrWhiteSpace(worksheet.LegacyDrawingId)) { worksheet.LegacyDrawingId = context.RelIdGenerator.GetNext(RelType.Workbook); worksheet.LegacyDrawingIsNew = true; @@ -510,7 +510,7 @@ if (Properties.Manager != null) { - if (!XLHelper.IsNullOrWhiteSpace(Properties.Manager)) + if (!String.IsNullOrWhiteSpace(Properties.Manager)) { if (properties.Manager == null) properties.Manager = new Manager(); @@ -523,7 +523,7 @@ if (Properties.Company == null) return; - if (!XLHelper.IsNullOrWhiteSpace(Properties.Company)) + if (!String.IsNullOrWhiteSpace(Properties.Company)) { if (properties.Company == null) properties.Company = new Company(); @@ -653,7 +653,7 @@ foreach (var xlSheet in WorksheetsInternal.Cast().OrderBy(w => w.Position)) { string rId; - if (xlSheet.SheetId == 0 && XLHelper.IsNullOrWhiteSpace(xlSheet.RelId)) + if (xlSheet.SheetId == 0 && String.IsNullOrWhiteSpace(xlSheet.RelId)) { rId = context.RelIdGenerator.GetNext(RelType.Workbook); @@ -665,7 +665,7 @@ } else { - if (XLHelper.IsNullOrWhiteSpace(xlSheet.RelId)) + if (String.IsNullOrWhiteSpace(xlSheet.RelId)) { rId = String.Concat("rId", xlSheet.SheetId); context.RelIdGenerator.AddValues(new List { rId }, RelType.Workbook); @@ -812,7 +812,7 @@ if (!nr.Visible) definedName.Hidden = BooleanValue.FromBoolean(true); - if (!XLHelper.IsNullOrWhiteSpace(nr.Comment)) + if (!String.IsNullOrWhiteSpace(nr.Comment)) definedName.Comment = nr.Comment; definedNames.AppendChild(definedName); } @@ -866,7 +866,7 @@ if (!nr.Visible) definedName.Hidden = BooleanValue.FromBoolean(true); - if (!XLHelper.IsNullOrWhiteSpace(nr.Comment)) + if (!String.IsNullOrWhiteSpace(nr.Comment)) definedName.Comment = nr.Comment; definedNames.AppendChild(definedName); } @@ -912,7 +912,7 @@ w.Internals.CellsCollection.GetCells( c => ((c.DataType == XLDataType.Text && c.ShareString) || c.HasRichText) && (c as XLCell).InnerText.Length > 0 - && XLHelper.IsNullOrWhiteSpace(c.FormulaA1) + && String.IsNullOrWhiteSpace(c.FormulaA1) ))) { c.DataType = XLDataType.Text; @@ -1063,7 +1063,7 @@ var cellsWithoutFormulas = new HashSet(); foreach (var c in worksheet.Internals.CellsCollection.GetCells()) { - if (XLHelper.IsNullOrWhiteSpace(c.FormulaA1)) + if (String.IsNullOrWhiteSpace(c.FormulaA1)) cellsWithoutFormulas.Add(c.Address.ToStringRelative()); else { @@ -1907,7 +1907,7 @@ while (formula.StartsWith("=") && formula.Length > 1) formula = formula.Substring(1); - if (!XLHelper.IsNullOrWhiteSpace(formula)) + if (!String.IsNullOrWhiteSpace(formula)) { tableColumn.CalculatedColumnFormula = new CalculatedColumnFormula { @@ -1928,7 +1928,7 @@ tableColumn.TotalsRowFormula = new TotalsRowFormula(xlField.TotalsRowFormulaA1); } - if (!XLHelper.IsNullOrWhiteSpace(xlField.TotalsRowLabel)) + if (!String.IsNullOrWhiteSpace(xlField.TotalsRowLabel)) tableColumn.TotalsRowLabel = xlField.TotalsRowLabel; } tableColumns.AppendChild(tableColumn); @@ -1991,7 +1991,7 @@ PivotCache pivotCache; PivotTableCacheDefinitionPart pivotTableCacheDefinitionPart; - if (!XLHelper.IsNullOrWhiteSpace(pt.WorkbookCacheRelId)) + if (!String.IsNullOrWhiteSpace(pt.WorkbookCacheRelId)) { pivotCache = pivotCaches.Cast().Single(pc => pc.Id.Value == pt.WorkbookCacheRelId); pivotTableCacheDefinitionPart = workbookPart.GetPartById(pt.WorkbookCacheRelId) as PivotTableCacheDefinitionPart; @@ -2005,18 +2005,18 @@ GeneratePivotTableCacheDefinitionPartContent(pivotTableCacheDefinitionPart, pt, context); - if (XLHelper.IsNullOrWhiteSpace(pt.WorkbookCacheRelId)) + if (String.IsNullOrWhiteSpace(pt.WorkbookCacheRelId)) pivotCaches.AppendChild(pivotCache); PivotTablePart pivotTablePart; - if (XLHelper.IsNullOrWhiteSpace(pt.RelId)) + if (String.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 (XLHelper.IsNullOrWhiteSpace(pt.RelId)) + if (String.IsNullOrWhiteSpace(pt.RelId)) pivotTablePart.AddPart(pivotTableCacheDefinitionPart, context.RelIdGenerator.GetNext(RelType.Workbook)); } } @@ -2881,7 +2881,7 @@ StrokeWeight = String.Concat(c.Comment.Style.ColorsAndLines.LineWeight.ToInvariantString(), "pt"), InsetMode = c.Comment.Style.Margins.Automatic ? InsetMarginValues.Auto : InsetMarginValues.Custom }; - if (!XLHelper.IsNullOrWhiteSpace(c.Comment.Style.Web.AlternateText)) + if (!String.IsNullOrWhiteSpace(c.Comment.Style.Web.AlternateText)) shape.Alternate = c.Comment.Style.Web.AlternateText; return shape; @@ -3479,7 +3479,7 @@ if (diffFont?.HasChildren ?? false) differentialFormat.Append(diffFont); - if (!XLHelper.IsNullOrWhiteSpace(cf.Style.NumberFormat.Format)) + if (!String.IsNullOrWhiteSpace(cf.Style.NumberFormat.Format)) { var numberFormat = new NumberingFormat { @@ -3511,7 +3511,7 @@ if (diffFont?.HasChildren ?? false) differentialFormat.Append(diffFont); - if (!XLHelper.IsNullOrWhiteSpace(style.NumberFormat.Format) || style.NumberFormat.NumberFormatId != 0) + if (!String.IsNullOrWhiteSpace(style.NumberFormat.Format) || style.NumberFormat.NumberFormatId != 0) { var numberFormat = new NumberingFormat(); @@ -4260,7 +4260,7 @@ { var newXLNumberFormat = new XLNumberFormat(); - if (nf.FormatCode != null && !XLHelper.IsNullOrWhiteSpace(nf.FormatCode.Value)) + if (nf.FormatCode != null && !String.IsNullOrWhiteSpace(nf.FormatCode.Value)) newXLNumberFormat.Format = nf.FormatCode.Value; else if (nf.NumberFormatId != null) newXLNumberFormat.NumberFormatId = (Int32)nf.NumberFormatId.Value; @@ -4856,7 +4856,7 @@ var table = xlWorksheet.Tables.First(t => t.AsRange().Contains(xlCell)); field = table.Fields.First(f => f.Column.ColumnNumber() == xlCell.Address.ColumnNumber) as XLTableField; - if (!XLHelper.IsNullOrWhiteSpace(field.TotalsRowLabel)) + if (!String.IsNullOrWhiteSpace(field.TotalsRowLabel)) { cell.DataType = XLWorkbook.CvSharedString; } @@ -4939,7 +4939,7 @@ var protection = xlWorksheet.Protection; sheetProtection.Sheet = protection.Protected; - if (!XLHelper.IsNullOrWhiteSpace(protection.PasswordHash)) + if (!String.IsNullOrWhiteSpace(protection.PasswordHash)) sheetProtection.Password = protection.PasswordHash; sheetProtection.FormatCells = OpenXmlHelper.GetBooleanValue(!protection.FormatCells, true); sheetProtection.FormatColumns = OpenXmlHelper.GetBooleanValue(!protection.FormatColumns, true); @@ -5194,7 +5194,7 @@ Display = hl.Cell.GetFormattedString() }; } - if (!XLHelper.IsNullOrWhiteSpace(hl.Tooltip)) + if (!String.IsNullOrWhiteSpace(hl.Tooltip)) hyperlink.Tooltip = hl.Tooltip; hyperlinks.AppendChild(hyperlink); } @@ -5521,7 +5521,7 @@ { if (field != null) { - if (!XLHelper.IsNullOrWhiteSpace(field.TotalsRowLabel)) + if (!String.IsNullOrWhiteSpace(field.TotalsRowLabel)) { var cellValue = new CellValue(); cellValue.Text = xlCell.SharedStringId.ToString(); @@ -5587,7 +5587,7 @@ } else if (dataType == XLDataType.DateTime || dataType == XLDataType.Number) { - if (!XLHelper.IsNullOrWhiteSpace(xlCell.InnerText)) + if (!String.IsNullOrWhiteSpace(xlCell.InnerText)) { var cellValue = new CellValue(); var d = Double.Parse(xlCell.InnerText, XLHelper.NumberStyle, XLHelper.ParseCulture); diff --git a/ClosedXML/Excel/XLWorksheet.cs b/ClosedXML/Excel/XLWorksheet.cs index eaf1280..839b5d8 100644 --- a/ClosedXML/Excel/XLWorksheet.cs +++ b/ClosedXML/Excel/XLWorksheet.cs @@ -174,7 +174,7 @@ throw new ArgumentException("Worksheet names cannot contain any of the following characters: " + InvalidNameChars); - if (XLHelper.IsNullOrWhiteSpace(value)) + if (String.IsNullOrWhiteSpace(value)) throw new ArgumentException("Worksheet names cannot be empty"); if (value.Length > 31) diff --git a/ClosedXML/Excel/XLWorksheets.cs b/ClosedXML/Excel/XLWorksheets.cs index 01aa54b..94cace4 100644 --- a/ClosedXML/Excel/XLWorksheets.cs +++ b/ClosedXML/Excel/XLWorksheets.cs @@ -130,7 +130,7 @@ "Can't delete the worksheet because there are multiple worksheets associated with that index."); var ws = _worksheets.Values.Single(w => w.Position == position); - if (!XLHelper.IsNullOrWhiteSpace(ws.RelId) && !Deleted.Contains(ws.RelId)) + if (!String.IsNullOrWhiteSpace(ws.RelId) && !Deleted.Contains(ws.RelId)) Deleted.Add(ws.RelId); _worksheets.RemoveAll(w => w.Position == position); @@ -171,7 +171,7 @@ public void Rename(String oldSheetName, String newSheetName) { - if (XLHelper.IsNullOrWhiteSpace(oldSheetName) || !_worksheets.ContainsKey(oldSheetName.ToLowerInvariant())) return; + if (String.IsNullOrWhiteSpace(oldSheetName) || !_worksheets.ContainsKey(oldSheetName.ToLowerInvariant())) return; if (!oldSheetName.Equals(newSheetName, StringComparison.OrdinalIgnoreCase) && _worksheets.Any(ws1 => ws1.Key.Equals(newSheetName, StringComparison.OrdinalIgnoreCase))) diff --git a/ClosedXML/Extensions.cs b/ClosedXML/Extensions.cs index 88c1f8d..5d14a91 100644 --- a/ClosedXML/Extensions.cs +++ b/ClosedXML/Extensions.cs @@ -215,7 +215,7 @@ { public static Double GetWidth(this IXLFontBase fontBase, String text, Dictionary fontCache) { - if (XLHelper.IsNullOrWhiteSpace(text)) + if (String.IsNullOrWhiteSpace(text)) return 0; var font = GetCachedFont(fontBase, fontCache); diff --git a/ClosedXML/XLHelper.cs b/ClosedXML/XLHelper.cs index 6f25f72..0796264 100644 --- a/ClosedXML/XLHelper.cs +++ b/ClosedXML/XLHelper.cs @@ -117,7 +117,7 @@ public static bool IsValidColumn(string column) { var length = column.Length; - if (XLHelper.IsNullOrWhiteSpace(column) || length > 3) + if (String.IsNullOrWhiteSpace(column) || length > 3) return false; var theColumn = column.ToUpper(); @@ -153,7 +153,7 @@ public static bool IsValidA1Address(string address) { - if (XLHelper.IsNullOrWhiteSpace(address)) + if (String.IsNullOrWhiteSpace(address)) return false; address = address.Replace("$", ""); @@ -226,7 +226,8 @@ return rows; } - +#if false +// Not using this anymore, but keeping it around for in case we bring back .NET3.5 support. public static bool IsNullOrWhiteSpace(string value) { #if _NET35_ @@ -236,6 +237,8 @@ return String.IsNullOrWhiteSpace(value); #endif } +#endif + private static readonly Regex A1RegexRelative = new Regex( @"(?<=\W)(?\$?[a-zA-Z]{1,3}\$?\d{1,7})(?=\W)" // A1 + @"|(?<=\W)(?\$?\d{1,7}:\$?\d{1,7})(?=\W)" // 1:1