Example usage for org.jfree.chart ChartUtilities writeChartAsPNG

List of usage examples for org.jfree.chart ChartUtilities writeChartAsPNG

Introduction

In this page you can find the example usage for org.jfree.chart ChartUtilities writeChartAsPNG.

Prototype

public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height)
        throws IOException 

Source Link

Document

Writes a chart to an output stream in PNG format.

Usage

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI Informix xls// w ww .ja va2 s  .c  o m
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportInformixSelfExcel(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        // fileName = CommonAppUtil.getAppName() +
        // "/temp/hostnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));

        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        WritableSheet sheet = wb.createSheet(hostname + "", 0);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD,
                false);
        WritableCellFormat labelFormat = new WritableCellFormat(labelFont);

        WritableCellFormat _labelFormat = new WritableCellFormat();
        _labelFormat.setBackground(jxl.format.Colour.GRAY_25);

        WritableCellFormat p_labelFormat = new WritableCellFormat();
        p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE);

        WritableCellFormat b_labelFormat = new WritableCellFormat();
        b_labelFormat.setBackground(jxl.format.Colour.GRAY_50);

        Label tmpLabel = null;
        tmpLabel = new Label(1, 0, hostname + "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);

        tmpLabel = new Label(1, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);

        tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip
                + "ConnectUtilization" + ".png");
        // sheet,0,0,5,1,,,
        // allRow = allRow+2;
        sheet.addImage(new WritableImage(1, 6, 7, 7, file));
        // allRow = allRow+7;
        int row = 14;
        tmpLabel = new Label(0, row, "   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        // 
        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(1, row, (String) tablesVO.get("dbspace"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(2, row, (String) tablesVO.get("owner"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(3, row, (String) tablesVO.get("fname"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(4, row,
                            df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(5, row,
                            df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(6, row,
                            df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(7, row,
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%",
                            p_labelFormat);
                    sheet.addCell(tmpLabel);
                    row++;
                }
            }
        }
        row = row + 2;
        // Informix
        tmpLabel = new Label(0, row, "     ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List dbsession = (ArrayList) dbinfo.get("sessionList");// 
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                String seqscans = String.valueOf(tablesVO.get("seqscans"));
                if ("null".equals(seqscans)) {
                    seqscans = "";
                }
                String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                if ("null".equals(total_sorts)) {
                    total_sorts = "";
                }
                String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                if ("null".equals(dsksorts)) {
                    dsksorts = "";
                }
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, tablesVO.get("access") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, tablesVO.get("locksheld") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, seqscans, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, total_sorts, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, dsksorts, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        row = row + 2;
        // Informix
        tmpLabel = new Label(0, row, "    ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List dblock = (ArrayList) dbinfo.get("lockList");// 
        if (dblock != null && dblock.size() > 0) {
            for (int i = 0; i < dblock.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblock.get(i);
                String type = (String) tablesVO.get("type");
                String desc = "";
                if ("B".equals(type)) {
                    desc = "";
                } else if ("IS".equals(type)) {
                    desc = "";
                } else if ("S".equals(type)) {
                    desc = "";
                } else if ("XS".equals(type)) {
                    desc = "";
                } else if ("U".equals(type)) {
                    desc = "";
                } else if ("IX".equals(type)) {
                    desc = "";
                } else if ("SIX".equals(type)) {
                    desc = "";
                } else if ("X".equals(type)) {
                    desc = "";
                } else if ("XR".equals(type)) {
                    desc = "";
                }
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, tablesVO.get("dbsname") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, tablesVO.get("tabname") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, desc, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
            sheet.addImage(wi);
        }
        wb.write();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI Informix pdf/*w ww .j  ava  2  s  .  co m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportInformixSelfPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        PdfPTable aTable = new PdfPTable(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        //  document.add(aTable);
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable spaceTable = new PdfPTable(8);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();

        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    cell = new PdfPCell(new Phrase((i + 1) + ""));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("dbspace")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("owner")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("fname")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                }
            }
        }
        document.add(spaceTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable hhTable = new PdfPTable(8);
        float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        hhTable.setWidths(hhWidth);
        hhTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        // hhTable.endHeaders();

        List dbsession = (ArrayList) dbinfo.get("sessionList");// 
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                String seqscans = String.valueOf(tablesVO.get("seqscans"));
                if ("null".equals(seqscans)) {
                    seqscans = "";
                }
                String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                if ("null".equals(total_sorts)) {
                    total_sorts = "";
                }
                String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                if ("null".equals(dsksorts)) {
                    dsksorts = "";
                }
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tablesVO.get("access") + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tablesVO.get("locksheld") + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(seqscans));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(total_sorts));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(dsksorts));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
            }
        }
        document.add(hhTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable lockTable = new PdfPTable(6);
        float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f };
        lockTable.setWidths(lockWidth);
        lockTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        // lockTable.endHeaders();

        List dblock = (ArrayList) dbinfo.get("lockList");// 
        if (dblock != null && dblock.size() > 0) {
            for (int i = 0; i < dblock.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblock.get(i);
                String type = (String) tablesVO.get("type");
                String desc = "";
                if ("B".equals(type)) {
                    desc = "";
                } else if ("IS".equals(type)) {
                    desc = "";
                } else if ("S".equals(type)) {
                    desc = "";
                } else if ("XS".equals(type)) {
                    desc = "";
                } else if ("U".equals(type)) {
                    desc = "";
                } else if ("IX".equals(type)) {
                    desc = "";
                } else if ("SIX".equals(type)) {
                    desc = "";
                } else if ("X".equals(type)) {
                    desc = "";
                } else if ("XR".equals(type)) {
                    desc = "";
                }
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("dbsname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("tabname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(desc));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
            }
        }

        document.add(lockTable);

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI Informixword//from  www .  jav  a2 s  . com
 * @param filename
 * @param types
 * @throws IOException
 */
public void createReport_InformixCldDoc(String filename, String types) throws IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        if ("pdf".equals(types)) {
            PdfWriter.getInstance(document, new FileOutputStream(filename));
        } else {
            RtfWriter2.getInstance(document, new FileOutputStream(filename));
        }
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String typename = (String) reportHash.get("typename");
        String runstr = (String) reportHash.get("runstr");
        String grade = (String) reportHash.get("grade");
        String pingnow = (String) reportHash.get("pingnow");
        String pingmin = (String) reportHash.get("pingmin");
        Hashtable dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        String pingconavg = (String) reportHash.get("pingconavg");
        DBVo vo = (DBVo) reportHash.get("vo");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");

        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        // 
        Table dbTable = new Table(5);
        this.setTableFormat(dbTable);
        // float[] cellWidths = { 220f, 220f, 220f, 220f, 220f };
        // dbTable.setWidths(cellWidths);
        // dbTable.setWidth(100); //  90%
        // dbTable.setAlignment(Element.ALIGN_CENTER);// 
        // dbTable.setAutoFillEmptyCells(true); // 
        // dbTable.setBorderWidth(1); // 
        // dbTable.setBorderColor(new Color(0, 125, 255)); // 
        // dbTable.setPadding(2);// 
        // dbTable.setSpacing(0);// 
        // dbTable.setBorder(2);// 
        // dbTable.endHeaders();

        Cell dbCell = null;
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setColspan(5);
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("IP", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(vo.getDbName(), contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(ip, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(typename, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(runstr, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(grade, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);

        Table aTable = new Table(3);
        // float[] widths = { 220f, 220f, 220f };
        // aTable.setWidths(widths);
        // aTable.setWidth(100); //  90%
        // aTable.setAlignment(Element.ALIGN_CENTER);// 
        // aTable.setAutoFillEmptyCells(true); // 
        // aTable.setBorderWidth(1); // 
        // aTable.setBorderColor(new Color(0, 125, 255)); // 
        // aTable.setPadding(2);// 
        // aTable.setSpacing(0);// 
        // aTable.setBorder(2);// 
        // aTable.endHeaders();
        this.setTableFormat(aTable);
        Cell cell = null;
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingnow + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingmin + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingconavg + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);

        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        // img.setAbsolutePosition(0, 0);
        img.scalePercent(75);
        img.setAlignment(Image.LEFT);// 
        document.add(dbTable);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));

        // Informix
        Table spaceTable = new Table(8);
        this.setTableFormat(spaceTable);
        // float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f
        // };
        // spaceTable.setWidths(width);
        // spaceTable.setWidth(100); //  90%
        // spaceTable.setAlignment(Element.ALIGN_CENTER);// 
        // spaceTable.setAutoFillEmptyCells(true); // 
        // spaceTable.setBorderWidth(1); // 
        // spaceTable.setBorderColor(new Color(0, 125, 255)); // 
        // spaceTable.setPadding(2);// 
        // spaceTable.setSpacing(0);// 
        // spaceTable.setBorder(2);// 
        cell = new Cell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();
        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    cell = new Cell(new Phrase((i + 1) + ""));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", contextFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", contextFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", contextFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%",
                            contextFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);

                }
            }
        }
        document.add(spaceTable);
        document.newPage();
        // Informix
        Table hhTable = new Table(8);
        this.setTableFormat(hhTable);
        float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 440f, 220f, 220f };
        hhTable.setWidths(hhWidth);
        // hhTable.setWidth(100); //  90%
        // hhTable.setAlignment(Element.ALIGN_CENTER);// 
        // hhTable.setAutoFillEmptyCells(true); // 
        // hhTable.setBorderWidth(1); // 
        // hhTable.setBorderColor(new Color(0, 125, 255)); // 
        // hhTable.setPadding(2);// 
        // hhTable.setSpacing(0);// 
        // hhTable.setBorder(2);// 
        cell = new Cell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        hhTable.addCell(cell);
        // hhTable.endHeaders();
        List dbsession = (ArrayList) dbinfo.get("sessionList");// 
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                String seqscans = String.valueOf(tablesVO.get("seqscans"));
                if ("null".equals(seqscans)) {
                    seqscans = "";
                }
                String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                if ("null".equals(total_sorts)) {
                    total_sorts = "";
                }
                String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                if ("null".equals(dsksorts)) {
                    dsksorts = "";
                }
                cell = new Cell(new Phrase((i + 1) + ""));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(tablesVO.get("access") + "", contextFont));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(tablesVO.get("locksheld") + "", contextFont));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(seqscans, contextFont));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(total_sorts, contextFont));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(dsksorts, contextFont));
                this.setCellFormat(cell, false);
                hhTable.addCell(cell);
            }
        }

        document.add(hhTable);

        // Informix
        Table lockTable = new Table(6);
        // float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f };
        // lockTable.setWidths(lockWidth);
        // lockTable.setWidth(100); //  90%
        // lockTable.setAlignment(Element.ALIGN_CENTER);// 
        // lockTable.setAutoFillEmptyCells(true); // 
        // lockTable.setBorderWidth(1); // 
        // lockTable.setBorderColor(new Color(0, 125, 255)); // 
        // lockTable.setPadding(2);// 
        // lockTable.setSpacing(0);// 
        // lockTable.setBorder(2);// 
        this.setTableFormat(lockTable);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setColspan(6);
        this.setCellFormat(cell, true);
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        lockTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        lockTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        lockTable.addCell(cell);
        // lockTable.endHeaders();
        List dblock = (ArrayList) dbinfo.get("lockList");// 
        if (dblock != null && dblock.size() > 0) {
            for (int i = 0; i < dblock.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblock.get(i);
                String type = (String) tablesVO.get("type");
                String desc = "";
                if ("B".equals(type)) {
                    desc = "";
                } else if ("IS".equals(type)) {
                    desc = "";
                } else if ("S".equals(type)) {
                    desc = "";
                } else if ("XS".equals(type)) {
                    desc = "";
                } else if ("U".equals(type)) {
                    desc = "";
                } else if ("IX".equals(type)) {
                    desc = "";
                } else if ("SIX".equals(type)) {
                    desc = "";
                } else if ("X".equals(type)) {
                    desc = "";
                } else if ("XR".equals(type)) {
                    desc = "";
                }
                cell = new Cell(new Phrase((i + 1) + ""));
                this.setCellFormat(cell, false);
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont));
                this.setCellFormat(cell, false);
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont));
                this.setCellFormat(cell, false);
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont));
                this.setCellFormat(cell, false);
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont));
                this.setCellFormat(cell, false);
                lockTable.addCell(cell);
                cell = new Cell(new Phrase(desc, contextFont));
                this.setCellFormat(cell, false);
                lockTable.addCell(cell);
            }
        }
        document.add(lockTable);

        // Informix
        Table logTable = new Table(9);
        this.setTableFormat(logTable);
        // float[] logWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f,
        // 220f, 220f };
        // logTable.setWidths(logWidth);
        // logTable.setWidth(100); //  90%
        // logTable.setAlignment(Element.ALIGN_CENTER);// 
        // logTable.setAutoFillEmptyCells(true); // 
        // logTable.setBorderWidth(1); // 
        // logTable.setBorderColor(new Color(0, 125, 255)); // 
        // logTable.setPadding(2);// 
        // logTable.setSpacing(0);// 
        // logTable.setBorder(2);// 
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setColspan(9);
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase("ID   ", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        logTable.addCell(cell);
        // logTable.endHeaders();
        List dblog = (ArrayList) dbinfo.get("informixlog");// 
        if (dblog != null && dblog.size() > 0) {
            for (int i = 0; i < dblog.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblog.get(i);
                cell = new Cell(new Phrase((i + 1) + ""));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("uniqid")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("size")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("used")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_used")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_current")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_backed_up")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_archived")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_temp")), contextFont));
                this.setCellFormat(cell, false);
                logTable.addCell(cell);
            }
        }
        document.add(logTable);

        // InformixIO
        Table ioTable = new Table(10);
        this.setTableFormat(ioTable);
        // float[] ioWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f,
        // 220f, 220f, 220f };
        // ioTable.setWidths(ioWidth);
        // ioTable.setWidth(100); //  90%
        // ioTable.setAlignment(Element.ALIGN_CENTER);// 
        // ioTable.setAutoFillEmptyCells(true); // 
        // ioTable.setBorderWidth(1); // 
        // ioTable.setBorderColor(new Color(0, 125, 255)); // 
        // ioTable.setPadding(2);// 
        // ioTable.setSpacing(0);// 
        // ioTable.setBorder(2);// 
        cell = new Cell(new Phrase("IO ", titleFont));
        cell.setColspan(10);
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase("   ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase("   ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase("   ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        ioTable.addCell(cell);
        // ioTable.endHeaders();
        List dbio = (ArrayList) dbinfo.get("iolist");// IO
        if (dbio != null && dbio.size() > 0) {
            for (int i = 0; i < dbio.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbio.get(i);
                cell = new Cell(new Phrase((i + 1) + ""));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("chunknum")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("reads")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("pagesread")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("writes")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("pageswritten")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mreads")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mpagesread")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mwrites")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
                cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mpageswritten")), contextFont));
                this.setCellFormat(cell, false);
                ioTable.addCell(cell);
            }
        }
        document.add(ioTable);

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            // img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        //    
        Table evenInfoTable = new Table(2);
        // float[] evenInfoWidths = { 220f, 220f };
        // evenInfoTable.setWidths(evenInfoWidths);
        // evenInfoTable.setWidth(100); //  90%
        // evenInfoTable.setAlignment(Element.ALIGN_CENTER);// 
        // evenInfoTable.setAutoFillEmptyCells(true); // 
        // evenInfoTable.setBorderWidth(1); // 
        // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // 
        // evenInfoTable.setPadding(2);// 
        // evenInfoTable.setSpacing(0);// 
        // evenInfoTable.setBorder(2);// 
        this.setTableFormat(evenInfoTable);
        String downnum = (String) reportHash.get("downnum");
        String count = (Integer) reportHash.get("count") + "";
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, true);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase(downnum, contextFont));
        this.setCellFormat(cell, false);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase(count, contextFont));
        this.setCellFormat(cell, false);
        evenInfoTable.addCell(cell);
        document.add(evenInfoTable);

        // 
        addEventListToDoc(document, titleFont, contextFont);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI Informixpdf/*from   w  w  w.  j a  va2 s  . c  om*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_InformixCldPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        PdfPTable aTable = new PdfPTable(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        //  document.add(aTable);
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable spaceTable = new PdfPTable(8);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();

        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    cell = new PdfPCell(new Phrase((i + 1) + ""));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("dbspace")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("owner")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("fname")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                }
            }
        }
        document.add(spaceTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable hhTable = new PdfPTable(8);
        float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        hhTable.setWidths(hhWidth);
        hhTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        // hhTable.endHeaders();

        List dbsession = (ArrayList) dbinfo.get("sessionList");// 
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                String seqscans = String.valueOf(tablesVO.get("seqscans"));
                if ("null".equals(seqscans)) {
                    seqscans = "";
                }
                String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                if ("null".equals(total_sorts)) {
                    total_sorts = "";
                }
                String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                if ("null".equals(dsksorts)) {
                    dsksorts = "";
                }
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tablesVO.get("access") + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tablesVO.get("locksheld") + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(seqscans));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(total_sorts));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(dsksorts));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
            }
        }
        document.add(hhTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable lockTable = new PdfPTable(6);
        float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f };
        lockTable.setWidths(lockWidth);
        lockTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        // lockTable.endHeaders();

        List dblock = (ArrayList) dbinfo.get("lockList");// 
        if (dblock != null && dblock.size() > 0) {
            for (int i = 0; i < dblock.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblock.get(i);
                String type = (String) tablesVO.get("type");
                String desc = "";
                if ("B".equals(type)) {
                    desc = "";
                } else if ("IS".equals(type)) {
                    desc = "";
                } else if ("S".equals(type)) {
                    desc = "";
                } else if ("XS".equals(type)) {
                    desc = "";
                } else if ("U".equals(type)) {
                    desc = "";
                } else if ("IX".equals(type)) {
                    desc = "";
                } else if ("SIX".equals(type)) {
                    desc = "";
                } else if ("X".equals(type)) {
                    desc = "";
                } else if ("XR".equals(type)) {
                    desc = "";
                }
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("dbsname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("tabname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(desc));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
            }
        }
        document.add(lockTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable logTable = new PdfPTable(9);
        float[] logWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        logTable.setWidths(logWidth);
        logTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setColspan(9);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("ID   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        // logTable.endHeaders();

        List dblog = (ArrayList) dbinfo.get("informixlog");// 
        if (dblog != null && dblog.size() > 0) {
            for (int i = 0; i < dblog.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblog.get(i);
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("uniqid"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("size"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("used"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_used"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_current"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_backed_up"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_archived"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_temp"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
            }
        }
        document.add(logTable);

        // InformixIO
        document.add(new Paragraph("\n"));
        PdfPTable ioTable = new PdfPTable(10);
        float[] ioWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        ioTable.setWidths(ioWidth);
        ioTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("IO   ", titleFont));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        // ioTable.endHeaders();

        List dbio = (ArrayList) dbinfo.get("iolist");// IO
        if (dbio != null && dbio.size() > 0) {
            for (int i = 0; i < dbio.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbio.get(i);
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("chunknum"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("reads"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("pagesread"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("writes"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("pageswritten"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mreads"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mpagesread"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mwrites"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mpageswritten"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
            }
        }
        document.add(ioTable);

        // 
        document.add(new Paragraph("\n"));
        PdfPTable eventTable = new PdfPTable(2);
        float[] eventWidths = { 220f, 220f };
        eventTable.setWidths(eventWidths);
        eventTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        document.add(eventTable);

        document.add(new Paragraph("\n"));
        // 
        addEventLisToPdf(document);
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI Informixexcel//from   w ww .j  a va2  s.co  m
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_InformixCldXls(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        // fileName = CommonAppUtil.getAppName() +
        // "/temp/hostnms_report.xls";
        wb = Workbook.createWorkbook(new File(filename));

        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        WritableSheet sheet = wb.createSheet(hostname + "", 0);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD,
                false);
        WritableCellFormat labelFormat = new WritableCellFormat(labelFont);

        WritableCellFormat _labelFormat = new WritableCellFormat();
        _labelFormat.setBackground(jxl.format.Colour.GRAY_25);

        WritableCellFormat p_labelFormat = new WritableCellFormat();
        p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE);

        WritableCellFormat b_labelFormat = new WritableCellFormat();
        b_labelFormat.setBackground(jxl.format.Colour.GRAY_50);

        Label tmpLabel = null;
        tmpLabel = new Label(1, 0, hostname + "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);

        tmpLabel = new Label(1, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);

        tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip
                + "ConnectUtilization" + ".png");
        // sheet,0,0,5,1,,,
        // allRow = allRow+2;
        sheet.addImage(new WritableImage(1, 6, 7, 7, file));
        // allRow = allRow+7;
        int row = 14;
        tmpLabel = new Label(0, row, "   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        // 
        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(1, row, (String) tablesVO.get("dbspace"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(2, row, (String) tablesVO.get("owner"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(3, row, (String) tablesVO.get("fname"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(4, row,
                            df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(5, row,
                            df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(6, row,
                            df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(7, row,
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%",
                            p_labelFormat);
                    sheet.addCell(tmpLabel);
                    row++;
                }
            }
        }
        row = row + 2;
        // Informix
        tmpLabel = new Label(0, row, "     ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List dbsession = (ArrayList) dbinfo.get("sessionList");// 
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                String seqscans = String.valueOf(tablesVO.get("seqscans"));
                if ("null".equals(seqscans)) {
                    seqscans = "";
                }
                String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                if ("null".equals(total_sorts)) {
                    total_sorts = "";
                }
                String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                if ("null".equals(dsksorts)) {
                    dsksorts = "";
                }
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, tablesVO.get("access") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, tablesVO.get("locksheld") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, seqscans, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, total_sorts, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, dsksorts, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        row = row + 2;
        // Informix
        tmpLabel = new Label(0, row, "    ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List dblock = (ArrayList) dbinfo.get("lockList");// 
        if (dblock != null && dblock.size() > 0) {
            for (int i = 0; i < dblock.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblock.get(i);
                String type = (String) tablesVO.get("type");
                String desc = "";
                if ("B".equals(type)) {
                    desc = "";
                } else if ("IS".equals(type)) {
                    desc = "";
                } else if ("S".equals(type)) {
                    desc = "";
                } else if ("XS".equals(type)) {
                    desc = "";
                } else if ("U".equals(type)) {
                    desc = "";
                } else if ("IX".equals(type)) {
                    desc = "";
                } else if ("SIX".equals(type)) {
                    desc = "";
                } else if ("X".equals(type)) {
                    desc = "";
                } else if ("XR".equals(type)) {
                    desc = "";
                }
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, tablesVO.get("dbsname") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, tablesVO.get("tabname") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, desc, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        row = row + 2;

        // Informix
        tmpLabel = new Label(0, row, "     ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "ID  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List dblog = (ArrayList) dbinfo.get("informixlog");// 
        if (dblog != null && dblog.size() > 0) {
            for (int i = 0; i < dblog.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblog.get(i);
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("uniqid")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("size")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("used")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("is_used")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("is_current")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("is_backed_up")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("is_archived")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, String.valueOf(tablesVO.get("is_temp")), p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        row = row + 2;

        // InformixIO
        tmpLabel = new Label(0, row, "IO ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, "   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, row, "   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(9, row, "    ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List dbio = (ArrayList) dbinfo.get("iolist");// IO
        if (dbio != null && dbio.size() > 0) {
            for (int i = 0; i < dbio.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbio.get(i);
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("chunknum")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("reads")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("pagesread")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("writes")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("pageswritten")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("mreads")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("mpagesread")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, String.valueOf(tablesVO.get("mwrites")), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, String.valueOf(tablesVO.get("mpageswritten")), p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        row = row + 2;

        //    
        tmpLabel = new Label(0, row, "     ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, reportHash.get("count") + "", p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        addEventListToExcel(sheet, row);

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
            sheet.addImage(wi);
        }
        wb.write();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI date 2010-11-11  pdf//from   ww  w  .  j  a va2  s. c o  m
 * @param filename
 */
