Search in sources :

Example 1 with ReportTO

use of org.compiere.model.ReportTO in project adempiere by adempiere.

the class SmjPdfReport method reportTable.

// generar
/**
	 * coloca la tabla en el reporte ** Put table in report
	 */
public void reportTable() {
    PdfPCell tableCell;
    Iterator<ReportTO> itRep = data.iterator();
    while (itRep.hasNext()) {
        ReportTO rpt = itRep.next();
        if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("T")) {
            // Coloca titulo - put title
            PdfPCell title = new PdfPCell(new Paragraph(dataNull(rpt.getDescription()), titleTableFont));
            title.setColspan(cols);
            title.setHorizontalAlignment(Paragraph.ALIGN_CENTER);
            title.setBorder(0);
            table.addCell(title);
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("L")) {
            // coloca linea en el reporte - Put under line in the report
            PdfPCell line = new PdfPCell(new Paragraph("", subFont));
            line.setColspan(cols);
            line.setBorderWidthLeft(0);
            line.setBorderWidthRight(0);
            line.setBorderWidthTop(0);
            line.setBorderColorBottom(Color.BLACK);
            table.addCell(line);
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("X")) {
            // coloca linea de total - Put total line
            simpleLine();
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("Z")) {
            // coloca linea doble de total - Put total line doble
            for (int j = 0; j < 2; j++) {
                simpleLine();
            }
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("D")) {
            // coloca liena de descripcion - put description line
            tableCell = new PdfPCell(new Phrase(""));
            tableCell.setBorder(0);
            table.addCell(tableCell);
            tableCell = new PdfPCell(new Phrase(""));
            tableCell.setBorderWidthLeft(0);
            tableCell.setBorderWidthRight(0);
            tableCell.setBorderWidthTop(0);
            tableCell.setBorderColorBottom(Color.BLACK);
            table.addCell(tableCell);
            for (int i = 0; i < (cols - 2); i++) {
                tableCell = new PdfPCell(new Phrase(""));
                tableCell.setBorder(0);
                table.addCell(tableCell);
            }
        // for
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("S")) {
            // coloca linea en blanco - put empty line
            PdfPCell line = new PdfPCell(new Paragraph("         "));
            line.setColspan(cols);
            line.setBorder(0);
            table.addCell(line);
        } else if (rpt.getTablevel() != null && rpt.getTablevel() > 0) {
            // coloca espacios a la izquierda para simular jeraquia - put
            // left spaces to simulate hierarchy
            String jerarchy = "";
            for (int i = 1; i <= rpt.getTablevel(); i++) {
                jerarchy = jerarchy + "   ";
            }
            PdfPCell line = new PdfPCell(new Paragraph(jerarchy + dataNull(rpt.getDescription()), catFont));
            line.setColspan(cols);
            line.setHorizontalAlignment(Paragraph.ALIGN_LEFT);
            line.setBorder(0);
            table.addCell(line);
        } else {
            if (rpt.getDescription() != null) {
                // nombre - name
                tableCell = new PdfPCell(new Phrase(dataNull(rpt.getName()), subFont));
                tableCell.setBorder(0);
                tableCell.setHorizontalAlignment(Paragraph.ALIGN_LEFT);
                table.addCell(tableCell);
                // descripcion - description
                tableCell = new PdfPCell(new Phrase(dataNull(rpt.getDescription()), subFont));
                tableCell.setBorder(0);
                table.addCell(tableCell);
                // columnas 0 a 20 - cols 0 to 20
                if (cols >= 3) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_0()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 4) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_1()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 5) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_2()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 6) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_3()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 7) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_4()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 8) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_5()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 9) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_6()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 10) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_7()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 11) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_8()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 12) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_9()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 13) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_10()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 14) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_11()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 15) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_12()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 16) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_13()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 17) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_14()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 18) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_15()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 19) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_16()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 20) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_17()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 21) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_18()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 22) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_19()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
                if (cols >= 23) {
                    tableCell = new PdfPCell(new Phrase(formatValue(rpt.getCol_20()), subFont));
                    tableCell.setBorder(0);
                    tableCell.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
                    table.addCell(tableCell);
                }
            }
        // if description NO null
        }
    // final else
    }
// while
}
Also used : PdfPCell(com.lowagie.text.pdf.PdfPCell) ReportTO(org.compiere.model.ReportTO) Phrase(com.lowagie.text.Phrase) Paragraph(com.lowagie.text.Paragraph)

Example 2 with ReportTO

use of org.compiere.model.ReportTO in project adempiere by adempiere.

the class SmjReportLogic method getDataReport.

