exportColumnHeader method

  1. @protected
void exportColumnHeader(
  1. SfDataGrid dataGrid,
  2. GridColumn column,
  3. String columnName,
  4. PdfGrid pdfGrid,
)

Exports a column header to Pdf

Implementation

@protected
void exportColumnHeader(SfDataGrid dataGrid, GridColumn column,
    String columnName, PdfGrid pdfGrid) {
  int rowSpan = 0;
  PdfGridRow columnHeader = pdfGrid.headers[rowIndex];
  PdfGridCell pdfCell = columnHeader.cells[_columnIndex];

  if (dataGrid.stackedHeaderRows.isNotEmpty && exportStackedHeaders) {
    rowSpan = getRowSpan(
        dataGrid: dataGrid,
        isStackedHeader: false,
        columnName: column.columnName,
        rowIndex: rowIndex - 1,
        columnIndex: dataGrid.columns.indexOf(column));
  }
  if (rowSpan > 0) {
    // Retrieve the header cell at the given index by subtracting the number of rows
    // spanned by the previous cells in the same row.
    columnHeader = pdfGrid.headers[rowIndex - rowSpan];
    pdfCell = columnHeader.cells[_columnIndex];
    pdfCell.rowSpan = rowSpan + 1;
    pdfCell.value = columnName;
  } else {
    pdfCell.value = columnName;
  }
  pdfCell.style.borders.all = _pdfPen;
  _exportCellToPdf(
      DataGridExportCellType.columnHeader, pdfCell, columnName, column);
}