rowSpan property
int
get
rowSpan
Gets or sets a value that indicates the total number of rows that cell spans within a PdfGrid.
//Create a new PDF document
PdfDocument document = PdfDocument();
//Create a PdfGrid
PdfGrid grid = PdfGrid();
//Add columns to grid
grid.columns.add(count: 3);
//Add headers to grid
PdfGridRow header = grid.headers.add(1)[0];
header.cells[0].value = 'Employee ID';
header.cells[1].value = 'Employee Name';
header.cells[2].value = 'Salary';
//Add rows to grid
PdfGridRow row1 = grid.rows.add();
row1.cells[0].value = 'E01';
row1.cells[1].value = 'Clay';
row1.cells[2].value = '\$10000';
//Sets the rowSpan
row1.cells[1].rowSpan = 1;
//Sets the colSpan
row1.cells[1].columnSpan = 2;
//Apply the cell style to specific row cells
row1.cells[0].style = PdfGridCellStyle(
backgroundBrush: PdfBrushes.lightYellow,
cellPadding: PdfPaddings(left: 2, right: 3, top: 4, bottom: 5),
font: PdfStandardFont(PdfFontFamily.timesRoman, 17),
textBrush: PdfBrushes.white,
textPen: PdfPens.orange,
);
PdfGridRow row2 = grid.rows.add();
row2.cells[0].value = 'E02';
row2.cells[1].value = 'Simon';
row2.cells[2].value = '\$12,000';
//Gets the width of the PDF grid cell
double width = row2.cells[2].width;
//Gets the height of the PDF grid cell
double height = row2.cells[2].height;
//Draw the grid in PDF document page
grid.draw(
page: document.pages.add(), bounds: Rect.zero);
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();
Implementation
int get rowSpan => _rowSpan;
set
rowSpan
(int value)
Implementation
set rowSpan(int value) {
if (value < 1) {
throw ArgumentError.value('value', 'row span',
'Invalid span specified, must be greater than or equal to 1');
}
if (value > 1) {
_rowSpan = value;
PdfGridRowHelper.getHelper(_helper.row!).rowSpanExists = true;
PdfGridHelper.getHelper(PdfGridRowHelper.getHelper(_helper.row!).grid)
.hasRowSpan = true;
}
}