protected override bool WriteColumnHeader(bool exportRawValues) { if (base.WriteColumnHeader(exportRawValues)) { return(true); } // If DisplayString is null, then write out the Column's name property as the header. foreach (BaseColumn col in data.ColumnList) { if (!(col == null)) { if (data.IncludeInExport(col)) { if (!exportRawValues) { base.WriteColumnTitle(col.Name); } else { Boolean _isExpandableNonCompositeForeignKey = col.TableDefinition.IsExpandableNonCompositeForeignKey(col); if (_isExpandableNonCompositeForeignKey) { ForeignKey fkColumn = data.DBTable.TableDefinition.GetExpandableNonCompositeForeignKey(col); String name = fkColumn.GetPrimaryKeyColumnName(col); base.WriteColumnTitle(name); } else { base.WriteColumnTitle(col.Name); } } } } } return(true); }
public override void Export(System.Web.HttpResponse response) { bool done = false; object val; if (response == null) { return; } CreateExcelBook(); int width = 0; int columnCounter = 0; // First write out the Column Headers foreach (ExcelColumn col in data.ColumnList) { width = GetExcelCellWidth(col); if (data.IncludeInExport(col)) { AddColumnToExcelBook(columnCounter, col.ToString(), GetExcelDataType(col), width, GetDisplayFormat(col)); columnCounter++; } } // Read pageSize records at a time and write out the Excel file. int totalRowsReturned = 0; while (!done) { ArrayList recList = data.GetRows(pageSize); if (recList == null) { break; } totalRowsReturned = recList.Count; foreach (BaseRecord rec in recList) { AddRowToExcelBook(); columnCounter = 0; foreach (ExcelColumn col in data.ColumnList) { if (!data.IncludeInExport(col)) { continue; } val = GetValueForExcelExport(col, rec); AddCellToExcelRow(columnCounter, GetExcelDataType(col), val, col.DisplayFormat); columnCounter++; } } // If we already are below the pageSize, then we are done. if ((totalRowsReturned < pageSize)) { done = true; } } SaveExcelBook(response); }