private static void AddRowBase( this CellCursor cursor, RowBase rowBase, ReportToWorkbookProjectionContext context, PassKind passKind) { if (passKind == PassKind.Formatting) { cursor.CanvassedRowRange.ApplyRowFormat(rowBase.Format); } for (var x = 0; x < rowBase.Cells.Count; x++) { if (x > 0) { cursor.MoveRight(rowBase.Cells[x - 1].ColumnsSpanned ?? 1); } if (passKind == PassKind.Formatting) { cursor.CanvassedRowRange.ApplyRowFormat(rowBase.Format); } cursor.AddCell(rowBase.Cells[x], context, passKind); } }
private static void AddTreeTable( this CellCursor cursor, TreeTable treeTable, ReportToWorkbookProjectionContext context, PassKind passKind) { if (passKind == PassKind.Formatting) { // Format whole table cursor.CanvassedRange.ApplyTableFormat(treeTable.Format); // Format columns var tableColumns = treeTable.TableColumns; var topLeftDataCellReference = cursor.HasMarker(TopLeftDataCellMarker) ? cursor.GetMarkedCellReference(TopLeftDataCellMarker) : null; var bottomRightNonSummaryDataCellReference = cursor.HasMarker(BottomRightNonSummaryDataCellMarker) ? cursor.GetMarkedCellReference(BottomRightNonSummaryDataCellMarker) : null; var bottomRightHeaderCellReference = cursor.HasMarker(BottomRightHeaderCellMarker) ? cursor.GetMarkedCellReference(BottomRightHeaderCellMarker) : null; foreach (var column in tableColumns.Columns) { var wholeColumnRange = cursor.Worksheet.GetRange(cursor.RowNumber, cursor.MaxRowNumber, cursor.ColumnNumber, cursor.ColumnNumber); // ReSharper disable once PossibleNullReferenceException var dataCellsRange = topLeftDataCellReference == null ? null : cursor.Worksheet.GetRange(topLeftDataCellReference.RowNumber, bottomRightNonSummaryDataCellReference.RowNumber, cursor.ColumnNumber, cursor.ColumnNumber); var lastHeaderCellToLastNonSummaryDataCellRange = bottomRightHeaderCellReference == null ? null : dataCellsRange == null ? null : cursor.Worksheet.GetRange(bottomRightHeaderCellReference.RowNumber, bottomRightNonSummaryDataCellReference.RowNumber, cursor.ColumnNumber, cursor.ColumnNumber); // Individual column format will override the format applied to all table columns, // that's why we first apply the table columns format and then the individual column's format. wholeColumnRange.ApplyColumnFormat(dataCellsRange, lastHeaderCellToLastNonSummaryDataCellRange, tableColumns.ColumnsFormat); wholeColumnRange.ApplyColumnFormat(dataCellsRange, lastHeaderCellToLastNonSummaryDataCellRange, column.Format); cursor.MoveRight(); } cursor.ResetColumn(); } // Add rows cursor.AddTableRows(treeTable.TableRows, context, passKind); }