- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
NESTED TABLES in Java
NESTED TABLES Encoding QR Code In Java Using Barcode generator for Java Control to generate, create QR Code image in Java applications. www.OnBarcode.comScan QR Code In Java Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comThere was a time when rowspan wasn t supported for PdfPCells. The only way to work around this was to use nested tables. Cells 1.1 and 1.2 in figure 4.10 are part of a Code-128 Generation In Java Using Barcode printer for Java Control to generate, create Code 128A image in Java applications. www.OnBarcode.comMaking EAN / UCC - 13 In Java Using Barcode printer for Java Control to generate, create EAN / UCC - 14 image in Java applications. www.OnBarcode.comOrganizing content in tables
Making PDF-417 2d Barcode In Java Using Barcode drawer for Java Control to generate, create PDF417 image in Java applications. www.OnBarcode.comData Matrix 2d Barcode Generator In Java Using Barcode maker for Java Control to generate, create Data Matrix image in Java applications. www.OnBarcode.comNested tables
EAN / UCC - 13 Generation In Java Using Barcode drawer for Java Control to generate, create GS1-128 image in Java applications. www.OnBarcode.comRoyal Mail Barcode Generation In Java Using Barcode generator for Java Control to generate, create RM4SCC image in Java applications. www.OnBarcode.comnested table. So are cells 12.1 and 12.2. Because of this, cells 13, 14, and 15 look as if they have their rowspan set to 2. Looking at next listing, you ll immediately see the difference between the nested table in cell 1 and the nested table in cell 12. Generate Denso QR Bar Code In Objective-C Using Barcode encoder for iPhone Control to generate, create QR Code image in iPhone applications. www.OnBarcode.comPrint QR In Java Using Barcode generator for Java Control to generate, create Quick Response Code image in Java applications. www.OnBarcode.comListing 4.16 NestedTable.java
Barcode Printer In Visual Studio .NET Using Barcode encoder for Visual Studio .NET Control to generate, create Barcode image in VS .NET applications. www.OnBarcode.comBarcode Printer In None Using Barcode creator for Software Control to generate, create Barcode image in Software applications. www.OnBarcode.comPdfPTable table = new PdfPTable(4); PdfPTable nested1 = new PdfPTable(2); Creates table nested1.addCell("1.1"); for cell 1 nested1.addCell("1.2"); PdfPTable nested2 = new PdfPTable(1); Creates table nested2.addCell("12.1"); for cell 12 nested2.addCell("12.2"); for (int k = 0; k < 16; ++k) { if (k == 1) { table.addCell(nested1); Adds tables } else if (k == 12) { as cell table.addCell(new PdfPCell(nested2)); } else { table.addCell("cell " + k); } } document.add(table); UPC - 13 Decoder In None Using Barcode decoder for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comUCC - 12 Maker In None Using Barcode generation for Microsoft Word Control to generate, create EAN / UCC - 14 image in Office Word applications. www.OnBarcode.comJust like with the Image object, the padding is 2 pt when the PdfPTable is added with addCell() directly. The padding is 0 pt when you wrap the table in a PdfPCell first. Create Code 128B In Java Using Barcode drawer for Android Control to generate, create Code 128C image in Android applications. www.OnBarcode.comPaint PDF417 In VB.NET Using Barcode creation for .NET framework Control to generate, create PDF 417 image in .NET framework applications. www.OnBarcode.comCOMPLEX TABLE LAYOUTS
ANSI/AIM Code 39 Generator In Java Using Barcode creation for Eclipse BIRT Control to generate, create Code 39 Extended image in Eclipse BIRT applications. www.OnBarcode.comQR-Code Generation In .NET Framework Using Barcode drawer for Visual Studio .NET Control to generate, create QR image in Visual Studio .NET applications. www.OnBarcode.comYou can use nested tables to create layouts that are tabular, but that don t fit in a traditional grid. Figure 4.11 is an example of such a layout. ANSI/AIM Code 39 Reader In VB.NET Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comMake Code-39 In Visual Studio .NET Using Barcode generator for .NET framework Control to generate, create Code39 image in Visual Studio .NET applications. www.OnBarcode.comFigure 4.11 Nesting tables for complex layouts
Changing the properties of a cell
This layout is created using the next listing, which is an example of deep nesting. A table is nested inside a nested table. Listing 4.17 NestedTables.java
public void createPdf(String filename) throws SQLException, DocumentException, IOException { DatabaseConnection connection = new HsqldbConnection("filmfestival"); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); List days = PojoFactory.getDays(connection); for (Date day : days) { document.add(getTable(connection, day)); document.newPage(); } document.close(); connection.close(); } public PdfPTable getTable( DatabaseConnection connection, Date day) throws SQLException, DocumentException, IOException { Master table PdfPTable table = new PdfPTable(1); ... List screenings = PojoFactory.getScreenings(connection, day); for (Screening screening : screenings) { table.addCell(getTable(connection, screening)); } return table; } private PdfPTable getTable( DatabaseConnection connection, Screening screening) throws DocumentException, IOException { PdfPTable table = new PdfPTable(4); ... Movie movie = screening.getMovie(); Table nested PdfPCell cell = new PdfPCell(); inside master cell.addElement(fullTitle(screening)); table ... table.addCell(cell); ... return table; } private static PdfPTable fullTitle(Screening screening) throws DocumentException { PdfPTable table = new PdfPTable(3); Deep nested table ... return table; } The table created with the fullTitle() method was added with the addElement() method. The effect is different from adding a PdfPTable as a parameter of the addCell() method or the PdfPCell constructor. With addElement(), the table is Organizing content in tables
added to the ColumnText object of the cell, and you can add other elements to the same cell. You ve now worked with some small, almost academic, table examples to demonstrate the properties of tables and cells, but once you start working with real-world examples, tables can get really large. In the next section, we ll discuss tips and tricks that are important as soon as a table spans multiple pages. Dealing with large tables
The table in figure 4.11 has a header with a date. If you download the example and generate the PDF on your own computer, you ll see that the table with all the movies spans more than one page for most of the days. The table is nicely split, but unfortunately the header isn t repeated. In this section, you ll fix this, and also add a footer while you re at it. Repeating headers and footers
Figure 4.12 is another overview of movie screenings on a specific day. The date is shown in the first row. The second row consists of headers that describe the content of the columns: Location, Time, Run Length, Title, and so on. The same information is also added as a footer.
|
|