Example usage for java.util Hashtable size

List of usage examples for java.util Hashtable size

Introduction

In this page you can find the example usage for java.util Hashtable size.

Prototype

public synchronized int size() 

Source Link

Document

Returns the number of keys in this hashtable.

Usage

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

public void createReport_sqlall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*w ww  . j av  a 2s.  com*/
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        Hashtable allreporthash = new Hashtable();
        allreporthash = reportHash;
        if (allreporthash != null && allreporthash.size() > 0) {
            Iterator keys = allreporthash.keySet().iterator();
            String ip = "";
            int sheetNum = 0;
            while (keys.hasNext()) {
                ip = keys.next().toString();
                String newip = doip(ip);
                Hashtable report_has = (Hashtable) allreporthash.get(ip);
                String dbname = (String) report_has.get("dbname");
                WritableSheet sheet = wb.createSheet(dbname + "", sheetNum);
                sheetNum = sheetNum + 1;
                Hashtable dbValue = new Hashtable();
                // Vector tableinfo_v = new Vector();
                if (report_has.get("dbValue") != null)
                    dbValue = (Hashtable) report_has.get("dbValue");
                // Hashtable CPU = (Hashtable)report_has.get("CPU");
                String Ping = (String) report_has.get("Ping");

                // Calendar colTime = (Calendar)report_has.get("time");
                // Date cc = colTime.getTime();
                // Hashtable Memory = (Hashtable)report_has.get("Memory");
                // Hashtable Disk = (Hashtable)report_has.get("Disk");

                // Hashtable memMaxHash =
                // (Hashtable)report_has.get("memmaxhash");
                // Hashtable memAvgHash =
                // (Hashtable)report_has.get("memavghash");
                Hashtable maxping = (Hashtable) report_has.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, dbname + "", labelFormat);
                sheet.addCell(tmpLabel);
                String reporttime = (String) report_has.get("reporttime");
                if (reporttime == null || reporttime.trim().length() == 0) {
                    tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
                } else {
                    tmpLabel = new Label(0, 1, ":" + reporttime);
                }

                sheet.addCell(tmpLabel);
                String starttime = (String) report_has.get("starttime");
                String totime = (String) report_has.get("totime");
                tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 4, "", b_labelFormat);
                sheet.addCell(tmpLabel);

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

                tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat);
                sheet.addCell(tmpLabel);
                File file = null;
                try {
                    // 
                    file = new File(ResourceCenter.getInstance().getSysPath() + "/images/jfreechart/" + newip
                            + "ConnectUtilization" + ".png");
                    // sheet,0,0,5,1,,,
                    // allRow = allRow+2;
                    sheet.addImage(new WritableImage(1, 6, 7, 7, file));
                    // allRow = allRow+7;
                } catch (Exception ex) {
                    ex.printStackTrace();
                }

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

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

                if (alldatabase != null && alldatabase.size() > 0) {
                    if (names == null)
                        names = new Vector();
                    for (int i = 0; i < names.size(); i++) {
                        String key = (String) names.get(i);
                        if (alldatabase.get(key) == null)
                            continue;
                        Hashtable data = (Hashtable) alldatabase.get(key);
                        String _dbname = data.get("dbname").toString();
                        String size = data.get("size").toString();
                        String usedsize = "";
                        if (data.get("usedsize") != null) {
                            usedsize = data.get("usedsize").toString();
                        }
                        String usedperc = "";
                        if (data.get("usedperc") != null)
                            usedperc = data.get("usedperc").toString();
                        row = row + 1;
                        tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(1, row, _dbname, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(2, row, size, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(3, row, usedperc, p_labelFormat);
                        sheet.addCell(tmpLabel);
                    }
                }
            }
            wb.write();
        }

    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

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

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

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

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

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

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

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

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

            document.add(img1);
        }

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

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

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

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

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

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

        // 

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

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

            document.add(img1);
        }

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

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

