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

public void createReport_db2PDF(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;//from   w ww.java  2  s . c om
        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 hostname = (String) reportHash.get("dbname");
        String servername = (String) reportHash.get("servername");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable returnhash = (Hashtable) reportHash.get("returnhash");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);

        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"));
        /*
         * 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(""));
        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);// 
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));
        Enumeration dbs = returnhash.keys();
        List retList = new ArrayList();
        Paragraph context1 = null;
        PdfPTable aTable1 = null;

        while (dbs.hasMoreElements()) {

            aTable1 = new PdfPTable(6);
            float[] width = { 220f, 220f, 220f, 220f, 220f, 220f };
            aTable1.setWidths(width);
            aTable1.setWidthPercentage(100);
            cell = new PdfPCell(new Phrase("", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase("", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase("", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase("MB", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase("MB", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase("(%)", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            // aTable1.endHeaders();

            // 
            String obj = (String) dbs.nextElement();
            retList = (List) returnhash.get(obj);
            String contextString1 = "DB2:" + obj + "(" + "IP:" + ip + ")";

            context1 = new Paragraph(contextString1, contextFont);
            // 
            context1.setAlignment(Element.ALIGN_LEFT);
            // context.setFont(contextFont);
            // 
            context1.setSpacingBefore(5);
            // 
            context1.setFirstLineIndent(5);
            int row = 1;
            for (int i = 0; i < retList.size(); i++) {
                Hashtable ht = (Hashtable) retList.get(i);
                if (ht == null)
                    continue;
                String spacename = "";
                if (ht.get("tablespace_name") != null)
                    spacename = ht.get("tablespace_name").toString();
                String size = "";
                if (ht.get("totalspac") != null)
                    size = ht.get("totalspac").toString();
                String free = "";
                if (ht.get("usablespac") != null)
                    free = ht.get("usablespac").toString();
                String percent = "";
                if (ht.get("usableper") != null)
                    percent = ht.get("usableper").toString();
                cell = new PdfPCell(new Phrase(""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(i + 1 + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(spacename));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(size));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(free));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(percent));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);

            }
            document.add(context1);
            document.add(new Paragraph("\n"));
            document.add(aTable1);
        }

        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) {
        // TODO: handle exception
    }
}

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

public void createReport_infor(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//from ww w .j a v  a 2  s. c  om
        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");
        ArrayList dbspaces = new ArrayList();
        dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        Hashtable maxping = (Hashtable) reportHash.get("ping");
        ArrayList dbsession = new ArrayList();
        dbsession = (ArrayList) dbinfo.get("sessionList");// 
        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, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", _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);
        tmpLabel = new Label(1, 14, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 14, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 14, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 14, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, 14, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, 14, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, 14, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, 14, "(%)", _labelFormat);
        sheet.addCell(tmpLabel);

        int row = 14;
        int row1 = 0;
        // 
        if (dbspaces != null && dbspaces.size() > 0) {
            for (int i = 0; i < dbspaces.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                double all = 100.00;
                double show = all - Double.parseDouble(tablesVO.get("percent_free").toString());
                String str = show + "";
                if (str.length() > 5) {
                    str = str.substring(0, 5);
                }
                row = row + (i);
                tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 15 + i, (String) tablesVO.get("dbspace"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 15 + i, (String) tablesVO.get("owner"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, 15 + i, (String) tablesVO.get("fname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 15 + i, (String) tablesVO.get("pages_size"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, 15 + i, (String) tablesVO.get("pages_used"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, 15 + i, (String) tablesVO.get("pages_free"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, 15 + i, str, p_labelFormat);

                sheet.addCell(tmpLabel);
                row1++;
            }
        }

        row1 = 15 + row1;
        // 
        tmpLabel = new Label(0, row1 + 1, "INFORMIX", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row1 + 1, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row1 + 1, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(9, row1 + 1, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(10, row1 + 1, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(11, row1 + 1, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(12, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(13, row1 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        int row2 = row1 + 2;
        int row3 = 0;
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {

                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                tmpLabel = new Label(1, row2 + i, i + 1 + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row2 + i, (String) tablesVO.get("username"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row2 + i, (String) tablesVO.get("hostname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row2 + i, (String) tablesVO.get("access"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row2 + i, ((Integer) tablesVO.get("lockreqs")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row2 + i, ((Integer) tablesVO.get("locksheld")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row2 + i, ((Integer) tablesVO.get("lockwts")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row2 + i, ((Integer) tablesVO.get("deadlks")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row2 + i, ((Integer) tablesVO.get("lktouts")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(10, row2 + i, ((Integer) tablesVO.get("bufreads")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(11, row2 + i, ((Integer) tablesVO.get("bufwrites")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(12, row2 + i, ((Integer) tablesVO.get("pagreads")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(13, row2 + i, ((Integer) tablesVO.get("pagwrites")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                row3++;
            }
        }

        int row4 = row3 + row2;
        int row5 = 0;
        tmpLabel = new Label(0, row4 + 1, "INFORMIX", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row4 + 1, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row4 + 1, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row4 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row4 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row4 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row4 + 1, "", _labelFormat);
        sheet.addCell(tmpLabel);
        // 
        ArrayList dblock = new ArrayList();
        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(1, row4 + 2 + i, i + 1 + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row4 + 2 + i, (String) tablesVO.get("username"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row4 + 2 + i, (String) tablesVO.get("hostname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row4 + 2 + i, (String) tablesVO.get("dbsname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row4 + 2 + i, (String) tablesVO.get("tabname"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row4 + 2 + i, (String) tablesVO.get("desc"), p_labelFormat);
                sheet.addCell(tmpLabel);
                row5++;
            }
        }
        // end
        // informix 
        int row6 = row5 + row4 + 3;
        int row7 = 0;
        tmpLabel = new Label(0, row6, "INFORMIX", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row6, "ID", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row6, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row6, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row6, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row6, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row6, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row6, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, row6, "", _labelFormat);
        sheet.addCell(tmpLabel);
        ArrayList dblog = new ArrayList();
        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(1, row6 + 1 + i, ((Integer) tablesVO.get("uniqid")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row6 + 1 + i, ((Integer) tablesVO.get("size")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row6 + 1 + i, ((Integer) tablesVO.get("used")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row6 + 1 + i, (String) tablesVO.get("is_used"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row6 + 1 + i, (String) tablesVO.get("is_current"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row6 + 1 + i, (String) tablesVO.get("is_backed_up"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row6 + 1 + i, (String) tablesVO.get("is_archived"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row6 + 1 + i, (String) tablesVO.get("is_temp"), p_labelFormat);
                sheet.addCell(tmpLabel);
                row7++;
            }
        }
        //  end
        // informix i/o
        int row8 = row7 + row6 + 2;
        tmpLabel = new Label(0, row8, "INFORMIXI/O", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row8, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row8, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row8, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row8, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row8, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row8, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row8, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, row8, " ", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(9, row8, "", _labelFormat);
        sheet.addCell(tmpLabel);
        ArrayList dbio = new ArrayList();
        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(1, row8 + 1 + i, (String) tablesVO.get("chunknum"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row8 + 1 + i, ((Integer) tablesVO.get("reads")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row8 + 1 + i, ((Integer) tablesVO.get("pagesread")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row8 + 1 + i, ((Integer) tablesVO.get("writes")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row8 + 1 + i, ((Integer) tablesVO.get("pageswritten")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row8 + 1 + i, ((Integer) tablesVO.get("mreads")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row8 + 1 + i, ((Integer) tablesVO.get("mpagesread")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row8 + 1 + i, ((Integer) tablesVO.get("mwrites")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row8 + 1 + i, ((Integer) tablesVO.get("mpageswritten")).intValue() + "",
                        p_labelFormat);
                sheet.addCell(tmpLabel);

            }
        }
        // end
        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

public void createReport_inforDoc(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;//from w  ww . j  ava2 s .  c o m
        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);
        Hashtable dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        ArrayList dbspaces = new ArrayList();
        dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        Hashtable maxping = (Hashtable) reportHash.get("ping");
        ArrayList dbsession = new ArrayList();
        dbsession = (ArrayList) dbinfo.get("sessionList");// 
        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");

        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("");
        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);

        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.LEFT);// 
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));
        // informix 
        Table aTable1 = new Table(9);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 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.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        int row = 0;
        if (dbspaces != null && dbspaces.size() > 0) {
            for (int i = 0; i < dbspaces.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                double all = 100.00;
                double show = all - Double.parseDouble(tablesVO.get("percent_free").toString());
                String str = show + "";
                if (str.length() > 5) {
                    str = str.substring(0, 5);
                }
                aTable1.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new Cell(new Phrase(rowStr, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("pages_size"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("pages_used"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("pages_free"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(str, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
            }
        }
        // informix
        Table aTable2 = new Table(9);
        float[] widthss = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        aTable2.setWidths(widthss);
        aTable2.setWidth(100); //  90%
        aTable2.setAlignment(Element.ALIGN_CENTER);// 
        aTable2.setAutoFillEmptyCells(true); // 
        aTable2.setBorderWidth(1); // 
        aTable2.setBorderColor(new Color(0, 125, 255)); // 
        aTable2.setPadding(2);// 
        aTable2.setSpacing(0);// 
        aTable2.setBorder(2);// 
        cell = new Cell(new Phrase("INFORMIX", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("ID", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);

        ArrayList dblog = new ArrayList();
        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);

                aTable2.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new Cell(new Phrase(((Integer) tablesVO.get("uniqid")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("size")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("used")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("is_used"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("is_current"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("is_backed_up"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("is_archived"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("is_temp"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
            }
        }
        // end 
        // --
        Table aTable3 = new Table(14);
        float[] widths1 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f,
                220f };
        aTable3.setWidths(widths1);
        aTable3.setWidth(100); //  90%
        aTable3.setAlignment(Element.ALIGN_CENTER);// 
        aTable3.setAutoFillEmptyCells(true); // 
        aTable3.setBorderWidth(1); // 
        aTable3.setBorderColor(new Color(0, 125, 255)); // 
        aTable3.setPadding(2);// 
        aTable3.setSpacing(0);// 
        aTable3.setBorder(2);// 

        cell = new Cell(new Phrase("INFORMIX", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        int row3 = 0;
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {

                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                aTable3.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new Cell(new Phrase(i + 1 + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("access"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("lockreqs")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("locksheld")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("lockwts")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("deadlks")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("lktouts")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("bufreads")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("bufwrites")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("pagreads")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("pagwrites")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
            }
        }

        // int row4 = row3 + row2;
        int row5 = 0;
        Table aTable4 = new Table(7);
        float[] widths2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        aTable4.setWidths(widths2);
        aTable4.setWidth(100); //  90%
        aTable4.setAlignment(Element.ALIGN_CENTER);// 
        aTable4.setAutoFillEmptyCells(true); // 
        aTable4.setBorderWidth(1); // 
        aTable4.setBorderColor(new Color(0, 125, 255)); // 
        aTable4.setPadding(2);// 
        aTable4.setSpacing(0);// 
        aTable4.setBorder(2);// 
        // 
        cell = new Cell(new Phrase("INFORMIX", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        ArrayList dblock = new ArrayList();
        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 = "";
                }

                aTable4.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new Cell(new Phrase(i + 1 + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("desc"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
            }
        }
        // informix i/o
        Table aTable5 = new Table(10);
        float[] widths3 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        aTable5.setWidths(widths3);
        aTable5.setWidth(100); //  90%
        aTable5.setAlignment(Element.ALIGN_CENTER);// 
        aTable5.setAutoFillEmptyCells(true); // 
        aTable5.setBorderWidth(1); // 
        aTable5.setBorderColor(new Color(0, 125, 255)); // 
        aTable5.setPadding(2);// 
        aTable5.setSpacing(0);// 
        aTable5.setBorder(2);// 
        cell = new Cell(new Phrase("INFORMIXI/O", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        ArrayList dbio = new ArrayList();
        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);
                aTable5.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new Cell(new Phrase((String) tablesVO.get("chunknum"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("reads")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("pagesread")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("writes")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(
                        new Phrase(((Integer) tablesVO.get("pageswritten")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("mreads")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(
                        new Phrase(((Integer) tablesVO.get("mpagesread")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(new Phrase(((Integer) tablesVO.get("mwrites")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new Cell(
                        new Phrase(((Integer) tablesVO.get("mpageswritten")).intValue() + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.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.add(aTable2);
        document.add(aTable3);
        document.add(aTable4);
        document.add(aTable5);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }

}

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

public void createReport_inforPDF(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;/*www . ja  va 2 s. com*/
        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 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");
        ArrayList dbspaces = new ArrayList();
        dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        Hashtable maxping = (Hashtable) reportHash.get("ping");
        ArrayList dbsession = new ArrayList();
        dbsession = (ArrayList) dbinfo.get("sessionList");// 

        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"));
        /*
         * 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(""));
        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.MIDDLE);// 
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));
        // informix 
        PdfPTable aTable1 = new PdfPTable(9);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidthPercentage(100);

        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // informix 
        int row = 0;
        if (dbspaces != null && dbspaces.size() > 0) {
            for (int i = 0; i < dbspaces.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                double all = 100.00;
                double show = all - Double.parseDouble(tablesVO.get("percent_free").toString());
                String str = show + "";
                if (str.length() > 5) {
                    str = str.substring(0, 5);
                }
                aTable1.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new PdfPCell(new Phrase(rowStr));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("dbspace")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("owner")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("fname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("pages_size")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("pages_used")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("pages_free")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(str));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
            }
        }
        // informix
        PdfPTable aTable2 = new PdfPTable(9);
        float[] widthss = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        aTable2.setWidths(widthss);
        aTable2.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("ID", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable2.addCell(cell);

        ArrayList dblog = new ArrayList();
        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);

                aTable2.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("uniqid")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("size")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("used")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("is_used")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("is_current")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("is_backed_up")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("is_archived")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("is_temp")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable2.addCell(cell);
            }
        }
        // end 
        // --
        PdfPTable aTable3 = new PdfPTable(14);
        float[] widths1 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f,
                220f };
        aTable3.setWidths(widths1);
        aTable3.setWidthPercentage(100);

        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable3.addCell(cell);
        int row3 = 0;
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {

                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                aTable3.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new PdfPCell(new Phrase(i + 1 + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("access")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("lockreqs")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("locksheld")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("lockwts")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("deadlks")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("lktouts")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("bufreads")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("bufwrites")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pagreads")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pagwrites")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable3.addCell(cell);
            }
        }

        // int row4 = row3 + row2;
        int row5 = 0;
        PdfPTable aTable4 = new PdfPTable(7);
        float[] widths2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        aTable4.setWidths(widths2);
        aTable4.setWidthPercentage(100);
        // 
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable4.addCell(cell);
        ArrayList dblock = new ArrayList();
        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 = "";
                }

                aTable4.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new PdfPCell(new Phrase(i + 1 + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("dbsname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("tabname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("desc")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable4.addCell(cell);
            }
        }
        // informix i/o
        PdfPTable aTable5 = new PdfPTable(10);
        float[] widths3 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        aTable5.setWidths(widths3);
        aTable5.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("I/O", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable5.addCell(cell);
        ArrayList dbio = new ArrayList();
        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);
                aTable5.addCell("");
                row = i + 1;
                String rowStr = "" + row;
                cell = new PdfPCell(new Phrase((String) tablesVO.get("chunknum")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("reads")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pagesread")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("writes")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pageswritten")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mreads")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mpagesread")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mwrites")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.addCell(cell);
                cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mpageswritten")).intValue() + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable5.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.add(new Paragraph("\n"));
        document.add(aTable2);
        document.add(new Paragraph("\n"));
        document.add(aTable3);
        document.add(new Paragraph("\n"));
        document.add(aTable4);
        document.add(new Paragraph("\n"));
        document.add(aTable5);
        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 sqlserverword/*www .  j  av  a2  s. c  om*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_SqlServerCldDoc(String filename, String type) throws IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        if ("pdf".equals(type)) {
            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");
        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);
        this.setTableFormat(aTable);
        // 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));
        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"));

        //  
        Table dbInfoTable = new Table(5);
        this.setTableFormat(dbInfoTable);
        // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f };
        // dbInfoTable.setWidths(dbInfoWidths);
        // dbInfoTable.setWidth(100); //  90%
        // dbInfoTable.setAlignment(Element.ALIGN_CENTER);// 
        // dbInfoTable.setAutoFillEmptyCells(true); // 
        // dbInfoTable.setBorderWidth(1); // 
        // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // 
        // dbInfoTable.setPadding(2);// 
        // dbInfoTable.setSpacing(0);// 
        // dbInfoTable.setBorder(2);// 
        Hashtable mems = (Hashtable) reportHash.get("mems");// 
        cell = new Cell(new Phrase("(KB)", titleFont));
        cell.setColspan(5);
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("SQL", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) mems.get("totalMemory"), contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) mems.get("optMemory"), contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) mems.get("conMemory"), contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) mems.get("sqlMem"), contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) mems.get("lockMem"), contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        document.add(dbInfoTable);

        // 
        Table sysInfoTable = new Table(4);
        this.setTableFormat(sysInfoTable);
        // float[] sysInfoWidths = { 220f, 220f, 220f, 220f };
        // dbInfoTable.setWidths(dbInfoWidths);
        // sysInfoTable.setWidth(100); //  90%
        // sysInfoTable.setAlignment(Element.ALIGN_CENTER);// 
        // sysInfoTable.setAutoFillEmptyCells(true); // 
        // sysInfoTable.setBorderWidth(1); // 
        // sysInfoTable.setBorderColor(new Color(0, 125, 255)); // 
        // sysInfoTable.setPadding(2);// 
        // sysInfoTable.setSpacing(0);// 
        // sysInfoTable.setBorder(2);// 
        Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// 
        cell = new Cell(new Phrase("(KB)", titleFont));
        cell.setColspan(4);
        this.setCellFormat(cell, true);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) sysValue.get("productlevel"), contextFont));
        this.setCellFormat(cell, false);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) sysValue.get("IsIntegratedSecurityOnly"), contextFont));
        this.setCellFormat(cell, false);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) sysValue.get("IsSingleUser"), contextFont));
        this.setCellFormat(cell, false);
        sysInfoTable.addCell(cell);
        cell = new Cell(new Phrase((String) sysValue.get("IsClustered"), contextFont));
        this.setCellFormat(cell, false);
        sysInfoTable.addCell(cell);
        document.add(sysInfoTable);

        Table aTable1 = new Table(6);
        this.setTableFormat(aTable1);
        float[] width = { 220f, 220f, 330f, 220f, 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(6);
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v");
        Hashtable alldatabase = new Hashtable();
        if (dbValue.get("database") != null)
            alldatabase = (Hashtable) dbValue.get("database");
        Vector names = new Vector();
        if (dbValue.get("names") != null)
            names = (Vector) dbValue.get("names");

        if (alldatabase != null && alldatabase.size() > 0) {
            if (names == null)
                names = new Vector();
            int row = 1;
            for (int i = 0; i < names.size(); i++) {
                String key = (String) names.get(i);
                if (alldatabase.get(key) == null)
                    continue;
                Hashtable data = (Hashtable) alldatabase.get(key);
                String dbname = data.get("dbname").toString();
                String size = data.get("size").toString();
                String usedsize = "";
                if (data.get("usedsize") != null) {
                    usedsize = data.get("usedsize").toString();
                }
                String usedperc = "";
                if (data.get("usedperc") != null)
                    usedperc = data.get("usedperc").toString();
                cell = new Cell(new Phrase(""));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(row + "", titleFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(dbname, titleFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(size, titleFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(usedsize, titleFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(usedperc, titleFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                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) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.add(aTable1);

        //    
        Table evenInfoTable = new Table(2);
        this.setTableFormat(evenInfoTable);
        // 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);// 
        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("", e);
    }
}

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

/**
 * @author HONGLI sqlserverpdf/*  w ww.  j  a  v a  2 s . c  om*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_SqlServerCldPdf(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 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");
        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);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        // 
        PdfPTable dbTable = new PdfPTable(5);
        float[] cellWidths = { 220f, 220f, 220f, 220f, 220f };
        dbTable.setWidths(cellWidths);
        dbTable.setWidthPercentage(100);
        PdfPCell dbCell = null;
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setColspan(5);
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("IP", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(vo.getDbName(), contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(ip, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(typename, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(runstr, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(grade, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);

        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.setColspan(3);
        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(pingnow + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(pingmin + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(pingconavg + "%", contextFont));
        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.setAbsolutePosition(0, 0);
        img.scalePercent(76);
        img.setAlignment(Image.MIDDLE);// 
        document.add(dbTable);
        document.add(new Paragraph("\n"));
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));

        // (KB)
        PdfPTable dbInfoTable = new PdfPTable(5);
        float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f };
        dbInfoTable.setWidths(dbInfoWidths);
        dbInfoTable.setWidthPercentage(100);
        Hashtable mems = (Hashtable) reportHash.get("mems");// 
        cell = new PdfPCell(new Phrase("(KB)", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("SQL", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) mems.get("totalMemory"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) mems.get("optMemory"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) mems.get("conMemory"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) mems.get("sqlMem"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) mems.get("lockMem"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        document.add(dbInfoTable);
        document.add(new Paragraph("\n"));

        // (KB)
        PdfPTable ncTable = new PdfPTable(4);
        float[] ncWidths = { 220f, 220f, 220f, 220f };
        ncTable.setWidths(ncWidths);
        ncTable.setWidthPercentage(100);
        Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// 
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) sysValue.get("productlevel"), titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) sysValue.get("IsIntegratedSecurityOnly"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) sysValue.get("IsSingleUser"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) sysValue.get("IsClustered"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        document.add(ncTable);
        document.add(new Paragraph("\n"));

        PdfPTable aTable1 = new PdfPTable(6);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v");
        Hashtable alldatabase = new Hashtable();
        if (dbValue.get("database") != null)
            alldatabase = (Hashtable) dbValue.get("database");
        Vector names = new Vector();
        if (dbValue.get("names") != null)
            names = (Vector) dbValue.get("names");

        if (alldatabase != null && alldatabase.size() > 0) {
            if (names == null)
                names = new Vector();
            int row = 1;
            for (int i = 0; i < names.size(); i++) {
                String key = (String) names.get(i);
                if (alldatabase.get(key) == null)
                    continue;
                Hashtable data = (Hashtable) alldatabase.get(key);
                String dbname = data.get("dbname").toString();
                String size = data.get("size").toString();
                String usedsize = "";
                if (data.get("usedsize") != null) {
                    usedsize = data.get("usedsize").toString();
                }
                String usedperc = "";
                if (data.get("usedperc") != null)
                    usedperc = data.get("usedperc").toString();
                cell = new PdfPCell(new Phrase(""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(row + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(dbname));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(size));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(usedsize));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(usedperc));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                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) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.add(aTable1);
        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);

        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 sqlserverexcel/*from ww w  . j a  v  a  2s  .  c  o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_SqlServerCldXls(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");
        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 mems = (Hashtable) reportHash.get("mems");// 
        Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// 
        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");
        String pingconavg = (String) reportHash.get("pingconavg");
        DBVo vo = (DBVo) reportHash.get("vo");
        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);

        // 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, runstr, p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 5, grade, p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        tmpLabel = new Label(0, 7, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 7, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 7, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 8, pingconavg + "%", 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, 9, 7, 7, file));
        // allRow = allRow+7;

        // 
        tmpLabel = new Label(0, 16, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 16, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 16, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 16, "SQL", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 16, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 17, (String) mems.get("totalMemory"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 17, (String) mems.get("optMemory"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 17, (String) mems.get("conMemory"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 17, (String) mems.get("sqlMem"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 17, (String) mems.get("lockMem"), p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        tmpLabel = new Label(0, 19, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 19, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 19, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 19, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 20, (String) sysValue.get("productlevel"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 20, (String) sysValue.get("IsIntegratedSecurityOnly"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 20, (String) sysValue.get("IsSingleUser"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 20, (String) sysValue.get("IsClustered"), p_labelFormat);
        sheet.addCell(tmpLabel);

        // 
        tmpLabel = new Label(0, 22, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 22, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 22, "(MB)", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 22, "(MB)", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 22, "(%)", b_labelFormat);
        sheet.addCell(tmpLabel);

        int row = 22;
        // 
        Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v");
        Hashtable alldatabase = new Hashtable();
        if (dbValue.get("database") != null)
            alldatabase = (Hashtable) dbValue.get("database");
        Vector names = new Vector();
        if (dbValue.get("names") != null)
            names = (Vector) dbValue.get("names");

        if (alldatabase != null && alldatabase.size() > 0) {
            if (names == null)
                names = new Vector();
            for (int i = 0; i < names.size(); i++) {
                String key = (String) names.get(i);
                if (alldatabase.get(key) == null)
                    continue;
                Hashtable data = (Hashtable) alldatabase.get(key);
                String dbname = data.get("dbname").toString();
                String size = data.get("size").toString();
                String usedsize = "";
                if (data.get("usedsize") != null) {
                    usedsize = data.get("usedsize").toString();
                }
                String usedperc = "";
                if (data.get("usedperc") != null)
                    usedperc = data.get("usedperc").toString();
                row = row + 1;
                tmpLabel = new Label(0, row, i + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, dbname, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, size, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, usedsize, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, usedperc, p_labelFormat);
                sheet.addCell(tmpLabel);
            }
        }
        //    
        row = row + 2;
        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("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

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

/**
 * @author HONGLI DB2 doc/*w  w w .ja  v a  2 s  . c o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportDB2SelfDoc(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");

        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(5);
        float[] width = { 220f, 220f, 220f, 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.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");
        if (spaceInfo.get("toolsdb") != null) {
            List toolsdb = (ArrayList) spaceInfo.get("toolsdb");// 
            if (toolsdb != null && toolsdb.size() > 0) {
                for (int i = 0; i < toolsdb.size(); i++) {
                    Hashtable tempSpace = (Hashtable) toolsdb.get(i);
                    String SYSCATSPACE = tempSpace.get("tablespace_name") + "";
                    String totalspac = tempSpace.get("totalspac") + "";
                    String usablespac = tempSpace.get("usablespac") + "";
                    String usableper = (String) tempSpace.get("usableper");

                    if (usableper == null || usableper.trim().equals("")) {
                        usableper = "0";
                    }
                    cell = new Cell(new Phrase((i + 1) + "", titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(SYSCATSPACE, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(totalspac, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(usablespac, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(usableper, titleFont));
                    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 DB2 xls/*  ww  w  . jav  a2 s .c  o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportDB2SelfExcel(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 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, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", _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);
        tmpLabel = new Label(1, 14, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 14, "(MB)", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 14, "(MB)", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 14, "(%)", _labelFormat);
        sheet.addCell(tmpLabel);
        int row = 14;

        // 
        Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");
        Iterator iterator = spaceInfo.keySet().iterator();
        while (iterator.hasNext()) {
            String dbName = (String) iterator.next();
            List toolsdb = (ArrayList) spaceInfo.get(dbName);
            if (toolsdb != null && toolsdb.size() > 0) {
                for (int i = 0; i < toolsdb.size(); i++) {
                    Hashtable tempSpace = (Hashtable) toolsdb.get(i);
                    String SYSCATSPACE = tempSpace.get("tablespace_name") + "";
                    String totalspac = tempSpace.get("totalspac") + "";
                    String usablespac = tempSpace.get("usablespac") + "";
                    String usableper = (String) tempSpace.get("usableper");
                    if (usableper == null || usableper.trim().equals("")) {
                        usableper = "0";
                    }
                    row = row + 1;
                    tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(1, row, SYSCATSPACE, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(2, row, totalspac, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(3, row, usablespac, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(4, row, usableper, p_labelFormat);
                    sheet.addCell(tmpLabel);
                }
            }
        }

        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 DB2 pdf//from   www  .  j a  v  a 2 s. co m
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportDB2SelfPdf(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 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(5);
        float[] width = { 220f, 220f, 220f, 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");
        Iterator iterator = spaceInfo.keySet().iterator();
        while (iterator.hasNext()) {
            String dbName = (String) iterator.next();
            List toolsdb = (ArrayList) spaceInfo.get(dbName);
            if (toolsdb != null && toolsdb.size() > 0) {
                for (int i = 0; i < toolsdb.size(); i++) {
                    Hashtable tempSpace = (Hashtable) toolsdb.get(i);
                    String SYSCATSPACE = tempSpace.get("tablespace_name") + "";
                    String totalspac = tempSpace.get("totalspac") + "";
                    String usablespac = tempSpace.get("usablespac") + "";
                    String usableper = (String) tempSpace.get("usableper");

                    if (usableper == null || usableper.trim().equals("")) {
                        usableper = "0";
                    }
                    cell = new PdfPCell(new Phrase((i + 1) + ""));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new PdfPCell(new Phrase(SYSCATSPACE));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new PdfPCell(new Phrase(totalspac));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new PdfPCell(new Phrase(usablespac));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new PdfPCell(new Phrase(usableper));
                    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) {
        // TODO: handle exception
    }
}