Example usage for org.jfree.chart ChartUtilities writeChartAsPNG

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

Introduction

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

Prototype

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

Source Link

Document

Writes a chart to an output stream in PNG format.

Usage

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

/**
 * @author HONGLI db2word/*from   w  w w  . j a  v a 2s.  c om*/
 * @param filename
 * @param type
 * @throws IOException
 */
public void createReport_DB2CldDoc(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");
        Hashtable conn = (Hashtable) reportHash.get("conn");// 
        if (conn == null)
            conn = new Hashtable();
        Hashtable poolInfo = (Hashtable) reportHash.get("poolInfo");// 
        if (poolInfo == null)
            poolInfo = new Hashtable();
        Hashtable log = (Hashtable) reportHash.get("log");// 
        if (log == null)
            log = new Hashtable();
        Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");// 
        if (spaceInfo == null)
            spaceInfo = new Hashtable();
        String[] sysDbStatus = { "", "", "", "" };
        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));
        this.setCellFormat(dbCell, true);
        dbCell.setColspan(5);
        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);
        if ("pdf".equals(type)) {
            img.scalePercent(75);
        }
        img.setAlignment(Image.LEFT);// 
        document.add(dbTable);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));

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

        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 = new Hashtable();
                    tempSpace = (Hashtable) toolsdb.get(i);
                    String tablespace_name = (String) tempSpace.get("tablespace_name");
                    String totalspac = (String) tempSpace.get("totalspac");
                    String usablespac = (String) tempSpace.get("usablespac");
                    String usableper = (String) tempSpace.get("usableper");

                    if (usableper == null || "0".equals(totalspac.trim())) {
                        usableper = "100";
                    }
                    cell = new Cell(new Phrase((i + 1) + "", titleFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(tablespace_name, titleFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(totalspac, titleFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(usablespac, titleFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(usableper, titleFont));
                    this.setCellFormat(cell, false);
                    spaceTable.addCell(cell);
                }
            }
        }
        document.add(spaceTable);

        //  
        Table dbInfoTable = new Table(10);
        this.setTableFormat(dbInfoTable);
        // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 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("   ", titleFont));
        cell.setColspan(10);
        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(" ", 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(" ", 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("SQL ", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        Enumeration dbs = conn.keys();
        Hashtable<String, Object> allhash = new Hashtable();
        List poolList = new ArrayList();
        while (dbs.hasMoreElements()) {
            String obj = (String) dbs.nextElement();
            List connList = (List) conn.get(obj);

            for (int i = 0; i < connList.size(); i++) {
                Hashtable ht = (Hashtable) connList.get(i);
                String db_name = ht.get("db_name").toString();
                String db_path = ht.get("db_path").toString();
                String db_status = ht.get("db_status").toString();
                String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString();
                String total_cons = ht.get("total_cons").toString();
                String connections_top = ht.get("connections_top").toString();
                String appls_cur_cons = ht.get("appls_cur_cons").toString();
                String failedsql = ht.get("failedsql").toString();
                String commitsql = ht.get("commitsql").toString();

                cell = new Cell(new Phrase((i + 1) + "", contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(db_name, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(db_path, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(sysDbStatus[Integer.parseInt(db_status)], contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(sqlm_elm_last_backup, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(total_cons, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(connections_top, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(appls_cur_cons, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(failedsql, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
                cell = new Cell(new Phrase(commitsql, contextFont));
                this.setCellFormat(cell, false);
                dbInfoTable.addCell(cell);
            }
        }
        document.add(dbInfoTable);

        //    
        Table sysInfoTable = new Table(7);
        this.setTableFormat(sysInfoTable);
        // 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("   ", titleFont));
        this.setCellFormat(cell, true);
        cell.setColspan(7);
        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(" ", 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);
        Enumeration dbs2 = poolInfo.keys();
        Hashtable<String, Object> allhash2 = new Hashtable();
        List poolList2 = new ArrayList();
        while (dbs2.hasMoreElements()) {
            String obj = (String) dbs2.nextElement();
            allhash = (Hashtable) poolInfo.get(obj);
            poolList = (List) allhash.get("poolValue");
            List lockList = (List) allhash.get("lockValue");
            List readList = (List) allhash.get("readValue");
            List writeList = (List) allhash.get("writeValue");
            for (int i = 0; i < poolList.size(); i++) {
                Hashtable ht = (Hashtable) poolList.get(i);
                String bp_name = ht.get("bp_name").toString();
                String data_hit_ratio = ht.get("data_hit_ratio").toString();
                String index_hit_ratio = ht.get("index_hit_ratio").toString();
                String BP_hit_ratio = ht.get("BP_hit_ratio").toString();
                String Async_read_pct = ht.get("Async_read_pct").toString();
                String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString();

                cell = new Cell(new Phrase((i + 1) + "", contextFont));
                this.setCellFormat(cell, false);
                sysInfoTable.addCell(cell);
                cell = new Cell(new Phrase(bp_name, contextFont));
                this.setCellFormat(cell, false);
                sysInfoTable.addCell(cell);
                cell = new Cell(new Phrase(data_hit_ratio, contextFont));
                this.setCellFormat(cell, false);
                sysInfoTable.addCell(cell);
                cell = new Cell(new Phrase(index_hit_ratio, contextFont));
                this.setCellFormat(cell, false);
                sysInfoTable.addCell(cell);
                cell = new Cell(new Phrase(BP_hit_ratio, contextFont));
                this.setCellFormat(cell, false);
                sysInfoTable.addCell(cell);
                cell = new Cell(new Phrase(Async_read_pct, contextFont));
                this.setCellFormat(cell, false);
                sysInfoTable.addCell(cell);
                cell = new Cell(new Phrase(Direct_RW_Ratio, contextFont));
                this.setCellFormat(cell, false);
                sysInfoTable.addCell(cell);
            }
        }
        document.newPage();
        document.add(sysInfoTable);

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

        Enumeration dbs3 = poolInfo.keys();
        Hashtable<String, Object> allhash3 = new Hashtable();
        List poolList3 = new ArrayList();
        while (dbs3.hasMoreElements()) {
            String obj = (String) dbs3.nextElement();
            allhash3 = (Hashtable) poolInfo.get(obj);
            poolList3 = (List) allhash3.get("poolValue");
            // System.out.println("poolList size === "+poolList.size());
            List lockList = (List) allhash3.get("lockValue");
            List readList = (List) allhash3.get("readValue");
            List writeList = (List) allhash3.get("writeValue");
            for (int i = 0; i < lockList.size(); i++) {
                Hashtable ht = (Hashtable) lockList.get(i);
                String db_name = ht.get("db_name").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_selected = ht.get("rows_selected").toString();
                String lock_waits = ht.get("lock_waits").toString();
                String lock_wait_time = ht.get("lock_wait_time").toString();
                String deadlocks = ht.get("deadlocks").toString();
                String lock_escals = ht.get("lock_escals").toString();
                String total_sorts = ht.get("total_sorts").toString();
                String total_sort_time = ht.get("total_sort_time").toString();
                cell = new Cell(new Phrase((i + 1) + ""));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(db_name, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(rows_read, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(rows_selected, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(lock_waits, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(lock_wait_time, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(deadlocks, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(lock_escals, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(total_sorts, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);
                cell = new Cell(new Phrase(total_sort_time, contextFont));
                this.setCellFormat(cell, false);
                aTable1.addCell(cell);

            }
        }

        // 
        Table aTable2 = new Table(7);
        this.setTableFormat(aTable2);
        // float[] width2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // aTable2.setWidths(width2);
        // 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("   ", titleFont));
        cell.setColspan(7);
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("(Mb)  ", titleFont));
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("(Mb)   ", titleFont));
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("(%)  ", titleFont));
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("(Mb) ", titleFont));
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("/", titleFont));
        this.setCellFormat(cell, true);
        aTable2.addCell(cell);
        Enumeration dbs4 = log.keys();
        Hashtable<String, Object> allhash4 = new Hashtable();
        List poolList4 = new ArrayList();
        while (dbs4.hasMoreElements()) {
            String obj = (String) dbs4.nextElement();
            List logList = (List) log.get(obj);
            for (int i = 0; i < logList.size(); i++) {
                Hashtable ht = (Hashtable) logList.get(i);
                String logused = ht.get("logused").toString();
                String logspacefree = ht.get("logspacefree").toString();
                String pctused = ht.get("pctused").toString();
                String maxlogused = ht.get("maxlogused").toString();
                String maxsecused = ht.get("maxsecused").toString();
                cell = new Cell(new Phrase((i + 1) + ""));
                this.setCellFormat(cell, false);
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(obj, contextFont));
                this.setCellFormat(cell, false);
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(logused, contextFont));
                this.setCellFormat(cell, false);
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(logspacefree, contextFont));
                this.setCellFormat(cell, false);
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(pctused, contextFont));
                this.setCellFormat(cell, false);
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(maxlogused, contextFont));
                this.setCellFormat(cell, false);
                aTable2.addCell(cell);
                cell = new Cell(new Phrase(maxsecused, contextFont));
                this.setCellFormat(cell, false);
                aTable2.addCell(cell);
            }
        }

        // 
        Table aTable3 = new Table(7);
        this.setTableFormat(aTable3);
        // float[] awidth3 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // aTable3.setWidths(awidth3);
        // 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("10", titleFont));
        cell.setColspan(7);
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        aTable3.addCell(cell);
        Enumeration dbs5 = poolInfo.keys();
        Hashtable<String, Object> allhash5 = new Hashtable();
        List poolList5 = new ArrayList();
        String obj = null;
        Hashtable allhash6 = null;
        List lockList = null;
        List readList = null;
        List writeList = null;
        while (dbs5.hasMoreElements()) {
            obj = (String) dbs5.nextElement();
            allhash6 = (Hashtable) poolInfo.get(obj);
            poolList = (List) allhash6.get("poolValue");
            // System.out.println("poolList size === "+poolList.size());
            lockList = (List) allhash6.get("lockValue");
            readList = (List) allhash6.get("readValue");
            writeList = (List) allhash6.get("writeValue");
        }
        if (readList != null && readList.size() > 0) {
            for (int i = 0; i < readList.size(); i++) {
                Hashtable ht = (Hashtable) readList.get(i);
                String tbschema = ht.get("tbschema").toString();
                String tbname = ht.get("tbname").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_written = ht.get("rows_written").toString();
                String overflow_accesses = ht.get("overflow_accesses").toString();
                String page_reorgs = ht.get("page_reorgs").toString();

                cell = new Cell(new Phrase((i + 1) + "", contextFont));
                this.setCellFormat(cell, false);
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(tbschema, contextFont));
                this.setCellFormat(cell, false);
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(tbname, contextFont));
                this.setCellFormat(cell, false);
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(rows_read, contextFont));
                this.setCellFormat(cell, false);
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(rows_written, contextFont));
                this.setCellFormat(cell, false);
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(overflow_accesses, contextFont));
                this.setCellFormat(cell, false);
                aTable3.addCell(cell);
                cell = new Cell(new Phrase(page_reorgs, contextFont));
                this.setCellFormat(cell, false);
                aTable3.addCell(cell);
            }
        }
        Table aTable4 = new Table(7);
        this.setTableFormat(aTable4);
        // float[] width4 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // aTable4.setWidths(width4);
        // 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("10", titleFont));
        cell.setColspan(7);
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        aTable4.addCell(cell);

        if (writeList != null && writeList.size() > 0) {
            for (int i = 0; i < writeList.size(); i++) {
                Hashtable ht = (Hashtable) writeList.get(i);
                String tbschema = ht.get("tbschema").toString();
                String tbname = ht.get("tbname").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_written = ht.get("rows_written").toString();
                String overflow_accesses = ht.get("overflow_accesses").toString();
                String page_reorgs = ht.get("page_reorgs").toString();

                cell = new Cell(new Phrase((i + 1) + "", contextFont));
                this.setCellFormat(cell, false);
                aTable4.addCell(cell);
                cell = new Cell(new Phrase(tbschema, contextFont));
                this.setCellFormat(cell, false);
                aTable4.addCell(cell);
                cell = new Cell(new Phrase(tbname, contextFont));
                this.setCellFormat(cell, false);
                aTable4.addCell(cell);
                cell = new Cell(new Phrase(rows_read, contextFont));
                this.setCellFormat(cell, false);
                aTable4.addCell(cell);
                cell = new Cell(new Phrase(rows_written, contextFont));
                this.setCellFormat(cell, false);
                aTable4.addCell(cell);
                cell = new Cell(new Phrase(overflow_accesses, contextFont));
                this.setCellFormat(cell, false);
                aTable4.addCell(cell);
                cell = new Cell(new Phrase(page_reorgs, contextFont));
                this.setCellFormat(cell, false);
                aTable4.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);

        //    
        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.newPage();
        document.add(evenInfoTable);
        // 
        addEventListToDoc(document, titleFont, contextFont);

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

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

/**
 * @author HONGLI DB2pdf/*  www.j  a v a 2s. c  o m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_DB2CldPdf(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");
        Hashtable conn = (Hashtable) reportHash.get("conn");// 
        if (conn == null)
            conn = new Hashtable();
        Hashtable poolInfo = (Hashtable) reportHash.get("poolInfo");// 
        if (poolInfo == null)
            poolInfo = new Hashtable();
        Hashtable log = (Hashtable) reportHash.get("log");// 
        if (log == null)
            log = new Hashtable();
        Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");// 
        if (spaceInfo == null)
            spaceInfo = new Hashtable();
        String[] sysDbStatus = { "", "", "", "" };
        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"));
        //   
        PdfPTable spaceInfoTable = new PdfPTable(5);
        float[] spaceInfoWidths = { 220f, 220f, 220f, 220f, 220f };
        spaceInfoTable.setWidths(spaceInfoWidths);
        spaceInfoTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("MB ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase("MB ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceInfoTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" % ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceInfoTable.addCell(cell);
        if (spaceInfo == null)
            spaceInfo = new Hashtable();
        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 = new Hashtable();
                    tempSpace = (Hashtable) toolsdb.get(i);
                    String tablespace_name = (String) tempSpace.get("tablespace_name");
                    String totalspac = (String) tempSpace.get("totalspac");
                    String usablespac = (String) tempSpace.get("usablespac");
                    String usableper = (String) tempSpace.get("usableper");

                    if (usableper == null || "0".equals(totalspac.trim())) {
                        usableper = "100";
                    }

                    cell = new PdfPCell(new Phrase((i + 1) + "", contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceInfoTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(tablespace_name, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceInfoTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(totalspac, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceInfoTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(usablespac, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceInfoTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(usableper, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceInfoTable.addCell(cell);
                }
            }
        }
        document.add(spaceInfoTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable connTable = new PdfPTable(10);
        float[] connWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        connTable.setWidths(connWidths);
        connTable.setWidthPercentage(100);
        Hashtable mems = (Hashtable) reportHash.get("mems");// 
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("SQL ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("SQL ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        Enumeration dbs = conn.keys();
        Hashtable<String, Object> allhash = new Hashtable();
        List poolList = new ArrayList();
        while (dbs.hasMoreElements()) {
            String obj = (String) dbs.nextElement();
            List connList = (List) conn.get(obj);

            for (int i = 0; i < connList.size(); i++) {
                Hashtable ht = (Hashtable) connList.get(i);
                String db_name = ht.get("db_name").toString();
                String db_path = ht.get("db_path").toString();
                String db_status = ht.get("db_status").toString();
                String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString();
                String total_cons = ht.get("total_cons").toString();
                String connections_top = ht.get("connections_top").toString();
                String appls_cur_cons = ht.get("appls_cur_cons").toString();
                String failedsql = ht.get("failedsql").toString();
                String commitsql = ht.get("commitsql").toString();
                cell = new PdfPCell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(db_name, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(db_path, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(sysDbStatus[Integer.parseInt(db_status)], contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(sqlm_elm_last_backup, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(total_cons, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(connections_top, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(appls_cur_cons, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(failedsql, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
                cell = new PdfPCell(new Phrase(commitsql, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                connTable.addCell(cell);
            }
        }
        document.add(connTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable hcTable = new PdfPTable(7);
        float[] hcWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        hcTable.setWidths(hcWidths);
        hcTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hcTable.addCell(cell);
        Enumeration dbs2 = poolInfo.keys();
        Hashtable<String, Object> allhash2 = new Hashtable();
        List poolList2 = new ArrayList();
        while (dbs2.hasMoreElements()) {
            String obj = (String) dbs2.nextElement();
            allhash = (Hashtable) poolInfo.get(obj);
            poolList = (List) allhash.get("poolValue");
            List lockList = (List) allhash.get("lockValue");
            List readList = (List) allhash.get("readValue");
            List writeList = (List) allhash.get("writeValue");
            for (int i = 0; i < poolList.size(); i++) {
                Hashtable ht = (Hashtable) poolList.get(i);
                String bp_name = ht.get("bp_name").toString();
                String data_hit_ratio = ht.get("data_hit_ratio").toString();
                String index_hit_ratio = ht.get("index_hit_ratio").toString();
                String BP_hit_ratio = ht.get("BP_hit_ratio").toString();
                String Async_read_pct = ht.get("Async_read_pct").toString();
                String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString();

                cell = new PdfPCell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hcTable.addCell(cell);
                cell = new PdfPCell(new Phrase(bp_name, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hcTable.addCell(cell);
                cell = new PdfPCell(new Phrase(data_hit_ratio, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hcTable.addCell(cell);
                cell = new PdfPCell(new Phrase(index_hit_ratio, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hcTable.addCell(cell);
                cell = new PdfPCell(new Phrase(BP_hit_ratio, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hcTable.addCell(cell);
                cell = new PdfPCell(new Phrase(Async_read_pct, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hcTable.addCell(cell);
                cell = new PdfPCell(new Phrase(Direct_RW_Ratio, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hcTable.addCell(cell);
            }
        }
        document.add(hcTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable lockTable = new PdfPTable(10);
        float[] lockWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        lockTable.setWidths(lockWidths);
        lockTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        Enumeration dbs3 = poolInfo.keys();
        Hashtable<String, Object> allhash3 = new Hashtable();
        List poolList3 = new ArrayList();
        while (dbs3.hasMoreElements()) {
            String obj = (String) dbs3.nextElement();
            allhash3 = (Hashtable) poolInfo.get(obj);
            poolList3 = (List) allhash3.get("poolValue");
            // System.out.println("poolList size === "+poolList.size());
            List lockList = (List) allhash3.get("lockValue");
            List readList = (List) allhash3.get("readValue");
            List writeList = (List) allhash3.get("writeValue");
            for (int i = 0; i < lockList.size(); i++) {
                Hashtable ht = (Hashtable) lockList.get(i);
                String db_name = ht.get("db_name").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_selected = ht.get("rows_selected").toString();
                String lock_waits = ht.get("lock_waits").toString();
                String lock_wait_time = ht.get("lock_wait_time").toString();
                String deadlocks = ht.get("deadlocks").toString();
                String lock_escals = ht.get("lock_escals").toString();
                String total_sorts = ht.get("total_sorts").toString();
                String total_sort_time = ht.get("total_sort_time").toString();
                cell = new PdfPCell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(db_name, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rows_read, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rows_selected, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(lock_waits, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(lock_wait_time, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(deadlocks, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(lock_escals, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(total_sorts, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(total_sort_time, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
            }
        }
        document.add(lockTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable logTable = new PdfPTable(7);
        float[] logWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        logTable.setWidths(logWidths);
        logTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(Mb)  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(Mb) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(%) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(Mb)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("/  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        Enumeration dbs4 = log.keys();
        Hashtable<String, Object> allhash4 = new Hashtable();
        List poolList4 = new ArrayList();
        while (dbs4.hasMoreElements()) {
            String obj = (String) dbs4.nextElement();
            List logList = (List) log.get(obj);
            for (int i = 0; i < logList.size(); i++) {
                Hashtable ht = (Hashtable) logList.get(i);
                String logused = ht.get("logused").toString();
                String logspacefree = ht.get("logspacefree").toString();
                String pctused = ht.get("pctused").toString();
                String maxlogused = ht.get("maxlogused").toString();
                String maxsecused = ht.get("maxsecused").toString();
                cell = new PdfPCell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(obj, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(logused, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(logspacefree, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(pctused, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(maxlogused, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(maxsecused, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
            }
        }
        document.add(logTable);
        document.add(new Paragraph("\n"));

        // 10
        PdfPTable readTopTenTable = new PdfPTable(7);
        float[] readTopTenWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        readTopTenTable.setWidths(readTopTenWidths);
        readTopTenTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("10", titleFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        readTopTenTable.addCell(cell);
        Enumeration dbs5 = poolInfo.keys();
        Hashtable<String, Object> allhash5 = new Hashtable();
        List poolList5 = new ArrayList();
        String obj = null;
        Hashtable allhash6 = null;
        List lockList = null;
        List readList = null;
        List writeList = null;
        while (dbs5.hasMoreElements()) {
            obj = (String) dbs5.nextElement();
            allhash6 = (Hashtable) poolInfo.get(obj);
            poolList = (List) allhash6.get("poolValue");
            // System.out.println("poolList size === "+poolList.size());
            lockList = (List) allhash6.get("lockValue");
            readList = (List) allhash6.get("readValue");
            writeList = (List) allhash6.get("writeValue");
        }
        if (readList != null && readList.size() > 0) {
            for (int i = 0; i < readList.size(); i++) {
                Hashtable ht = (Hashtable) readList.get(i);
                String tbschema = ht.get("tbschema").toString();
                String tbname = ht.get("tbname").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_written = ht.get("rows_written").toString();
                String overflow_accesses = ht.get("overflow_accesses").toString();
                String page_reorgs = ht.get("page_reorgs").toString();
                cell = new PdfPCell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                readTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tbschema, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                readTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tbname, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                readTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rows_read, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                readTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rows_written, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                readTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(overflow_accesses, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                readTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(page_reorgs, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                readTopTenTable.addCell(cell);
            }
        }
        document.add(readTopTenTable);
        document.add(new Paragraph("\n"));

        // 10
        PdfPTable writeTopTenTable = new PdfPTable(7);
        float[] writeTopTenWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        writeTopTenTable.setWidths(writeTopTenWidths);
        writeTopTenTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("10", titleFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        writeTopTenTable.addCell(cell);
        if (writeList != null && writeList.size() > 0) {
            for (int i = 0; i < writeList.size(); i++) {
                Hashtable ht = (Hashtable) writeList.get(i);
                String tbschema = ht.get("tbschema").toString();
                String tbname = ht.get("tbname").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_written = ht.get("rows_written").toString();
                String overflow_accesses = ht.get("overflow_accesses").toString();
                String page_reorgs = ht.get("page_reorgs").toString();
                cell = new PdfPCell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                writeTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tbschema, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                writeTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tbname, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                writeTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rows_read, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                writeTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rows_written, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                writeTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(overflow_accesses, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                writeTopTenTable.addCell(cell);
                cell = new PdfPCell(new Phrase(page_reorgs, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                writeTopTenTable.addCell(cell);
            }
        }
        document.add(writeTopTenTable);
        document.add(new Paragraph("\n"));

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

            document.add(img1);
        }

        document.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 DB2excel/*from www  .j  a v  a  2 s.com*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_DB2CldXls(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 conn = (Hashtable) reportHash.get("conn");// 
        if (conn == null)
            conn = new Hashtable();
        Hashtable poolInfo = (Hashtable) reportHash.get("poolInfo");// 
        if (poolInfo == null)
            poolInfo = new Hashtable();
        Hashtable log = (Hashtable) reportHash.get("log");// 
        if (log == null)
            log = new Hashtable();
        Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");// 
        if (spaceInfo == null)
            spaceInfo = new Hashtable();
        String[] sysDbStatus = { "", "", "", "" };
        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);

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

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

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

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

        // ip
        tmpLabel = new Label(0, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 4, "IP", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 4, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 5, ip, p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 5, typename, p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 5, 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, "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 17, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 17, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 17, "MB ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 17, "MB  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 17, " %", b_labelFormat);
        sheet.addCell(tmpLabel);
        int row = 18;
        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 = new Hashtable();
                    tempSpace = (Hashtable) toolsdb.get(i);
                    String tablespace_name = (String) tempSpace.get("tablespace_name");
                    String totalspac = (String) tempSpace.get("totalspac");
                    String usablespac = (String) tempSpace.get("usablespac");
                    String usableper = (String) tempSpace.get("usableper");

                    if (usableper == null || "0".equals(totalspac.trim())) {
                        usableper = "100";
                    }
                    tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(1, row, tablespace_name, 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);

                    row++;
                }
            }
        }

        row = row + 2;
        //    
        tmpLabel = new Label(0, row, "   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, row, "SQL ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(9, row, "SQL", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        Enumeration dbs = conn.keys();
        Hashtable<String, Object> allhash = new Hashtable();
        List poolList = new ArrayList();
        while (dbs.hasMoreElements()) {
            String obj = (String) dbs.nextElement();
            List connList = (List) conn.get(obj);

            for (int i = 0; i < connList.size(); i++) {
                Hashtable ht = (Hashtable) connList.get(i);
                String db_name = ht.get("db_name").toString();
                String db_path = ht.get("db_path").toString();
                String db_status = ht.get("db_status").toString();
                String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString();
                String total_cons = ht.get("total_cons").toString();
                String connections_top = ht.get("connections_top").toString();
                String appls_cur_cons = ht.get("appls_cur_cons").toString();
                String failedsql = ht.get("failedsql").toString();
                String commitsql = ht.get("commitsql").toString();

                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, db_name, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, db_path, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, sysDbStatus[Integer.parseInt(db_status)], p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, sqlm_elm_last_backup, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, total_cons, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, connections_top, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, appls_cur_cons, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, failedsql, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, commitsql, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        //    
        row = row + 2;
        tmpLabel = new Label(0, row, "   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        Enumeration dbs2 = poolInfo.keys();
        Hashtable<String, Object> allhash2 = new Hashtable();
        List poolList2 = new ArrayList();
        while (dbs2.hasMoreElements()) {
            String obj = (String) dbs2.nextElement();
            allhash = (Hashtable) poolInfo.get(obj);
            poolList = (List) allhash.get("poolValue");
            List lockList = (List) allhash.get("lockValue");
            List readList = (List) allhash.get("readValue");
            List writeList = (List) allhash.get("writeValue");
            for (int i = 0; i < poolList.size(); i++) {
                Hashtable ht = (Hashtable) poolList.get(i);
                String bp_name = ht.get("bp_name").toString();
                String data_hit_ratio = ht.get("data_hit_ratio").toString();
                String index_hit_ratio = ht.get("index_hit_ratio").toString();
                String BP_hit_ratio = ht.get("BP_hit_ratio").toString();
                String Async_read_pct = ht.get("Async_read_pct").toString();
                String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString();

                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, bp_name, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, data_hit_ratio, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, index_hit_ratio, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, BP_hit_ratio, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, Async_read_pct, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, Direct_RW_Ratio, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        //   
        row = row + 2;
        tmpLabel = new Label(0, row, "  ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(9, row, "   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        Enumeration dbs3 = poolInfo.keys();
        Hashtable<String, Object> allhash3 = new Hashtable();
        List poolList3 = new ArrayList();
        while (dbs3.hasMoreElements()) {
            String obj = (String) dbs3.nextElement();
            allhash3 = (Hashtable) poolInfo.get(obj);
            poolList3 = (List) allhash3.get("poolValue");
            // System.out.println("poolList size === "+poolList.size());
            List lockList = (List) allhash3.get("lockValue");
            List readList = (List) allhash3.get("readValue");
            List writeList = (List) allhash3.get("writeValue");
            for (int i = 0; i < lockList.size(); i++) {
                Hashtable ht = (Hashtable) lockList.get(i);
                String db_name = ht.get("db_name").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_selected = ht.get("rows_selected").toString();
                String lock_waits = ht.get("lock_waits").toString();
                String lock_wait_time = ht.get("lock_wait_time").toString();
                String deadlocks = ht.get("deadlocks").toString();
                String lock_escals = ht.get("lock_escals").toString();
                String total_sorts = ht.get("total_sorts").toString();
                String total_sort_time = ht.get("total_sort_time").toString();
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, db_name, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, rows_read, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, rows_selected, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, lock_waits, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, lock_wait_time, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, deadlocks, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, lock_escals, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, total_sorts, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, total_sort_time, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        //   
        row = row + 2;
        tmpLabel = new Label(0, row, "   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "(Mb)   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "(Mb)  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "(%)  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "(Mb) ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, "/  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        Enumeration dbs4 = log.keys();
        Hashtable<String, Object> allhash4 = new Hashtable();
        List poolList4 = new ArrayList();
        while (dbs4.hasMoreElements()) {
            String obj = (String) dbs4.nextElement();
            List logList = (List) log.get(obj);
            for (int i = 0; i < logList.size(); i++) {
                Hashtable ht = (Hashtable) logList.get(i);
                String logused = ht.get("logused").toString();
                String logspacefree = ht.get("logspacefree").toString();
                String pctused = ht.get("pctused").toString();
                String maxlogused = ht.get("maxlogused").toString();
                String maxsecused = ht.get("maxsecused").toString();
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, obj, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, logused, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, logspacefree, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, pctused, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, maxlogused, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, maxsecused, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        // 10
        row = row + 2;
        tmpLabel = new Label(0, row, "10 ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        Enumeration dbs5 = poolInfo.keys();
        Hashtable<String, Object> allhash5 = new Hashtable();
        List poolList5 = new ArrayList();
        String obj = null;
        Hashtable allhash6 = null;
        List lockList = null;
        List readList = null;
        List writeList = null;
        while (dbs5.hasMoreElements()) {
            obj = (String) dbs5.nextElement();
            allhash6 = (Hashtable) poolInfo.get(obj);
            poolList = (List) allhash6.get("poolValue");
            // System.out.println("poolList size === "+poolList.size());
            lockList = (List) allhash6.get("lockValue");
            readList = (List) allhash6.get("readValue");
            writeList = (List) allhash6.get("writeValue");
        }
        if (readList != null && readList.size() > 0) {
            for (int i = 0; i < readList.size(); i++) {
                Hashtable ht = (Hashtable) readList.get(i);
                String tbschema = ht.get("tbschema").toString();
                String tbname = ht.get("tbname").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_written = ht.get("rows_written").toString();
                String overflow_accesses = ht.get("overflow_accesses").toString();
                String page_reorgs = ht.get("page_reorgs").toString();
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, tbschema, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, tbname, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, rows_read, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, rows_written, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, overflow_accesses, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, page_reorgs, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

        // 10
        row = row + 2;
        tmpLabel = new Label(0, row, "10 ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        if (writeList != null && writeList.size() > 0) {
            for (int i = 0; i < writeList.size(); i++) {
                Hashtable ht = (Hashtable) writeList.get(i);
                String tbschema = ht.get("tbschema").toString();
                String tbname = ht.get("tbname").toString();
                String rows_read = ht.get("rows_read").toString();
                String rows_written = ht.get("rows_written").toString();
                String overflow_accesses = ht.get("overflow_accesses").toString();
                String page_reorgs = ht.get("page_reorgs").toString();
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, tbschema, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, tbname, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, rows_read, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, rows_written, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, overflow_accesses, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, page_reorgs, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

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

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

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

/**
 * @author HONGLI Sybase doc/*from   w w  w . ja  va2  s .  c  o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportSybaseSelfDoc(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");
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");
        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 spaceTable = new Table(5);
        float[] width = { 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidth(100); //  90%
        spaceTable.setAlignment(Element.ALIGN_CENTER);// 
        spaceTable.setAutoFillEmptyCells(true); // 
        spaceTable.setBorderWidth(1); // 
        spaceTable.setBorderColor(new Color(0, 125, 255)); // 
        spaceTable.setPadding(2);// 
        spaceTable.setSpacing(0);// 
        spaceTable.setBorder(2);// 
        cell = new Cell(new Phrase("  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();

        // 
        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {

            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                cell = new Cell(new Phrase((i + 1) + "", titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_name, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_size, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_freesize, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_usedperc, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.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(spaceTable);
        document.close();
    } catch (Exception e) {
        SysLogger.error("ExcelReport1.createReportDB2SelfDoc()");
    }
}

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

/**
 * @author HONGLI Sybase xls/*from   ww  w.j  ava 2  s.co m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportSybaseSelfExcel(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");
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

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

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

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

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

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

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

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

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

        // 
        File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip
                + "ConnectUtilization" + ".png");
        // sheet,0,0,5,1,,,
        // allRow = allRow+2;
        sheet.addImage(new WritableImage(1, 6, 7, 7, file));
        // allRow = allRow+7;
        int row = 15;
        tmpLabel = new Label(1, row, "", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "MB", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "MB ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "(%)", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;

        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {

            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, db_name, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, db_size, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, db_freesize, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, db_usedperc, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }

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

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

/**
 * @author HONGLI Sybase pdf/*w  w w.  jav  a  2 s .c o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportSybaseSelfPdf(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);
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");
        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.setColspan(5);
        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();

        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {
            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                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(db_name));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(db_size));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(db_freesize));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(db_usedperc));
                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
    }
}

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

/**
 * @author HONGLI Sybaseword/*from  ww w .j  av a 2 s  . c om*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_SybaseCldDoc(String filename) throws 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 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");
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");
        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);
        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);
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("IP", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(vo.getDbName(), contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(ip, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(typename, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(runstr, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(grade, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);

        Table aTable = new Table(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidth(100); //  90%
        aTable.setAlignment(Element.ALIGN_CENTER);// 
        aTable.setAutoFillEmptyCells(true); // 
        aTable.setBorderWidth(1); // 
        aTable.setBorderColor(new Color(0, 125, 255)); // 
        aTable.setPadding(2);// 
        aTable.setSpacing(0);// 
        aTable.setBorder(2);// 
        aTable.endHeaders();
        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(pingnow + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingmin + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(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.setAlignment(Image.LEFT);// 
        document.add(dbTable);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));

        //   
        Table spaceTable = new Table(5);
        float[] width = { 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidth(100); //  90%
        spaceTable.setAlignment(Element.ALIGN_CENTER);// 
        spaceTable.setAutoFillEmptyCells(true); // 
        spaceTable.setBorderWidth(1); // 
        spaceTable.setBorderColor(new Color(0, 125, 255)); // 
        spaceTable.setPadding(2);// 
        spaceTable.setSpacing(0);// 
        spaceTable.setBorder(2);// 
        cell = new Cell(new Phrase("  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();

        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {

            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                cell = new Cell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_name, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_size, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_freesize, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_usedperc, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);

            }
        }
        document.add(spaceTable);

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

        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("Metadata(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(MB) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(MB) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(%) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getData_hitrate(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        document.add(memTable);

        // Sysbase 
        Table remoteServerTable = new Table(5);
        float[] remoteServerWidths = { 220f, 220f, 220f, 220f, 220f };
        remoteServerTable.setWidths(remoteServerWidths);
        remoteServerTable.setWidth(100); //  90%
        remoteServerTable.setAlignment(Element.ALIGN_CENTER);// 
        remoteServerTable.setAutoFillEmptyCells(true); // 
        remoteServerTable.setBorderWidth(1); // 
        remoteServerTable.setBorderColor(new Color(0, 125, 255)); // 
        remoteServerTable.setPadding(2);// 
        remoteServerTable.setSpacing(0);// 
        remoteServerTable.setBorder(2);// 
        Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// 
        cell = new Cell(new Phrase("Sysbase  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        List serverlist = (List) sysbaseVO.getServersInfo();
        if (serverlist != null && serverlist.size() > 0) {
            for (int k = 0; k < serverlist.size(); k++) {
                TablesVO tVO = (TablesVO) serverlist.get(k);

                cell = new Cell(new Phrase((k + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_network_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_class(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_status(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
            }
        }
        document.add(remoteServerTable);

        Table userTable = new Table(5);
        float[] uWidth = { 220f, 220f, 220f, 220f, 220f };
        userTable.setWidths(uWidth);
        userTable.setWidth(100); //  90%
        userTable.setAlignment(Element.ALIGN_CENTER);// 
        userTable.setAutoFillEmptyCells(true); // 
        userTable.setBorderWidth(1); // 
        userTable.setBorderColor(new Color(0, 125, 255)); // 
        userTable.setPadding(2);// 
        userTable.setSpacing(0);// 
        userTable.setBorder(2);// 
        cell = new Cell(new Phrase(" Sysbase  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase("id ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        // userTable.endHeaders();

        List userlist = (List) sysbaseVO.getUserInfo();
        if (userlist != null && userlist.size() > 0) {
            for (int k = 0; k < userlist.size(); k++) {
                TablesVO tVO = (TablesVO) userlist.get(k);
                cell = new Cell(new Phrase((k + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getUsers_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getID_in_db(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getGroup_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getLogin_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);

            }
        }
        document.add(userTable);

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

            document.add(img1);
        }

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

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

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

/**
 * @author HONGLI Sybasepdf//from ww w . j a va 2s  . c  o  m
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_SybaseCldPdf(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");
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");
        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"));

        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.setColspan(5);
        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();

        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {
            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                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(db_name));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(db_size));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(db_freesize));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
                cell = new PdfPCell(new Phrase(db_usedperc));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable1.addCell(cell);
            }
        }

        // 
        PdfPTable memTable = new PdfPTable(6);
        float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        memTable.setWidths(dbInfoWidths);
        memTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(MB) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase("Metadata(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(MB) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(MB) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase("(%) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new PdfPCell(new Phrase(sysbaseVO.getData_hitrate(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        document.add(memTable);
        document.add(new Paragraph("\n"));

        // Sysbase 
        PdfPTable remoteServerTable = new PdfPTable(5);
        float[] ncWidths = { 220f, 220f, 220f, 220f, 220f };
        remoteServerTable.setWidths(ncWidths);
        remoteServerTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("Sysbase  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        List serverlist = (List) sysbaseVO.getServersInfo();
        if (serverlist != null && serverlist.size() > 0) {
            for (int k = 0; k < serverlist.size(); k++) {
                TablesVO tVO = (TablesVO) serverlist.get(k);
                cell = new PdfPCell(new Phrase((k + 1) + "", titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getServer_name(), titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getServer_network_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getServer_class(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getServer_status(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
            }
        }
        document.add(remoteServerTable);
        document.add(new Paragraph("\n"));

        // Sysbase 
        PdfPTable userTable = new PdfPTable(5);
        float[] uWidths = { 220f, 220f, 220f, 220f, 220f };
        userTable.setWidths(uWidths);
        userTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase(" Sysbase  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new PdfPCell(new Phrase("id  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        List userlist = (List) sysbaseVO.getUserInfo();
        if (userlist != null && userlist.size() > 0) {
            for (int k = 0; k < userlist.size(); k++) {
                TablesVO tVO = (TablesVO) userlist.get(k);
                cell = new PdfPCell(new Phrase((k + 1) + "", titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getUsers_name(), titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getID_in_db(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getGroup_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getLogin_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
            }
        }
        document.add(userTable);
        document.add(new Paragraph("\n"));

        // Sysbase 
        PdfPTable deviceTable = new PdfPTable(4);
        float[] dWidths = { 220f, 220f, 220f, 220f };
        deviceTable.setWidths(dWidths);
        deviceTable.setWidthPercentage(100);
        Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// 
        cell = new PdfPCell(new Phrase("Sysbase   ", titleFont));
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        deviceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        deviceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        deviceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        deviceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        deviceTable.addCell(cell);
        List devicelist = (List) sysbaseVO.getDeviceInfo();
        if (devicelist != null && devicelist.size() > 0) {
            for (int k = 0; k < devicelist.size(); k++) {
                TablesVO tVO = (TablesVO) devicelist.get(k);
                cell = new PdfPCell(new Phrase((k + 1) + "", titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                deviceTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getDevice_name(), titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                deviceTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getDevice_physical_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                deviceTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tVO.getDevice_description(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                deviceTable.addCell(cell);
            }
        }
        document.add(deviceTable);

        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(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 Sybaseexcel/*w  ww .  ja v  a2s.  c o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_SybaseCldXls(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");
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");

        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;
        int row = 15;
        tmpLabel = new Label(0, row, "", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "MB", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "MB ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "(%)", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;

        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {

            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, db_name, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, db_size, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, db_freesize, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, db_usedperc, p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        row = row + 2;

        // 
        tmpLabel = new Label(0, row, " ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, "(MB)", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "(MB) ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "Metadata(MB)", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "(MB) ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "(MB) ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, "(%)", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, sysbaseVO.getTotal_dataCache(), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, sysbaseVO.getTotal_physicalMemory(), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, sysbaseVO.getMetadata_cache(), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, sysbaseVO.getProcedure_cache(), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, sysbaseVO.getTotal_logicalMemory(), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, row, sysbaseVO.getData_hitrate(), p_labelFormat);
        sheet.addCell(tmpLabel);
        row++;

        // Sysbase 
        tmpLabel = new Label(0, row, "Sysbase   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List serverlist = (List) sysbaseVO.getServersInfo();
        if (serverlist != null && serverlist.size() > 0) {
            for (int k = 0; k < serverlist.size(); k++) {
                TablesVO tVO = (TablesVO) serverlist.get(k);
                tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, tVO.getServer_name(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, tVO.getServer_network_name(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, tVO.getServer_class(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, tVO.getServer_status(), p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        row = row + 2;

        // Sysbase 
        tmpLabel = new Label(0, row, "Sysbase   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "id   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, row, "  ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List userlist = (List) sysbaseVO.getUserInfo();
        if (userlist != null && userlist.size() > 0) {
            for (int k = 0; k < userlist.size(); k++) {
                TablesVO tVO = (TablesVO) userlist.get(k);
                tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, tVO.getUsers_name(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, tVO.getID_in_db(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, tVO.getGroup_name(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, tVO.getLogin_name(), p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        row = row + 2;

        // Sysbase 
        tmpLabel = new Label(0, row, "Sysbase   ", labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        tmpLabel = new Label(0, row, " ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, row, "   ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, row, "    ", b_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, row, "    ", b_labelFormat);
        sheet.addCell(tmpLabel);
        row++;
        List devicelist = (List) sysbaseVO.getDeviceInfo();
        if (devicelist != null && devicelist.size() > 0) {
            for (int k = 0; k < devicelist.size(); k++) {
                TablesVO tVO = (TablesVO) devicelist.get(k);
                tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, tVO.getDevice_name(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, tVO.getDevice_physical_name(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, tVO.getDevice_description(), p_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
            }
        }
        row = row + 2;

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

        // 
        addEventListToExcel(sheet, row);

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

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

/**
 * @author HONGLI Informix doc/*from   w  ww.  j  a  v a2  s  .  co  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportInformixSelfDoc(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 dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

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

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

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        /*
         * 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"));
        // Informix
        Table spaceTable = new Table(8);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidth(100); //  90%
        spaceTable.setAlignment(Element.ALIGN_CENTER);// 
        spaceTable.setAutoFillEmptyCells(true); // 
        spaceTable.setBorderWidth(1); // 
        spaceTable.setBorderColor(new Color(0, 125, 255)); // 
        spaceTable.setPadding(2);// 
        spaceTable.setSpacing(0);// 
        spaceTable.setBorder(2);// 
        cell = new Cell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();
        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    cell = new Cell(new Phrase((i + 1) + ""));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%",
                            contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);

                }
            }
        }
        document.add(spaceTable);

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

        document.add(hhTable);

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

        document.add(lockTable);

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

            document.add(img1);
        }

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