public void createReport_sqlall2(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*from  ww w  .  java  2  s. c o m*/
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        Hashtable allreporthash = new Hashtable();
        allreporthash = reportHash;
        if (allreporthash != null && allreporthash.size() > 0) {
            Iterator keys = allreporthash.keySet().iterator();
            String ip = "";
            int sheetNum = 0;
            while (keys.hasNext()) {
                ip = keys.next().toString();
                String newip = doip(ip);
                Hashtable report_has = (Hashtable) allreporthash.get(ip);
                // reportHash = report_has;
                String hostname = (String) report_has.get("dbname");
                WritableSheet sheet = wb.createSheet(hostname + "", sheetNum);
                sheetNum++;
                String Ping = (String) report_has.get("Ping");
                String starttime = (String) report_has.get("starttime");
                String totime = (String) report_has.get("totime");
                Hashtable mems = (Hashtable) report_has.get("mems");// 
                Hashtable sysValue = (Hashtable) report_has.get("sysValue");// 
                String typename = (String) report_has.get("typename");
                String runstr = (String) report_has.get("runstr");
                String grade = (String) report_has.get("grade");
                String pingnow = (String) report_has.get("pingnow");
                String pingmin = (String) report_has.get("pingmin");
                String pingconavg = (String) report_has.get("pingconavg");
                DBVo vo = (DBVo) report_has.get("vo");
                Hashtable maxping = (Hashtable) report_has.get("ping");

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

                Label tmpLabel = null;
                this.dbTitlePing(sheet, ip, report_has);
                int row = 18;
                // 
                tmpLabel = new Label(0, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, "SQL", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 1, row);
                sheet.mergeCells(2, row, 3, row);
                sheet.mergeCells(4, row, 5, row);
                sheet.mergeCells(6, row, 7, row);
                sheet.mergeCells(8, row, 10, row);
                row++;
                tmpLabel = new Label(0, row, (String) mems.get("totalMemory"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, (String) mems.get("optMemory"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, (String) mems.get("conMemory"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, (String) mems.get("sqlMem"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, (String) mems.get("lockMem"), p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 1, row);
                sheet.mergeCells(2, row, 3, row);
                sheet.mergeCells(4, row, 5, row);
                sheet.mergeCells(6, row, 7, row);
                sheet.mergeCells(8, row, 10, row);
                row += 2;
                // 
                tmpLabel = new Label(0, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 1, row);
                sheet.mergeCells(2, row, 4, row);
                sheet.mergeCells(5, row, 7, row);
                sheet.mergeCells(8, row, 10, row);
                row++;
                tmpLabel = new Label(0, row, (String) sysValue.get("productlevel"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, (String) sysValue.get("IsIntegratedSecurityOnly"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, (String) sysValue.get("IsSingleUser"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, (String) sysValue.get("IsClustered"), p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 1, row);
                sheet.mergeCells(2, row, 4, row);
                sheet.mergeCells(5, row, 7, row);
                sheet.mergeCells(8, row, 10, row);

                row += 2;
                // 
                tmpLabel = new Label(0, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, "(MB)", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, "(MB)", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, row, "(%)", b_labelFormat);
                sheet.addCell(tmpLabel);

                sheet.mergeCells(0, row, 1, row);
                sheet.mergeCells(2, row, 3, row);
                sheet.mergeCells(4, row, 5, row);
                sheet.mergeCells(6, row, 7, row);
                sheet.mergeCells(8, row, 10, row);
                // 
                Hashtable dbValue = (Hashtable) report_has.get("tableinfo_v");
                Hashtable alldatabase = new Hashtable();
                if (dbValue.get("database") != null)
                    alldatabase = (Hashtable) dbValue.get("database");
                Vector names = new Vector();
                if (dbValue.get("names") != null)
                    names = (Vector) dbValue.get("names");

                if (alldatabase != null && alldatabase.size() > 0) {
                    if (names == null)
                        names = new Vector();
                    for (int i = 0; i < names.size(); i++) {
                        String key = (String) names.get(i);
                        if (alldatabase.get(key) == null)
                            continue;
                        Hashtable data = (Hashtable) alldatabase.get(key);
                        String dbname = data.get("dbname").toString();
                        String size = data.get("size").toString();
                        String usedsize = "";
                        if (data.get("usedsize") != null) {
                            usedsize = data.get("usedsize").toString();
                        }
                        String usedperc = "";
                        if (data.get("usedperc") != null)
                            usedperc = data.get("usedperc").toString();
                        row = row + 1;
                        p_labelFormat = this.colorChange(i);
                        tmpLabel = new Label(0, row, i + "", p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(2, row, dbname, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(4, row, size, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(6, row, usedsize, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(8, row, usedperc, p_labelFormat);
                        sheet.addCell(tmpLabel);

                        sheet.mergeCells(0, row, 1, row);
                        sheet.mergeCells(2, row, 3, row);
                        sheet.mergeCells(4, row, 5, row);
                        sheet.mergeCells(6, row, 7, row);
                        sheet.mergeCells(8, row, 10, row);
                    }
                }
                //    
                row = row + 2;
                this.addEventReport(sheet, report_has, row);
                row += 2;
                // 
                this.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) {
                        SysLogger.error("", 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) {
            SysLogger.error("", e);
        }
    }
}

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

/**
 * MODIFY HONGLI 2010-10-27//  w  w w . j a v  a 2  s . co m
 */
public void createReport_oraPDF(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);
        Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");

        Hashtable 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, contextFont1);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        PdfPTable aTable = new PdfPTable(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon")));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);

        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.MIDDLE);// 
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));
        // HONGLI MODIFY START1
        PdfPTable aTable1 = new PdfPTable(12);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // HONGLI MODIFY END1
        aTable1.setWidths(width);
        aTable1.setWidthPercentage(100);
        aTable1.setHeaderRows(1);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("MB", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("MB", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        // HONGLI ADD START1
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        // HONGLI ADD END1
        cell = new PdfPCell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");

        // HONGLI ADD START2
        Hashtable dbio = (Hashtable) reportHash.get("dbio");
        // HONGLI ADD END2

        int row = 0;
        for (int i = 0; i < tableinfo_v.size(); i++) {
            Hashtable ht = (Hashtable) tableinfo_v.get(i);
            String _filename = ht.get("file_name").toString();
            String tablespace = ht.get("tablespace").toString();
            String size = ht.get("size_mb").toString();
            String free = ht.get("free_mb").toString();
            String percent = ht.get("percent_free").toString();
            String status = ht.get("status").toString();

            // HONGLI ADD START3
            String pyr = "";
            String pbr = "";
            String pyw = "";
            String pbw = "";
            if (dbio.containsKey(_filename)) {
                Hashtable iodetail = (Hashtable) dbio.get(_filename);
                if (iodetail != null && iodetail.size() > 0) {
                    pyr = (String) iodetail.get("pyr");
                    pbr = (String) iodetail.get("pbr");
                    pyw = (String) iodetail.get("pyw");
                    pbw = (String) iodetail.get("pbw");
                }
            }
            // HONGLI ADD END3

            aTable1.addCell(new Phrase(""));
            row = i + 1;
            String rowStr = "" + row;
            cell = new PdfPCell(new Phrase(rowStr));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(_filename));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(tablespace));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(size));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(free));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(percent));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            // HONGLI ADD START4
            cell = new PdfPCell(new Phrase(pyr));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(pbr));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(pyw));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new PdfPCell(new Phrase(pbw));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            // HONGLI ADD END4
            cell = new PdfPCell(new Phrase(status));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);

        }

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

            document.add(img1);
        }

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

}

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

public void createReport_monthnetworkall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//from  w ww  . java  2s  .c om
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        Hashtable allreporthash = new Hashtable();
        allreporthash = reportHash;
        if (allreporthash != null && allreporthash.size() > 0) {
            Iterator keys = allreporthash.keySet().iterator();
            String ip = "";
            int sheetNum = 0;
            while (keys.hasNext()) {
                ip = keys.next().toString();
                Hashtable report_has = (Hashtable) allreporthash.get(ip);
                String hostname = (String) report_has.get("equipname");
                WritableSheet sheet = wb.createSheet(hostname + "", sheetNum);
                sheetNum = sheetNum + 1;

                Hashtable CPU = (Hashtable) report_has.get("CPU");
                String Ping = (String) report_has.get("Ping");
                String newip = doip(ip);
                Calendar colTime = Calendar.getInstance();
                Date cc = colTime.getTime();
                Vector netifVector = (Vector) report_has.get("netifVector");
                Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash");
                List reportports = (List) report_has.get("reportports");
                Vector iprouterVector = (Vector) report_has.get("iprouterVector");

                // Hashtable Memory = (Hashtable)report_has.get("Memory");
                // Hashtable Disk = (Hashtable)report_has.get("Disk");
                // String hostname = (String)report_has.get("equipname");
                Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash");
                Hashtable maxping = (Hashtable) report_has.get("ping");

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

                String[] netIfItemch = { "", "", "", "(M)", "", "",
                        "" };
                String[] ipRouterItemch = { "", "", "", "", "",
                        "" };
                String[] memoryItem = { "Capability", "Utilization" };
                String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" };
                String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)",
                        "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)",
                        "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" };

                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);
                String reporttime = (String) report_has.get("reporttime");
                if (reporttime == null || reporttime.trim().length() == 0) {
                    tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
                } else {
                    tmpLabel = new Label(0, 1, ":" + reporttime);
                }
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 2, ":" + sdf.format(cc));
                sheet.addCell(tmpLabel);

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

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

                tmpLabel = new Label(0, 14, "CPU", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 14, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 14, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 15, (String) CPU.get("cpumax"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 15, (String) CPU.get("avgcpu"), p_labelFormat);
                sheet.addCell(tmpLabel);

                int allRow = 15;

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

                if (netifVector != null && netifVector.size() > 0) {
                    allRow = allRow + 1;
                    tmpLabel = new Label(0, allRow, "", b_labelFormat);
                    sheet.addCell(tmpLabel);
                    // 
                    // allRow = allRow;
                    for (int i = 0; i < netIfItemch.length; i++) {
                        Label label = new Label(i + 1, allRow, netIfItemch[i], _labelFormat);
                        sheet.addCell(label);
                    }
                    // 
                    for (int i = 0; i < netifVector.size(); i++) {
                        allRow = allRow + 1;

                        String[] strs = (String[]) netifVector.get(i);
                        String ifname = strs[1];
                        String index = strs[0];
                        for (int j = 0; j < strs.length; j++) {

                            if (j == 1) {
                                String linkuse = "";
                                if (portconfigHash != null && portconfigHash.size() > 0) {
                                    if (portconfigHash.get(ip + ":" + index) != null)
                                        linkuse = (String) portconfigHash.get(ip + ":" + index);
                                }
                                Label label = new Label(j + 1, allRow, strs[j], p_labelFormat);
                                sheet.addCell(label);
                                label = new Label(j + 2, allRow, linkuse, p_labelFormat);
                                sheet.addCell(label);

                            } else if (j > 1) {
                                Label label = new Label(j + 2, allRow, strs[j], p_labelFormat);
                                sheet.addCell(label);
                            } else {
                                Label label = new Label(j + 1, allRow, strs[j], p_labelFormat);
                                sheet.addCell(label);
                            }
                        } // end 

                    }
                }

                if (iprouterVector != null && iprouterVector.size() > 0) {

                    allRow = allRow + 2;
                    tmpLabel = new Label(0, allRow, "", b_labelFormat);
                    sheet.addCell(tmpLabel);
                    // 
                    // allRow = allRow+1;
                    for (int i = 0; i < ipRouterItemch.length; i++) {
                        Label label = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat);
                        sheet.addCell(label);
                    }

                    // 

                    for (int i = 0; i < iprouterVector.size(); i++) {
                        allRow = allRow + 1;
                        IpRouter iprouter = (IpRouter) iprouterVector.get(i);
                        Label label = new Label(1, allRow, iprouter.getIfindex(), p_labelFormat);
                        sheet.addCell(label);
                        label = new Label(2, allRow, iprouter.getDest(), p_labelFormat);
                        sheet.addCell(label);
                        label = new Label(3, allRow, iprouter.getNexthop(), p_labelFormat);
                        sheet.addCell(label);
                        label = new Label(4, allRow,
                                iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")],
                                p_labelFormat);
                        sheet.addCell(label);
                        label = new Label(5, allRow,
                                iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")],
                                p_labelFormat);
                        sheet.addCell(label);
                        label = new Label(6, allRow, iprouter.getMask(), p_labelFormat);
                        sheet.addCell(label);
                    }
                }
                allRow = allRow + 2;
                if (reportports != null && reportports.size() > 0) {
                    // 
                    for (int i = 0; i < reportports.size(); i++) {
                        Portconfig portconfig = (Portconfig) reportports.get(i);
                        tmpLabel = new Label(0, allRow,
                                "" + portconfig.getPortindex() + "(" + portconfig.getName() + ")",
                                b_labelFormat);
                        sheet.addCell(tmpLabel);
                        if (portconfig.getLinkuse() == null)
                            portconfig.setLinkuse("");
                        tmpLabel = new Label(1, allRow, ":" + portconfig.getLinkuse());
                        sheet.addCell(tmpLabel);
                        // 
                        file = new File(
                                ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                                        + newip + portconfig.getPortindex() + "ifspeed_day.png");
                        // sheet,0,0,5,1,,,
                        allRow = allRow + 1;
                        sheet.addImage(new WritableImage(1, allRow, 8, 7, file));
                        allRow = allRow + 8;
                    }
                }
                if (impReport.getChart() != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    try {
                        ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                                impReport.getChart().getWidth(), impReport.getChart().getHeight());
                    } catch (IOException ioe) {
                    }
                    WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
                    sheet.addImage(wi);
                }
                wb.write();
            }
        }
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

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

