public XLWorksheet(String sheetName, XLWorkbook workbook) : base(new XLRangeAddress( new XLAddress(null, XLHelper.MinRowNumber, XLHelper.MinColumnNumber, false, false), new XLAddress(null, XLHelper.MaxRowNumber, XLHelper.MaxColumnNumber, false, false))) { EventTrackingEnabled = workbook.EventTracking == XLEventTracking.Enabled; RangeShiftedRows = new XLReentrantEnumerableSet<XLCallbackAction>(); RangeShiftedColumns = new XLReentrantEnumerableSet<XLCallbackAction>(); RangeAddress.Worksheet = this; RangeAddress.FirstAddress.Worksheet = this; RangeAddress.LastAddress.Worksheet = this; NamedRanges = new XLNamedRanges(workbook); SheetView = new XLSheetView(); Tables = new XLTables(); Hyperlinks = new XLHyperlinks(); DataValidations = new XLDataValidations(); PivotTables = new XLPivotTables(); Protection = new XLSheetProtection(); AutoFilter = new XLAutoFilter(); ConditionalFormats = new XLConditionalFormats(); Workbook = workbook; SetStyle(workbook.Style); Internals = new XLWorksheetInternals(new XLCellsCollection(), new XLColumnsCollection(), new XLRowsCollection(), new XLRanges()); PageSetup = new XLPageSetup((XLPageSetup)workbook.PageOptions, this); Outline = new XLOutline(workbook.Outline); _columnWidth = workbook.ColumnWidth; _rowHeight = workbook.RowHeight; RowHeightChanged = Math.Abs(workbook.RowHeight - XLWorkbook.DefaultRowHeight) > XLHelper.Epsilon; Name = sheetName; SubscribeToShiftedRows((range, rowsShifted) => this.WorksheetRangeShiftedRows(range, rowsShifted)); SubscribeToShiftedColumns((range, columnsShifted) => this.WorksheetRangeShiftedColumns(range, columnsShifted)); Charts = new XLCharts(); ShowFormulas = workbook.ShowFormulas; ShowGridLines = workbook.ShowGridLines; ShowOutlineSymbols = workbook.ShowOutlineSymbols; ShowRowColHeaders = workbook.ShowRowColHeaders; ShowRuler = workbook.ShowRuler; ShowWhiteSpace = workbook.ShowWhiteSpace; ShowZeros = workbook.ShowZeros; RightToLeft = workbook.RightToLeft; TabColor = XLColor.NoColor; SelectedRanges = new XLRanges(); Author = workbook.Author; Pictures = new XLPictures(); }
internal void BreakConditionalFormatsIntoCells(List<IXLAddress> addresses) { var newConditionalFormats = new XLConditionalFormats(); SuspendEvents(); foreach (var conditionalFormat in ConditionalFormats) { foreach (XLCell cell in conditionalFormat.Range.Cells(c=>!addresses.Contains(c.Address))) { var row = cell.Address.RowNumber; var column = cell.Address.ColumnLetter; var newConditionalFormat = new XLConditionalFormat(cell.AsRange(), true); newConditionalFormat.CopyFrom(conditionalFormat); newConditionalFormat.Values.Values.Where(f => f.IsFormula) .ForEach(f => f._value = XLHelper.ReplaceRelative(f.Value, row, column)); newConditionalFormats.Add(newConditionalFormat); } conditionalFormat.Range.Dispose(); } ResumeEvents(); ConditionalFormats = newConditionalFormats; }