This way will work but there's a faster way to simulate colspan if you know
the width of the table and by consequence the width of each cell.
Imagine a table with 10 columns with an header with two columns that span
5+5 columns. Each column has the width of 50. 5 columns have the width of
250. To span this columns make the first and sixth cell with a
setPaddingRight(-200 + 2). 2 is the actual padding right. Fill only this 2
columns and leave the others blank without vertical borders.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Yalavarthi, Vasu [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, January 22, 2002 2:39
> To:   'Itext-Questions (E-mail)
> Subject:      [iText-questions] Nested PdfPTable
> 
> Hi,
>  I have a table with 2(or more header rows) and n-Data rows.
> The table will have 10 columns.
> In the first header row, i want to have a column span of 1 for the first 4
> columns and a column span of 2 for the next three( 3x2 = 6) columns.
> In the second header row and in the data rows i want to have a column span
> of 1 for all the columns.
> 
> Since PdfPTable doesn't support column span, I am planning to use nested
> tables as shown below:
> Let me know if this is the efficient way of doing nested tables:
> 
> //////////Sample Code/////////////////
> PdfPTable mainTable = new PdfPTable(1);
> PdfPTable headerTable1 = PdfPTable(7);
> float widthPercents1[] = { 1, 1, 1, 1, 2, 2, 2 };
> headerTable1.setWidths( widthPercents );
> 
> PdfPTable headerTable2 = PdfPTable(10);
> float widthPercents2[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
> headerTable2.setWidths( widthPercents2 );
> 
> mainTable.addCell( headerTable1 );
> mainTable.addCell( headerTable2 );
> mainTable.setHeaderRows(2);
> 
> PdfPTable dataTable = new PdfPTable(10);
> dataTable.setWidths( widthPercents2 );
> for(int i = 0; i < 200; i++) {
>       for(int j=0; j < 10; j++) {
>               dataTable.addCell( "Data");
>       }
>       mainTable.addCell( dataTable );
>        dataTable.deleteLastRow();
> }
> 
> document.add( mainTable );
> ////////////End Sample Code////////////
> 
> Thanks,
> Vasu
> 
> 
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions

_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to