public void createReport_monthhostall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//ww  w  .j a  v  a2s . c o  m
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        Hashtable allreporthash = new Hashtable();
        allreporthash = reportHash;
        if (allreporthash != null && allreporthash.size() > 0) {
            Iterator keys = allreporthash.keySet().iterator();
            String ip = "";
            int sheetNum = 0;
            while (keys.hasNext()) {
                ip = keys.next().toString();
                String newip = doip(ip);
                Hashtable report_has = (Hashtable) allreporthash.get(ip);
                String hostname = (String) report_has.get("equipname");
                WritableSheet sheet = wb.createSheet(hostname + "", sheetNum);
                sheetNum = sheetNum + 1;
                Hashtable CPU = (Hashtable) report_has.get("CPU");
                String Ping = (String) report_has.get("Ping");
                Calendar colTime = Calendar.getInstance();
                Date cc = colTime.getTime();
                Hashtable Memory = (Hashtable) report_has.get("Memory");
                Hashtable Disk = (Hashtable) report_has.get("Disk");

                Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash");
                Hashtable memAvgHash = (Hashtable) report_has.get("memavghash");
                Hashtable maxping = (Hashtable) report_has.get("ping");

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

                String[] memoryItemch = { "", "", "" };
                String[] memoryItem = { "Capability" };
                String[] diskItem = { "AllSize", "UsedSize", "Utilization" };
                String[] diskItemch = { "", "", "" };

                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);
                String reporttime = (String) report_has.get("reporttime");
                if (reporttime == null || reporttime.trim().length() == 0) {
                    tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
                } else {
                    tmpLabel = new Label(0, 1, ":" + reporttime);
                }

                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 2, ":" + sdf.format(cc));
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 4, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 4, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 4, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat);
                sheet.addCell(tmpLabel);

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

                tmpLabel = new Label(0, 14, "CPU", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 14, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 14, "", _labelFormat);
                sheet.addCell(tmpLabel);
                if (CPU == null) {
                    tmpLabel = new Label(1, 15, "", p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(2, 15, "", p_labelFormat);
                    sheet.addCell(tmpLabel);
                } else {
                    tmpLabel = new Label(1, 15, (String) CPU.get("cpumax"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(2, 15, (String) CPU.get("avgcpu"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                }

                int allRow = 15;

                // 
                file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                        + newip + "cpu_month" + ".png");
                // sheet,0,0,5,1,,,
                allRow = allRow + 2;
                sheet.addImage(new WritableImage(1, allRow, 7, 7, file));
                allRow = allRow + 6;
                int memoryRow = 0;
                if (Memory != null && Memory.size() > 0) {
                    memoryRow = Memory.size();
                    allRow = allRow + 2;
                    tmpLabel = new Label(0, allRow, "", b_labelFormat);
                    sheet.addCell(tmpLabel);
                    // 
                    allRow = allRow;
                    Label label = new Label(1, allRow, "", _labelFormat);
                    sheet.addCell(label);
                    for (int i = 0; i < memoryItemch.length; i++) {
                        label = new Label(i + 2, allRow, memoryItemch[i], _labelFormat);
                        sheet.addCell(label);
                    }
                    // 
                    for (int i = 0; i < Memory.size(); i++) {
                        Hashtable mhash = (Hashtable) (Memory.get(new Integer(i)));
                        String name = (String) mhash.get("name");
                        allRow = allRow + 1;
                        label = new Label(1, allRow, name);
                        sheet.addCell(label);

                        for (int j = 0; j < memoryItem.length; j++) {
                            String value = "";
                            if (mhash != null) {
                                if (mhash.get(memoryItem[j]) != null) {
                                    value = (String) mhash.get(memoryItem[j]);
                                }
                            }
                            label = new Label(j + 2, allRow, value, p_labelFormat);
                            sheet.addCell(label);
                        }

                        String value = "";
                        if (memMaxHash != null) {
                            if (memMaxHash.get(name) != null) {
                                value = (String) memMaxHash.get(name);
                                label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat);
                                sheet.addCell(label);
                            }
                        } else {
                            label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat);
                            sheet.addCell(label);
                        }
                        String avgvalue = "";
                        if (memAvgHash != null) {
                            if (memAvgHash.get(name) != null) {
                                avgvalue = (String) memAvgHash.get(name);
                                label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat);
                                sheet.addCell(label);
                            }
                        } else {
                            label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat);
                            sheet.addCell(label);
                        }

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

                }
                if (Disk != null && Disk.size() > 0) {
                    // memoryRow = Disk.size();
                    allRow = allRow + 1 + 7;
                    tmpLabel = new Label(0, allRow, "", b_labelFormat);
                    sheet.addCell(tmpLabel);
                    // 
                    allRow = allRow;
                    Label label = new Label(1, allRow, "", _labelFormat);
                    // CellFormat cf = new CellFormat();
                    // label.setCellFormat(cf)

                    sheet.addCell(label);
                    for (int i = 0; i < diskItemch.length; i++) {
                        label = new Label(i + 2, allRow, diskItemch[i], _labelFormat);
                        sheet.addCell(label);
                    }
                    // 

                    for (int i = 0; i < Disk.size(); i++) {
                        Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i)));
                        if (diskhash != null && diskhash.size() > 0) {
                            String name = (String) diskhash.get("name");
                            if (name == null)
                                name = "";
                            allRow = allRow + 1;
                            label = new Label(1, allRow, name);
                            sheet.addCell(label);
                            for (int j = 0; j < diskItem.length; j++) {
                                String value = "";
                                if (diskhash.get(diskItem[j]) != null) {
                                    value = (String) diskhash.get(diskItem[j]);
                                }
                                label = new Label(j + 2, allRow, value, p_labelFormat);
                                sheet.addCell(label);
                            }
                        }
                    } // end 
                      // 
                    file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                            + newip + "disk" + ".png");
                    // sheet,0,0,5,1,,,
                    sheet.addImage(new WritableImage(1, allRow + 2, 9, 9, file));

                    /*
                     * 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,40, 8, 12, baos.toByteArray());
                     * sheet.addImage(wi); }
                     */
                }

            }
            wb.write();
        }

    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
        }
    }
}

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

