private static void ApplyTableFormat( this Range range, TableFormat tableFormat) { if (tableFormat == null) { return; } var implementedProperties = new[] { nameof(TableFormat.CellsFormat), }; tableFormat.ThrowOnNotImplementedProperty(implementedProperties); range.ApplyCellFormat(tableFormat.CellsFormat); }
private static void ApplyRowFormat( this Range range, RowFormat format) { if (format == null) { return; } var implementedProperties = new[] { nameof(RowFormat.CellsFormat), nameof(RowFormat.HeightInPixels), nameof(RowFormat.Options), }; format.ThrowOnNotImplementedProperty(implementedProperties); range.ApplyCellFormat(format.CellsFormat); range.SetPerRowHeightInPixels(format.HeightInPixels); range.ApplyRowFormatOptions(format.Options); }
private static void ApplyColumnFormat( this Range wholeColumnRange, Range dataCellsRange, Range lastHeaderCellToLastNonSummaryDataCellRange, ColumnFormat columnFormat) { if (columnFormat == null) { return; } var implementedProperties = new[] { nameof(ColumnFormat.CellsFormat), nameof(ColumnFormat.WidthInPixels), nameof(ColumnFormat.AutofitColumnWidth), nameof(ColumnFormat.Options), }; columnFormat.ThrowOnNotImplementedProperty(implementedProperties); dataCellsRange.ApplyCellFormat(columnFormat.CellsFormat); wholeColumnRange.SetPerColumnWidthInPixels(columnFormat.WidthInPixels); // Apply options before auto-fitting, in case options change width of column (e.g. filtering) wholeColumnRange.ApplyColumnFormatOptions(lastHeaderCellToLastNonSummaryDataCellRange, columnFormat.Options); if (columnFormat.AutofitColumnWidth == true) { wholeColumnRange.Worksheet.AutoFitColumn( lastHeaderCellToLastNonSummaryDataCellRange.FirstColumn, lastHeaderCellToLastNonSummaryDataCellRange.FirstRow, lastHeaderCellToLastNonSummaryDataCellRange.FirstRow + lastHeaderCellToLastNonSummaryDataCellRange.RowCount - 1); } }