public void createReportPingPdf(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL);
        String dbtype = (String) reportHash.get("dbtype");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(dbtype + "(" + ip + ")" + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        document.add(title);
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;
        Paragraph context = new Paragraph(contextString, contextFont1);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        PdfPTable aTable = new PdfPTable(4);
        float[] widths = { 220f, 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        cell = new PdfPCell(new Phrase(reportHash.get("pingnow") + "%"));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new PdfPCell(new Phrase((String) maxping.get("ping")));
        cell = new PdfPCell(new Phrase(reportHash.get("pingmin") + "%"));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(reportHash.get("avgpingcon") + "%"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.MIDDLE);// 
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 
            document.add(img1);
        }
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI excel/*from w ww .  j ava 2 s .com*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_EventXls(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    WritableWorkbook wb = null;
    try {
        wb = Workbook.createWorkbook(new File(filename));
        String hostname = (String) reportHash.get("dbname");
        WritableSheet sheet = wb.createSheet(hostname + "", 0);
        String ip = (String) reportHash.get("ip");
        String typename = (String) reportHash.get("typename");
        DBVo vo = (DBVo) reportHash.get("vo");
        String downnum = (String) reportHash.get("downnum");
        String count = (Integer) reportHash.get("count") + "";
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable maxping = (Hashtable) reportHash.get("ping");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String newip = doip(ip);

        WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD,
                false);
        WritableCellFormat labelFormat = new WritableCellFormat(labelFont);

        WritableCellFormat _labelFormat = new WritableCellFormat();
        _labelFormat.setBackground(jxl.format.Colour.GRAY_25);

        WritableCellFormat p_labelFormat = new WritableCellFormat();
        p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE);

        WritableCellFormat b_labelFormat = new WritableCellFormat();
        b_labelFormat.setBackground(jxl.format.Colour.GRAY_50);
        WritableCellFormat red_labelFormat = new WritableCellFormat();
        red_labelFormat.setBackground(jxl.format.Colour.RED);

        WritableCellFormat orange_labelFormat = new WritableCellFormat();
        orange_labelFormat.setBackground(jxl.format.Colour.ORANGE);

        WritableCellFormat yellow_labelFormat = new WritableCellFormat();
        yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW);

        Label tmpLabel = null;
        tmpLabel = new Label(1, 0, hostname + "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime);
        sheet.addCell(tmpLabel);

        // ip
        tmpLabel = new Label(0, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 4, "IP", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 5, ip, p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 5, typename, p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 5, downnum, p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 5, count, p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        int row = 7;
        tmpLabel = new Label(0, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        int index = 0;
        java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
        List list = (ArrayList) reportHash.get("list");
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                index++;
                EventList eventlist = (EventList) list.get(i);
                Date cc = eventlist.getRecordtime().getTime();
                Integer eventid = eventlist.getId();
                String eventlocation = eventlist.getEventlocation();
                String content = eventlist.getContent();
                String level = String.valueOf(eventlist.getLevel1());
                String status = String.valueOf(eventlist.getManagesign());
                String s = status;
                String showlevel = null;
                String act = "";
                if ("1".equals(level)) {
                    showlevel = "";
                } else if ("2".equals(level)) {
                    showlevel = "";
                } else {
                    showlevel = "";
                }
                if ("0".equals(status)) {
                    status = "";
                }
                if ("1".equals(status)) {
                    status = "";
                }
                if ("2".equals(status)) {
                    status = "";
                }
                String rptman = eventlist.getReportman();
                String rtime1 = _sdf.format(cc);

                tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat);
                sheet.addCell(tmpLabel);
                if ("3".equals(level)) {
                    tmpLabel = new Label(1, row, showlevel, red_labelFormat);
                    sheet.addCell(tmpLabel);
                } else if ("2".equals(level)) {
                    tmpLabel = new Label(1, row, showlevel, orange_labelFormat);
                    sheet.addCell(tmpLabel);
                } else {
                    tmpLabel = new Label(1, row, showlevel, yellow_labelFormat);
                    sheet.addCell(tmpLabel);
                }
                tmpLabel = new Label(2, row, content, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, rtime1, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, rptman, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, status, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
            sheet.addImage(wi);
        }
        wb.write();
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI MySQL doc/*from   w w  w .j a v a2  s .c  o m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportMySQLSelfDoc(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Vector val = (Vector) reportHash.get("Val");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        Table aTable = new Table(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidth(100); //  90%
        aTable.setAlignment(Element.ALIGN_CENTER);// 
        aTable.setAutoFillEmptyCells(true); // 
        aTable.setBorderWidth(1); // 
        aTable.setBorderColor(new Color(0, 125, 255)); // 
        aTable.setPadding(2);// 
        aTable.setSpacing(0);// 
        aTable.setBorder(2);// 
        aTable.endHeaders();
        Cell cell = null;
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        // 

        document.add(aTable);
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        document.add(img);

        document.add(new Paragraph("\n"));
        Table aTable1 = new Table(2);
        float[] width = { 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidth(100); //  90%
        aTable1.setAlignment(Element.ALIGN_CENTER);// 
        aTable1.setAutoFillEmptyCells(true); // 
        aTable1.setBorderWidth(1); // 
        aTable1.setBorderColor(new Color(0, 125, 255)); // 
        aTable1.setPadding(2);// 
        aTable1.setSpacing(0);// 
        aTable1.setBorder(2);// 
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // 
        if (val != null && val.size() > 0) {
            for (int i = 0; i < val.size(); i++) {
                Hashtable return_value = (Hashtable) val.get(i);
                if (return_value != null && return_value.size() > 0) {
                    String name = return_value.get("variable_name").toString();
                    String value = return_value.get("value").toString();
                    if (name.equalsIgnoreCase("Max_used_connections")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_first")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_key")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_prev")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd")) {
                        name = "H";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Open_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Opened_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_cached")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_connected")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_created")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_running")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_immediate")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_waited")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_read_requests")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_reads")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("log_slow_queries")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("slow_launch_time")) {
                        name = "Slow_launch_threads";
                    }
                    cell = new Cell(new Phrase(name, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(value, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                }
            }
        }
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.add(aTable1);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI MySQL xls//  w  w  w.  j  a v  a2s .  c  om
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportMySQLSelfExcel(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        // fileName = CommonAppUtil.getAppName() +
        // "/temp/hostnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));

        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        WritableSheet sheet = wb.createSheet(hostname + "", 0);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Vector val = (Vector) reportHash.get("Val");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD,
                false);
        WritableCellFormat labelFormat = new WritableCellFormat(labelFont);

        WritableCellFormat _labelFormat = new WritableCellFormat();
        _labelFormat.setBackground(jxl.format.Colour.GRAY_25);

        WritableCellFormat p_labelFormat = new WritableCellFormat();
        p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE);

        WritableCellFormat b_labelFormat = new WritableCellFormat();
        b_labelFormat.setBackground(jxl.format.Colour.GRAY_50);

        Label tmpLabel = null;
        tmpLabel = new Label(1, 0, hostname + "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);

        tmpLabel = new Label(1, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);

        tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip
                + "ConnectUtilization" + ".png");
        // sheet,0,0,5,1,,,
        // allRow = allRow+2;
        sheet.addImage(new WritableImage(1, 6, 7, 7, file));
        // allRow = allRow+7;

        tmpLabel = new Label(0, 14, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        int row = 15;
        if (val != null && val.size() > 0) {
            for (int i = 0; i < val.size(); i++) {
                Hashtable return_value = (Hashtable) val.get(i);
                if (return_value != null && return_value.size() > 0) {
                    String name = return_value.get("variable_name").toString();
                    String value = return_value.get("value").toString();
                    if (name.equalsIgnoreCase("Max_used_connections")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_first")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_key")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_prev")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd")) {
                        name = "H";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Open_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Opened_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_cached")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_connected")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_created")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_running")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_immediate")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_waited")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_read_requests")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_reads")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("log_slow_queries")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("slow_launch_time")) {
                        name = "Slow_launch_threads";
                    }
                    tmpLabel = new Label(0, row, name, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(1, row, value, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    row++;
                }
            }
        }

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
            sheet.addImage(wi);
        }
        wb.write();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI MySQL pdf// w ww. ja v a  2 s. c  o  m
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportMySQLSelfPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Vector val = (Vector) reportHash.get("Val");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        PdfPTable aTable = new PdfPTable(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        //  document.add(aTable);
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);

        document.add(new Paragraph("\n"));
        PdfPTable aTable1 = new PdfPTable(2);
        float[] width = { 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("     ", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        if (val != null && val.size() > 0) {
            for (int i = 0; i < val.size(); i++) {
                Hashtable return_value = (Hashtable) val.get(i);
                if (return_value != null && return_value.size() > 0) {
                    String name = return_value.get("variable_name").toString();
                    String value = return_value.get("value").toString();
                    if (name.equalsIgnoreCase("Max_used_connections")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_first")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_key")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_prev")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd")) {
                        name = "H";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Open_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Opened_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_cached")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_connected")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_created")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_running")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_immediate")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_waited")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_read_requests")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_reads")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("log_slow_queries")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("slow_launch_time")) {
                        name = "Slow_launch_threads";
                    }
                    cell = new PdfPCell(new Phrase(name, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new PdfPCell(new Phrase(value));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    // aTable1.endHeaders();
                }
            }
        }

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.add(aTable1);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}