public void createReport_oraDoc(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;//from ww  w. ja  v  a2 s.  com
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");

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

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

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

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

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

        // HONGLI MODIFY START1
        Table aTable1 = new Table(12);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // HONGLI MODIFY END1

        aTable1.setWidths(width);
        aTable1.setWidth(100); //  90%
        aTable1.setAlignment(Element.ALIGN_CENTER);// 
        aTable1.setAutoFillEmptyCells(true); // 
        aTable1.setBorderWidth(1); // 
        aTable1.setBorderColor(new Color(0, 125, 255)); // 
        aTable1.setPadding(2);// 
        aTable1.setSpacing(0);// 
        aTable1.setBorder(2);// 

        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // HONGLI ADD START1
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // HONGLI ADD END1

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

        // 
        Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");

        // HONGLI ADD START2
        Hashtable dbio = (Hashtable) reportHash.get("dbio");
        // HONGLI ADD END2

        int row = 0;
        for (int i = 0; i < tableinfo_v.size(); i++) {
            Hashtable ht = (Hashtable) tableinfo_v.get(i);
            String _filename = ht.get("file_name").toString();
            String tablespace = ht.get("tablespace").toString();
            String size = ht.get("size_mb").toString();
            String free = ht.get("free_mb").toString();
            String percent = ht.get("percent_free").toString();
            String status = ht.get("status").toString();

            // HONGLI ADD START3
            String pyr = "";
            String pbr = "";
            String pyw = "";
            String pbw = "";
            if (dbio.containsKey(_filename)) {
                Hashtable iodetail = (Hashtable) dbio.get(_filename);
                if (iodetail != null && iodetail.size() > 0) {
                    pyr = (String) iodetail.get("pyr");
                    pbr = (String) iodetail.get("pbr");
                    pyw = (String) iodetail.get("pyw");
                    pbw = (String) iodetail.get("pbw");
                }
            }
            // HONGLI ADD END3

            aTable1.addCell("");
            row = i + 1;
            String rowStr = "" + row;
            cell = new Cell(new Phrase(rowStr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(_filename, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(tablespace, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(size, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(free, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(percent, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);

            // HONGLI ADD START4
            cell = new Cell(new Phrase(pyr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pbr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pyw, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pbw, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            // HONGLI ADD END4

            cell = new Cell(new Phrase(status, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);

        }

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

            document.add(img1);
        }

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

}

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

public void createReport_networkall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//  ww w. j av  a  2 s .  c om
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        Hashtable allreporthash = new Hashtable();
        allreporthash = reportHash;
        if (allreporthash != null && allreporthash.size() > 0) {
            Iterator keys = allreporthash.keySet().iterator();
            String ip = "";
            int sheetNum = 0;
            CellView cv = new CellView();
            cv.setAutosize(true);
            while (keys.hasNext()) {
                ip = keys.next().toString();
                Hashtable report_has = (Hashtable) allreporthash.get(ip);
                String hostname = (String) report_has.get("equipname");
                WritableSheet sheet = wb.createSheet(hostname + "", sheetNum);
                // for (int i = 0; i < 8; i++) {
                // // 
                // sheet.setColumnView(i, cv);
                // }
                sheetNum = sheetNum + 1;

                Hashtable CPU = (Hashtable) report_has.get("CPU");
                String Ping = (String) report_has.get("Ping");
                String newip = doip(ip);
                Calendar colTime = Calendar.getInstance();
                Date cc = colTime.getTime();
                Vector netifVector = (Vector) report_has.get("netifVector");
                int netiSize = 0;
                int iprouterSize = 0;
                if (netifVector != null) {
                    netiSize = netifVector.size();
                }
                Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash");
                List reportports = (List) report_has.get("reportports");
                Vector iprouterVector = (Vector) report_has.get("iprouterVector");
                if (iprouterVector != null) {
                    iprouterSize = iprouterVector.size();
                }

                // Hashtable Memory = (Hashtable)report_has.get("Memory");
                // Hashtable Disk = (Hashtable)report_has.get("Disk");
                // String hostname = (String)report_has.get("equipname");
                Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash");
                Hashtable maxping = (Hashtable) report_has.get("ping");
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                String[] netIfItemch = { "", "", "", "(M)", "", "",
                        "" };
                String[] ipRouterItemch = { "", "", "", "", "",
                        "" };
                String[] memoryItem = { "Capability", "Utilization" };
                String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize",
                        "INodeUtilization" };
                String[] diskItemch = { "", "", "", "i-node", "i-node" };
                String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" };
                String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)",
                        "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)",
                        "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" };

                WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12,
                        WritableFont.BOLD, false);
                WritableCellFormat labelFormat = new WritableCellFormat(labelFont);
                labelFormat.setAlignment(Alignment.CENTRE);
                labelFormat.setBackground(Colour.GREY_25_PERCENT);
                labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,
                        jxl.format.Colour.BLACK);
                WritableCellFormat _labelFormat = new WritableCellFormat();
                _labelFormat.setBackground(jxl.format.Colour.GRAY_25);
                _labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,
                        jxl.format.Colour.BLACK);
                WritableCellFormat p_labelFormat = new WritableCellFormat();
                p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE);
                // 
                p_labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,
                        jxl.format.Colour.BLACK);
                WritableCellFormat p_labelFormat1 = new WritableCellFormat();
                // 
                p_labelFormat1.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,
                        jxl.format.Colour.BLACK);
                WritableCellFormat b_labelFormat = new WritableCellFormat();
                // 
                b_labelFormat.setAlignment(Alignment.CENTRE);
                // 
                b_labelFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
                b_labelFormat.setBackground(jxl.format.Colour.GREY_25_PERCENT);
                b_labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,
                        jxl.format.Colour.BLACK);
                Label tmpLabel = null;
                tmpLabel = new Label(0, 0, hostname + "", labelFormat);
                sheet.addCell(tmpLabel);
                String reporttime = (String) report_has.get("reporttime");
                if (reporttime == null || reporttime.trim().length() == 0) {
                    tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
                } else {
                    tmpLabel = new Label(0, 1, ":" + reporttime);
                }
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 2, ":" + sdf.format(cc));
                sheet.addCell(tmpLabel);

                tmpLabel = new Label(0, 4, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 4, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 4, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 4, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(1, 4, 2, 4);
                sheet.mergeCells(3, 4, 4, 4);
                sheet.mergeCells(5, 4, 7, 4);
                sheet.mergeCells(1, 5, 2, 5);
                if (maxping != null) {
                    tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    sheet.mergeCells(3, 5, 4, 5);
                    sheet.mergeCells(5, 5, 7, 5);
                }

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

                tmpLabel = new Label(0, 14, "CPU", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 14, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 14, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 14, "", _labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 15, (String) CPU.get("cpu") + "%", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 15, (String) CPU.get("cpumax"), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 15, (String) CPU.get("avgcpu"), p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(1, 14, 2, 14);
                sheet.mergeCells(3, 14, 4, 14);
                sheet.mergeCells(5, 14, 7, 14);
                sheet.mergeCells(1, 15, 2, 15);
                sheet.mergeCells(3, 15, 4, 15);
                sheet.mergeCells(5, 15, 7, 15);
                int allRow = 15;

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

                if (netifVector != null && netifVector.size() > 0) {
                    allRow = allRow + 1;
                    tmpLabel = new Label(0, allRow, "", b_labelFormat);
                    sheet.addCell(tmpLabel);
                    // 
                    // allRow = allRow;
                    for (int i = 0; i < netIfItemch.length; i++) {
                        Label label = new Label(i + 1, allRow, netIfItemch[i], _labelFormat);
                        sheet.addCell(label);
                    }
                    // 
                    for (int i = 0; i < netifVector.size(); i++) {
                        allRow = allRow + 1;

                        String[] strs = (String[]) netifVector.get(i);
                        String ifname = strs[1];
                        String index = strs[0];
                        for (int j = 0; j < strs.length; j++) {

                            if (j == 1) {
                                String linkuse = "";
                                if (portconfigHash != null && portconfigHash.size() > 0) {
                                    if (portconfigHash.get(ip + ":" + index) != null)
                                        linkuse = (String) portconfigHash.get(ip + ":" + index);
                                }
                                Label label = new Label(j + 1, allRow, strs[j],
                                        i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                                sheet.addCell(label);
                                label = new Label(j + 2, allRow, linkuse,
                                        i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                                sheet.addCell(label);

                            } else if (j > 1) {
                                Label label = new Label(j + 2, allRow, strs[j],
                                        i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                                sheet.addCell(label);
                            } else {
                                Label label = new Label(j + 1, allRow, strs[j],
                                        i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                                sheet.addCell(label);
                            }
                        } // end 

                    }
                }

                if (iprouterVector != null && iprouterVector.size() > 0) {

                    allRow = allRow + 2;
                    tmpLabel = new Label(0, allRow, "", b_labelFormat);
                    sheet.addCell(tmpLabel);
                    // 
                    // allRow = allRow+1;
                    for (int i = 0; i < ipRouterItemch.length; i++) {
                        Label label = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat);
                        sheet.addCell(label);
                        if (i == ipRouterItemch.length - 1) {
                            Label labeledn = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat);
                            sheet.addCell(labeledn);
                        }
                        sheet.mergeCells(ipRouterItemch.length, allRow, ipRouterItemch.length + 1, allRow);
                    }

                    // 

                    for (int i = 0; i < iprouterVector.size(); i++) {
                        allRow = allRow + 1;
                        IpRouter iprouter = (IpRouter) iprouterVector.get(i);
                        Label label = new Label(1, allRow, iprouter.getIfindex(),
                                i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                        sheet.addCell(label);
                        label = new Label(2, allRow, iprouter.getDest(),
                                i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                        sheet.addCell(label);
                        label = new Label(3, allRow, iprouter.getNexthop(),
                                i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                        sheet.addCell(label);
                        label = new Label(4, allRow,
                                iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")],
                                i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                        sheet.addCell(label);
                        label = new Label(5, allRow,
                                iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")],
                                i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                        sheet.addCell(label);
                        label = new Label(6, allRow, iprouter.getMask(),
                                i % 2 == 0 ? p_labelFormat : p_labelFormat1);
                        sheet.addCell(label);
                        sheet.mergeCells(6, allRow, 7, allRow);
                    }
                }
                allRow = allRow + 2;
                if (reportports != null && reportports.size() > 0) {
                    // 
                    for (int i = 0; i < reportports.size(); i++) {
                        com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports
                                .get(i);
                        tmpLabel = new Label(0, allRow,
                                "" + portconfig.getPortindex() + "(" + portconfig.getName() + ")",
                                b_labelFormat);
                        sheet.addCell(tmpLabel);
                        if (portconfig.getLinkuse() == null)
                            portconfig.setLinkuse("");
                        tmpLabel = new Label(1, allRow, ":" + portconfig.getLinkuse());
                        sheet.addCell(tmpLabel);
                        // 
                        file = new File(
                                ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                                        + newip + portconfig.getPortindex() + "ifspeed_day.png");
                        // sheet,0,0,5,1,,,
                        allRow = allRow + 1;
                        sheet.addImage(new WritableImage(1, allRow, 8, 7, file));
                        allRow = allRow + 8;
                    }
                }
                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);
                }
                // 
                sheet.mergeCells(0, 0, 7, 0);
                sheet.mergeCells(0, 1, 7, 1);
                sheet.mergeCells(0, 2, 7, 2);
                sheet.mergeCells(0, 4, 0, 12);
                sheet.mergeCells(0, 14, 0, 22);
                sheet.mergeCells(0, 24, 0, 24 + netiSize);
                sheet.mergeCells(0, 24 + netiSize + 1 + 1, 0, 24 + netiSize + 1 + 1 + iprouterSize);
            }
            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

public void createReport_oraall2(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*w w  w. ja v a  2s .co m*/
        return;
    }
    WritableWorkbook wb = null;
    try {
        // fileName = ResourceCenter.getInstance().getSysPath() +
        // "temp\\dhcnms_report.xls";
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        Hashtable allreport_has = new Hashtable();
        allreport_has = reportHash;
        if (allreport_has != null && allreport_has.size() > 0) {
            Iterator keys = allreport_has.keySet().iterator();
            String ip = "";
            int sheetNum = 0;
            while (keys.hasNext()) {
                ip = keys.next().toString();
                String newip = doip(ip);
                Hashtable report_has = (Hashtable) allreport_has.get(ip);
                reportHash = report_has;
                fileName = ResourceCenter.getInstance().getSysPath() + filename;
                wb = Workbook.createWorkbook(new File(fileName));
                String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" };
                String[] sysItemch1 = { "", "", "", "Java" };
                String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated",
                        "maximum_PGA_allocated" };
                String[] sysItemch2 = { "PGA", "PGA", "PGA" };
                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");
                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 buffercache = "0";// 
                String dictionarycache = "0";// 
                String librarycache = "0";// 
                String pctmemorysorts = "0";// 
                String pctbufgets = "0";// 10
                String opencurstr = "0";// 
                Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue");
                Hashtable memValue = (Hashtable) reportHash.get("memValue");
                Hashtable cursors = (Hashtable) reportHash.get("cursors");
                if (cursors == null) {
                    cursors = new Hashtable();
                }
                if (memPerfValue == null)
                    memPerfValue = new Hashtable();
                if (memPerfValue != null) {
                    if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) {
                        buffercache = (String) memPerfValue.get("buffercache") + "%";
                    }
                    if (memPerfValue.containsKey("dictionarycache")
                            && memPerfValue.get("dictionarycache") != null) {
                        dictionarycache = (String) memPerfValue.get("dictionarycache") + "%";
                    }
                    if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) {
                        librarycache = (String) memPerfValue.get("librarycache") + "%";
                    }
                    if (memPerfValue.containsKey("pctmemorysorts")
                            && memPerfValue.get("pctmemorysorts") != null) {
                        pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%";
                    }
                    if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) {
                        pctbufgets = (String) memPerfValue.get("pctbufgets") + "%";
                    }
                    if (cursors.containsKey("opencur") && cursors.get("opencur") != null) {
                        opencurstr = (String) cursors.get("opencur");
                    }
                }

                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;
                // ip
                this.dbTitlePing(sheet, ip, reportHash);
                int row = 18;
                // 
                tmpLabel = new Label(0, row, "   ", labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 10, row);
                row++;
                tmpLabel = new Label(0, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, "10", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(1, row, 2, row);
                sheet.mergeCells(3, row, 4, row);
                sheet.mergeCells(5, row, 6, row);
                sheet.mergeCells(7, row, 8, row);
                sheet.mergeCells(9, row, 10, row);
                row++;
                tmpLabel = new Label(0, row, buffercache, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, dictionarycache, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, librarycache, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, pctmemorysorts, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, pctbufgets, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, opencurstr, p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(1, row, 2, row);
                sheet.mergeCells(3, row, 4, row);
                sheet.mergeCells(5, row, 6, row);
                sheet.mergeCells(7, row, 8, row);
                sheet.mergeCells(9, row, 10, row);

                // 
                row += 2;
                tmpLabel = new Label(0, row, "", labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 10, row);
                row++;
                tmpLabel = new Label(0, row, sysItemch2[0], b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, sysItemch2[1], b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, sysItemch2[2], b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, sysItemch1[0], b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, sysItemch1[1], b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, sysItemch1[2], b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, sysItemch1[3], b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(3, row, 4, row);
                sheet.mergeCells(5, row, 6, row);
                sheet.mergeCells(7, row, 8, row);
                sheet.mergeCells(9, row, 10, row);
                row++;
                tmpLabel = new Label(0, row, memValue.get(sysItem2[0]) + "MB", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, memValue.get(sysItem2[1]) + "MB", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, row, memValue.get(sysItem2[2]) + "MB", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, memValue.get(sysItem1[0]) + "MB", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, memValue.get(sysItem1[1]) + "MB", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, memValue.get(sysItem1[2]) + "MB", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, memValue.get(sysItem1[3]) + "MB", p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(3, row, 4, row);
                sheet.mergeCells(5, row, 6, row);
                sheet.mergeCells(7, row, 8, row);
                sheet.mergeCells(9, row, 10, row);

                // 
                row += 2;
                tmpLabel = new Label(0, row, "", labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 10, row);
                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, "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);

                // HONGLI ADD START1
                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);
                // HONGLI ADD END1

                // HONGLI MODIFY START1
                tmpLabel = new Label(10, row, "", b_labelFormat);
                // HONGLI MODIFY END1

                sheet.addCell(tmpLabel);

                // 
                row = row++;
                Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");

                // HONGLI ADD START2
                Hashtable dbio = (Hashtable) reportHash.get("dbio");
                // HONGLI ADD END2

                for (int i = 0; i < tableinfo_v.size(); i++) {
                    p_labelFormat = super.colorChange(i);
                    Hashtable ht = (Hashtable) tableinfo_v.get(i);
                    String _filename = ht.get("file_name").toString();
                    String tablespace = ht.get("tablespace").toString();
                    String size = ht.get("size_mb").toString();
                    String free = ht.get("free_mb").toString();
                    String percent = ht.get("percent_free").toString();
                    String status = ht.get("status").toString();

                    // HONGLI ADD START3
                    String pyr = "";
                    String pbr = "";
                    String pyw = "";
                    String pbw = "";
                    if (dbio.containsKey(_filename)) {
                        Hashtable iodetail = (Hashtable) dbio.get(_filename);
                        if (iodetail != null && iodetail.size() > 0) {
                            pyr = (String) iodetail.get("pyr");
                            pbr = (String) iodetail.get("pbr");
                            pyw = (String) iodetail.get("pyw");
                            pbw = (String) iodetail.get("pbw");
                        }
                    }
                    // HONGLI ADD END3

                    tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(1, row, _filename, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(2, row, tablespace, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(3, row, size, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(4, row, free, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(5, row, percent, p_labelFormat);
                    sheet.addCell(tmpLabel);

                    // HONGLI ADD START4
                    tmpLabel = new Label(6, row, pyr, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(7, row, pbr, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(8, row, pyw, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    tmpLabel = new Label(9, row, pbw, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    // HONGLI ADD END4
                    tmpLabel = new Label(10, row, status, p_labelFormat);
                    sheet.addCell(tmpLabel);
                    row++;
                }
                //    
                row++;
                this.addEventReport(sheet, report_has, row);
                row += 2;
                // 
                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) {
                        SysLogger.error("", ioe);
                    }
                    WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
                    sheet.addImage(wi);
                }
                sheetNum++;
            }
            wb.write();
        }
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
            SysLogger.error("", e);
        }
    }
}