/**
	 * trae los datos de T_Report ** T_Report get Data
	 * 
	 * @param idReport
	 * @param nameTrx
	 */
public LinkedList<ReportTO> getDataReport(Integer idReport, String nameTrx) {
    StringBuffer sql = new StringBuffer();
    sql.append("select seqno, name, description, col_0, col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8, ");
    sql.append("col_9, col_10, col_11, col_12, col_13, col_14, col_15, col_16, col_17, col_18, col_19, col_20, ");
    sql.append("tablevel, reportlinestyle, fixedPercentage from T_Report ");
    sql.append("where ad_pinstance_id = " + idReport + " ");
    sql.append(" order by seqno, name asc ");
    //		System.out.println("data SQL::"+sql.toString());
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    LinkedList<ReportTO> data = new LinkedList<ReportTO>();
    try {
        pstmt = DB.prepareStatement(sql.toString(), nameTrx);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            ReportTO rpt = new ReportTO();
            rpt.setSeqno(rs.getInt("seqno"));
            rpt.setName(rs.getString("name"));
            rpt.setDescription(rs.getString("description"));
            rpt.setCol_0(rs.getBigDecimal("col_0"));
            rpt.setCol_1(rs.getBigDecimal("col_1"));
            rpt.setCol_2(rs.getBigDecimal("col_2"));
            rpt.setCol_3(rs.getBigDecimal("col_3"));
            rpt.setCol_4(rs.getBigDecimal("col_4"));
            rpt.setCol_5(rs.getBigDecimal("col_5"));
            rpt.setCol_6(rs.getBigDecimal("col_6"));
            rpt.setCol_7(rs.getBigDecimal("col_7"));
            rpt.setCol_8(rs.getBigDecimal("col_8"));
            rpt.setCol_9(rs.getBigDecimal("col_9"));
            rpt.setCol_10(rs.getBigDecimal("col_10"));
            rpt.setCol_11(rs.getBigDecimal("col_11"));
            rpt.setCol_12(rs.getBigDecimal("col_12"));
            rpt.setCol_13(rs.getBigDecimal("col_13"));
            rpt.setCol_14(rs.getBigDecimal("col_14"));
            rpt.setCol_15(rs.getBigDecimal("col_15"));
            rpt.setCol_16(rs.getBigDecimal("col_16"));
            rpt.setCol_17(rs.getBigDecimal("col_17"));
            rpt.setCol_18(rs.getBigDecimal("col_18"));
            rpt.setCol_19(rs.getBigDecimal("col_19"));
            rpt.setCol_20(rs.getBigDecimal("col_20"));
            //SMJReport
            rpt.setTablevel(rs.getInt("tablevel"));
            rpt.setReportlinestyle(rs.getString("reportlinestyle"));
            rpt.setFixedPercentage(rs.getInt("fixedPercentage"));
            data.add(rpt);
        }
    // while
    }// try
     catch (Exception e) {
        log.log(Level.SEVERE, sql.toString(), e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    return data;
}
Also used : ResultSet(java.sql.ResultSet) ReportTO(org.compiere.model.ReportTO) PreparedStatement(java.sql.PreparedStatement) LinkedList(java.util.LinkedList)

Example 3 with ReportTO

use of org.compiere.model.ReportTO in project adempiere by adempiere.

the class SmjXlsReport method reportTable.

// titleTable
/**
	 * llena los datos del reporte - fill report data
	 * @param book
	 * @param data
	 * @param sheet
	 * @param fila
	 */
public void reportTable(HSSFWorkbook book, LinkedList<ReportTO> data, HSSFSheet sheet, int fila) {
    HSSFRow row;
    // crea fuente - create font
    HSSFFont font = book.createFont();
    font.setFontHeightInPoints((short) 10);
    font.setFontName(HSSFFont.FONT_ARIAL);
    HSSFRichTextString text;
    Iterator<ReportTO> itRep = data.iterator();
    Boolean newRow = false;
    sheet.setColumnWidth((short) 0, (short) (13 * 256));
    sheet.setColumnWidth((short) 1, (short) (60 * 256));
    for (int i = 2; i < (cols); i++) {
        sheet.setColumnWidth((short) i, (short) (15 * 256));
    }
    //for
    // estio celda - cell style
    HSSFCellStyle cellStyle = book.createCellStyle();
    HSSFCellStyle cellStyleD = book.createCellStyle();
    HSSFCellStyle cellStyleN = book.createCellStyle();
    while (itRep.hasNext()) {
        short col = 0;
        ReportTO rpt = itRep.next();
        if (!newRow) {
            cellStyle = book.createCellStyle();
            cellStyleD = book.createCellStyle();
            cellStyleN = book.createCellStyle();
        }
        //if
        newRow = false;
        if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("T")) {
            // Coloca titulo - put title
            row = sheet.createRow(fila++);
            HSSFFont fontT = book.createFont();
            fontT.setFontHeightInPoints((short) 12);
            fontT.setFontName(HSSFFont.FONT_ARIAL);
            fontT.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            HSSFCellStyle cellStyleT = book.createCellStyle();
            cellStyleT.setWrapText(true);
            cellStyleT.setAlignment(HSSFCellStyle.ALIGN_CENTER);
            cellStyleT.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);
            cellStyleT.setFont(fontT);
            Region region = new Region(fila - 1, (short) 0, fila - 1, endRegion);
            sheet.addMergedRegion(region);
            text = new HSSFRichTextString(rpt.getDescription());
            HSSFCell cellT = row.createCell(col);
            cellT.setCellStyle(cellStyleT);
            cellT.setCellValue(text);
            newRow = true;
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("L")) {
            // coloca linea en el reporte - Put under line in the report
            cellStyle.setWrapText(true);
            cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
            cellStyle.setBottomBorderColor((short) 8);
            cellStyleD.setWrapText(true);
            cellStyleD.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
            cellStyleD.setBottomBorderColor((short) 8);
            cellStyleN.setWrapText(true);
            cellStyleN.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
            cellStyleN.setBottomBorderColor((short) 8);
            newRow = true;
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("X")) {
            // coloca linea de total - Put total line
            cellStyle.setWrapText(true);
            cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);
            cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
            cellStyle.setBottomBorderColor((short) 8);
            newRow = true;
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("Z")) {
            // coloca linea doble de total - Put total line doble
            cellStyle.setWrapText(true);
            cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);
            cellStyle.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
            cellStyle.setBottomBorderColor((short) 8);
            //--------------
            row = sheet.createRow(fila++);
            ReportTO rptD = new ReportTO();
            putRow(cellStyle, cellStyleD, cellStyleN, sheet, row, fila, rptD);
            cellStyle = book.createCellStyle();
            newRow = true;
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("D")) {
            // coloca liena de descripcion - put description line
            cellStyleD.setWrapText(true);
            cellStyleD.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);
            cellStyleD.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
            cellStyleD.setBottomBorderColor((short) 8);
            newRow = true;
        } else if (rpt.getReportlinestyle() != null && rpt.getReportlinestyle().equals("S")) {
            // coloca linea en blanco - put empty line
            row = sheet.createRow(fila++);
            newRow = true;
        } else if (rpt.getTablevel() != null && rpt.getTablevel() > 0) {
            // coloca espacios a la izquierda para simular jeraquia - put
            // left spaces to simulate hierarchy
            row = sheet.createRow(fila++);
            String jerarchy = "";
            for (int i = 1; i <= rpt.getTablevel(); i++) {
                jerarchy = jerarchy + "   ";
            }
            //for
            Region region = new Region(fila - 1, (short) 0, fila - 1, endRegion);
            sheet.addMergedRegion(region);
            text = new HSSFRichTextString(jerarchy + rpt.getDescription());
            HSSFCell cellJ = row.createCell(col);
            cellJ.setCellValue(text);
            newRow = true;
        } else {
            row = sheet.createRow(fila++);
            putRow(cellStyle, cellStyleD, cellStyleN, sheet, row, fila, rpt);
        }
    //else
    }
// while itData
}
Also used : HSSFCellStyle(org.apache.poi.hssf.usermodel.HSSFCellStyle) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) ReportTO(org.compiere.model.ReportTO) Region(org.apache.poi.hssf.util.Region) HSSFFont(org.apache.poi.hssf.usermodel.HSSFFont) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString)

Aggregations

ReportTO (org.compiere.model.ReportTO)3 Paragraph (com.lowagie.text.Paragraph)1 Phrase (com.lowagie.text.Phrase)1 PdfPCell (com.lowagie.text.pdf.PdfPCell)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 LinkedList (java.util.LinkedList)1 HSSFCell (org.apache.poi.hssf.usermodel.HSSFCell)1 HSSFCellStyle (org.apache.poi.hssf.usermodel.HSSFCellStyle)1 HSSFFont (org.apache.poi.hssf.usermodel.HSSFFont)1 HSSFRichTextString (org.apache.poi.hssf.usermodel.HSSFRichTextString)1 HSSFRow (org.apache.poi.hssf.usermodel.HSSFRow)1 Region (org.apache.poi.hssf.util.Region)1