public void PrintRow(int rowIndex) { originalRowIndex = rowIndex; if (nowPrinting == NowPrinting.None) { // we are at the start. Rows will now have priority over columns. rowsPriority = true; } if (rowsPriority) { switch (nowPrinting) { case NowPrinting.None: printingRowIndex = 0; break; case NowPrinting.Column: printingRowIndex++; break; case NowPrinting.Row: // we have two sequential calls of the PrintRow. But we must print // some columns... break; } // add new row, do not copy cells: it will be done in the PrintColumn. TableRow row = new TableRow(); row.Assign(sourceTable.Rows[rowIndex]); row.PageBreak = pageBreak; resultTable.Rows.Add(row); columnSpans.Clear(); } else { if (nowPrinting == NowPrinting.Column) { // this is the first row inside a column, reset the index printingRowIndex = 0; } else { // not the first row, increment the index printingRowIndex++; } TableRow row = null; if (resultTable.Rows.Count <= printingRowIndex) { // index is outside existing rows. Probably not all rows created yet, // we're at the start. Add new row. row = new TableRow(); row.Assign(sourceTable.Rows[rowIndex]); resultTable.Rows.Add(row); } else { // do not create row, use existing one row = resultTable.Rows[printingRowIndex]; } // apply page break row.PageBreak = pageBreak; // copy cells from the template to the result CopyCells(originalColumnIndex, originalRowIndex, printingColumnIndex, printingRowIndex); } nowPrinting = NowPrinting.Row; pageBreak = false; }
public void PrintColumn(int columnIndex) { originalColumnIndex = columnIndex; if (nowPrinting == NowPrinting.None) { // we are at the start. Columns will now have priority over rows. rowsPriority = false; } if (!rowsPriority) { switch (nowPrinting) { case NowPrinting.None: printingColumnIndex = 0; break; case NowPrinting.Column: // we have two sequential calls of the PrintColumn. But we must print // some rows... break; case NowPrinting.Row: printingColumnIndex++; break; } // add new column, do not copy cells: it will be done in the PrintRow. TableColumn column = new TableColumn(); column.Assign(sourceTable.Columns[columnIndex]); column.PageBreak = pageBreak; resultTable.Columns.Add(column); rowSpans.Clear(); } else { if (nowPrinting == NowPrinting.Row) { // this is the first column inside a row, reset the index printingColumnIndex = 0; } else { // not the first column, increment the index printingColumnIndex++; } TableColumn column = null; if (resultTable.Columns.Count <= printingColumnIndex) { // index is outside existing columns. Probably not all columns // created yet, we're at the start. Add new column. column = new TableColumn(); column.Assign(sourceTable.Columns[columnIndex]); resultTable.Columns.Add(column); } else { // do not create column, use existing one column = resultTable.Columns[printingColumnIndex]; } // apply page break column.PageBreak = pageBreak; // copy cells from the template to the result CopyCells(originalColumnIndex, originalRowIndex, printingColumnIndex, printingRowIndex); } nowPrinting = NowPrinting.Column; pageBreak = false; }