Search in sources :

Example 36 with Table

use of com.itextpdf.layout.element.Table in project ComponentManagement by Bac3Phi.

the class ReportInventoriesController method addTableInventories.

private void addTableInventories(Document document) throws SQLException {
    float[] pointColumnWidths = { 200F, 200F, 200F, 200F, 200F };
    Table table = new Table(pointColumnWidths);
    table.addCell(new Cell().add("Mã Chi Tiết Hàng Tồn").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tên Mặt Hàng").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Lượng Nhập").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Lượng Bán").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Lượng Tồn").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    resultSet = dbConn.getData("SELECT CTBCHT.MaCTBC, MH.TenMH, SUM(CTPN.SoLuong) AS LuongNhapBĐ, SUM(CTHD.SoLuong) AS LuongBan, SUM(MH.SoLuong) AS LuongTon FROM CHITIETBAOCAOHANGTON CTBCHT JOIN MATHANG MH JOIN CHITIETPHIEUNHAP CTPN JOIN CHITIETHOADON CTHD ON CTBCHT.MaMH = MH.MaMH AND CTPN.MaMH = CTBCHT.MaMH AND CTHD.MaMH = CTBCHT.MaMH WHERE MaBCHT = '" + txtReportID.getText() + "'" + "GROUP BY TenMH;");
    while (resultSet.next()) {
        table.addCell(new Cell().add(resultSet.getString("MaCTBC")).setTextAlignment(TextAlignment.LEFT).setFontSize(12)).setFont(font);
        table.addCell(new Cell().add(resultSet.getString("TenMH")).setTextAlignment(TextAlignment.LEFT).setFontSize(12)).setFont(font);
        table.addCell(new Cell().add(String.valueOf(resultSet.getLong("LuongNhapBĐ"))).setTextAlignment(TextAlignment.RIGHT).setFontSize(12)).setFont(font);
        table.addCell(new Cell().add(String.valueOf(resultSet.getLong("LuongBan"))).setTextAlignment(TextAlignment.RIGHT).setFontSize(12)).setFont(font);
        table.addCell(new Cell().add(String.valueOf(resultSet.getLong("LuongTon"))).setTextAlignment(TextAlignment.RIGHT).setFontSize(12)).setFont(font);
    }
    document.add(table);
}
Also used : Table(com.itextpdf.layout.element.Table) Cell(com.itextpdf.layout.element.Cell)

Example 37 with Table

use of com.itextpdf.layout.element.Table in project ComponentManagement by Bac3Phi.

the class ReportInventoriesController method addTable.

private void addTable(Document document) throws SQLException {
    float[] pointColumnWidths = { 200F, 200F, 200F, 200F, 200F, 200F, 200F };
    Table table = new Table(pointColumnWidths);
    table.addCell(new Cell().add("Mã BCHT").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Ngày lập").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tháng").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tên nhân viên lập").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tổng nhập").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tổng bán").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tổng tồn").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    InventoriesReport selectedRow = tbvReport.getSelectionModel().getSelectedItem();
    table.addCell(new Cell().add(selectedRow.getReportID()).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
    table.addCell(new Cell().add(selectedRow.getPublishDate().toString()).setTextAlignment(TextAlignment.LEFT).setFont(font));
    table.addCell(new Cell().add(String.valueOf(selectedRow.getReportMonth())).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
    table.addCell(new Cell().add(String.valueOf(selectedRow.getEmployeeName())).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
    table.addCell(new Cell().add(String.valueOf(selectedRow.getSumImport())).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
    table.addCell(new Cell().add(String.valueOf(selectedRow.getSumSell())).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
    table.addCell(new Cell().add(String.valueOf(selectedRow.getSumStock())).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
    document.add(table);
}
Also used : Table(com.itextpdf.layout.element.Table) Cell(com.itextpdf.layout.element.Cell)

Aggregations

Table (com.itextpdf.layout.element.Table)37 Cell (com.itextpdf.layout.element.Cell)29 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)25 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)25 Document (com.itextpdf.layout.Document)25 Paragraph (com.itextpdf.layout.element.Paragraph)22 CsvTo2DList (com.itextpdf.highlevel.util.CsvTo2DList)7 List (java.util.List)7 SolidBorder (com.itextpdf.layout.borders.SolidBorder)3 DashedBorder (com.itextpdf.layout.borders.DashedBorder)2 DottedBorder (com.itextpdf.layout.borders.DottedBorder)2 Image (com.itextpdf.layout.element.Image)2 IOException (java.io.IOException)2 PdfFont (com.itextpdf.kernel.font.PdfFont)1 Rectangle (com.itextpdf.kernel.geom.Rectangle)1 PdfDocumentInfo (com.itextpdf.kernel.pdf.PdfDocumentInfo)1 PdfCanvas (com.itextpdf.kernel.pdf.canvas.PdfCanvas)1 Canvas (com.itextpdf.layout.Canvas)1 Style (com.itextpdf.layout.Style)1 SolidBorder (com.itextpdf.layout.border.SolidBorder)1