Example usage for org.jfree.chart ChartUtilities writeChartAsPNG

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

Introduction

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

Prototype

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

Source Link

Document

Writes a chart to an output stream in PNG format.

Usage

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

public void createReport_netevent(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//w w w . ja  v  a  2  s. c o  m
        return;
    }
    WritableWorkbook wb = null;
    try {
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));

        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        WritableSheet sheet = wb.createSheet("", 0);
        List memlist = (List) reportHash.get("eventlist");

        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(0, 0, "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime, labelFormat1);
        sheet.addCell(tmpLabel);
        sheet.mergeCells(0, 0, 11, 0);
        sheet.mergeCells(0, 1, 11, 1);
        sheet.mergeCells(0, 2, 11, 2);
        tmpLabel = new Label(0, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 4, "IP", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(9, 4, "CPU", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(10, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(11, 4, "", _labelFormat);

        sheet.addCell(tmpLabel);

        // I_MonitorIpList monitorManager=new MonitoriplistManager();
        int row = 5;
        if (memlist != null && memlist.size() > 0) {
            for (int i = 0; i < memlist.size(); i++) {
                p_labelFormat = super.colorChange(i);
                List mlist = (List) memlist.get(i);
                row = row + (i);
                tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, 5 + i, (String) mlist.get(7), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, 5 + i, (String) mlist.get(8), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(10, 5 + i, (String) mlist.get(9), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(11, 5 + i, (String) mlist.get(10), p_labelFormat);
                sheet.addCell(tmpLabel);
            }
        }

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
            sheet.addImage(wi);
        }

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

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

public void createReport_networkWithoutClose(String filename, WritableWorkbook wb) {

    if (impReport.getTable() == null) {
        fileName = null;//from   w  ww.jav  a  2s . co  m
        return;
    }
    String hostname = (String) reportHash.get("equipname");
    try {
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        // wb = Workbook.createWorkbook(new File(fileName));
        WritableSheet sheet = wb.createSheet(hostname + "", 0);
        Hashtable CPU = (Hashtable) reportHash.get("CPU");
        String Ping = (String) reportHash.get("Ping");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Calendar colTime = (Calendar) reportHash.get("time");
        Date cc = colTime.getTime();
        Vector netifVector = (Vector) reportHash.get("netifVector");
        Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash");
        List reportports = (List) reportHash.get("reportports");
        Vector iprouterVector = (Vector) reportHash.get("iprouterVector");

        Hashtable Memory = (Hashtable) reportHash.get("Memory");
        Hashtable Disk = (Hashtable) reportHash.get("Disk");

        Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
        Hashtable maxping = (Hashtable) reportHash.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);

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

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

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

        Label tmpLabel = null;
        tmpLabel = new Label(1, 0, hostname + "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ":" + 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(3, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 5, (String) maxping.get("pingmax"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 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(3, 14, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 15, (String) CPU.get("cpu") + "%", p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 15, (String) CPU.get("cpumax"), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 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++) {
                // SysLogger.info(reportports.get(i).getClass()+"=============================================");
                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 ( reportports != null && reportports.size()>0){ //
         * for(int i =0;i<reportports.size();i++){ Portconfig portconfig =
         * (Portconfig)reportports.get(i); //  file = new
         * File(CommonAppUtil.getAppName()+"/images/jfreechart/"+newip+portconfig.getPortindex()+"ifspeed_day.png");
         * //sheet,0,0,5,1,,, allRow =
         * allRow+2; sheet.addImage(new WritableImage(1,allRow,8,7,file));
         * allRow = allRow+7; } }
         */
        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_network(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*from   ww  w .  ja v  a2  s .  c o  m*/
        return;
    }
    WritableWorkbook wb = null;
    try {
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        String runmodel = PollingEngine.getCollectwebflag(); // 
        WritableSheet sheet = wb.createSheet("", 0);
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Vector netifVector = (Vector) reportHash.get("netifVector");
        Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash");
        List reportports = (List) reportHash.get("reportports");
        Vector iprouterVector = (Vector) reportHash.get("iprouterVector");
        String hostname = (String) reportHash.get("equipname");

        String[] netIfItemch = { "", "", "", "(M)", "", "",
                "" };
        String[] ipRouterItemch = { "", "", "", "", "", "" };
        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)" };
        createReportTitle(sheet, reportHash);
        createPingAndCpu(sheet, ip, reportHash);
        Label tmpLabel = null;
        int allRow = 23;
        if (netifVector != null && netifVector.size() > 0) {
            allRow = allRow + 1;
            tmpLabel = new Label(0, allRow, "", b_labelFormat);
            sheet.addCell(tmpLabel);
            sheet.mergeCells(0, allRow, 0, allRow + netifVector.size());
            // 
            // allRow = allRow;
            Label label = null;
            label = new Label(1, allRow, netIfItemch[0], _labelFormat);
            sheet.addCell(label);
            label = new Label(2, allRow, netIfItemch[1], _labelFormat);
            sheet.mergeCells(2, allRow, 3, allRow);
            sheet.addCell(label);
            label = new Label(4, allRow, netIfItemch[2], _labelFormat);
            sheet.addCell(label);
            sheet.mergeCells(4, allRow, 5, allRow);
            label = new Label(6, allRow, netIfItemch[3], _labelFormat);
            sheet.addCell(label);
            label = new Label(7, allRow, netIfItemch[4], _labelFormat);
            sheet.addCell(label);
            label = new Label(8, allRow, netIfItemch[5], _labelFormat);
            sheet.addCell(label);
            label = new Label(9, allRow, netIfItemch[6], _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];
                p_labelFormat = super.colorChange(i);
                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 = new Label(j + 1, allRow, strs[j], p_labelFormat);
                        sheet.addCell(label);
                        sheet.mergeCells(j + 1, allRow, j + 2, allRow);
                        label = new Label(j + 3, allRow, linkuse, p_labelFormat);
                        sheet.addCell(label);
                        sheet.mergeCells(j + 3, allRow, j + 3 + 1, allRow);
                    } else if (j > 1) {
                        label = new Label(j + 4, allRow, strs[j], p_labelFormat);
                        sheet.addCell(label);
                    } else {
                        label = new Label(j + 1, allRow, strs[j], p_labelFormat);
                        sheet.addCell(label);
                    }
                } // end 
            }
        }
        if ("0".equals(runmodel)) {
            if (iprouterVector != null && iprouterVector.size() > 0) {
                allRow = allRow + 2;
                tmpLabel = new Label(0, allRow, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, allRow, 0, allRow + iprouterVector.size());
                // 
                // 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 == 2) {
                        break;
                    }
                }
                Label label = new Label(4, allRow, ipRouterItemch[3], _labelFormat);
                sheet.addCell(label);
                label = new Label(6, allRow, ipRouterItemch[4], _labelFormat);
                sheet.addCell(label);
                label = new Label(8, allRow, ipRouterItemch[5], _labelFormat);
                sheet.addCell(label);
                sheet.mergeCells(4, allRow, 5, allRow);
                sheet.mergeCells(6, allRow, 7, allRow);
                sheet.mergeCells(8, allRow, 9, allRow);
                // 

                for (int i = 0; i < iprouterVector.size(); i++) {
                    p_labelFormat = super.colorChange(i);
                    allRow = allRow + 1;
                    IpRouter iprouter = (IpRouter) iprouterVector.get(i);
                    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(6, allRow,
                            iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")],
                            p_labelFormat);
                    sheet.addCell(label);
                    label = new Label(8, allRow, iprouter.getMask(), p_labelFormat);
                    sheet.addCell(label);
                    sheet.mergeCells(4, allRow, 5, allRow);
                    sheet.mergeCells(6, allRow, 7, allRow);
                    sheet.mergeCells(8, allRow, 9, allRow);
                }
            }
        } else {
            // 
            // allRow = allRow+1;
            List routeList = (ArrayList) reportHash.get("routerList");
            if (routeList != null) {
                allRow = allRow + 2;
                tmpLabel = new Label(0, allRow, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, allRow, 0, allRow + routeList.size());
                for (int i = 0; i < routeList.size(); i++) {
                    allRow = allRow + 1;
                    RouterNodeTemp iprouter = (RouterNodeTemp) routeList.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, iprouter.getType(), p_labelFormat);
                    sheet.addCell(label);
                    label = new Label(6, allRow, iprouter.getProto(), p_labelFormat);
                    sheet.addCell(label);
                    label = new Label(8, allRow, iprouter.getMask(), p_labelFormat);
                    sheet.addCell(label);
                    sheet.mergeCells(4, allRow, 5, allRow);
                    sheet.mergeCells(6, allRow, 7, allRow);
                    sheet.mergeCells(8, allRow, 9, allRow);
                }
            }
        }

        allRow = allRow + 2;
        if (reportports != null && reportports.size() > 0) {
            // 
            for (int i = 0; i < reportports.size(); i++) {
                // SysLogger.info(reportports.get(i).getClass()+"=============================================");
                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 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 ( reportports != null && reportports.size()>0){ //
         * for(int i =0;i<reportports.size();i++){ Portconfig portconfig =
         * (Portconfig)reportports.get(i); //  file = new
         * File(CommonAppUtil.getAppName()+"/images/jfreechart/"+newip+portconfig.getPortindex()+"ifspeed_day.png");
         * //sheet,0,0,5,1,,, allRow =
         * allRow+2; sheet.addImage(new WritableImage(1,allRow,8,7,file));
         * allRow = allRow+7; } }
         */
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
            sheet.addImage(wi);
        }
        wb.write();
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
            SysLogger.error("", e);
        }
    }
}

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

public void createReport_networkall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*  w  ww.ja  va 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_monthnetworkall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//  w  w w.jav 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 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_syball2(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//from   ww w .j  a v  a  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);

                String hostname = (String) report_has.get("dbname");
                WritableSheet sheet = wb.createSheet(hostname + "", 0);
                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");
                SybaseVO sysbaseVO = (SybaseVO) report_has.get("sysbaseVO");

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

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

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

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

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

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

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

                // 
                tmpLabel = new Label(0, 7, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 7, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 7, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat);
                sheet.addCell(tmpLabel);

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

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

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

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

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

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

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

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

                // 
                WritableCellFormat red_labelFormat = new WritableCellFormat();
                WritableCellFormat orange_labelFormat = new WritableCellFormat();
                WritableCellFormat yellow_labelFormat = new WritableCellFormat();

                red_labelFormat.setBackground(jxl.format.Colour.RED);
                orange_labelFormat.setBackground(jxl.format.Colour.ORANGE);
                yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW);

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

                        tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat);
                        sheet.addCell(tmpLabel);
                        if ("3".equals(level)) {
                            tmpLabel = new Label(1, row, showlevel, red_labelFormat);
                            sheet.addCell(tmpLabel);
                        } else if ("2".equals(level)) {
                            tmpLabel = new Label(1, row, showlevel, orange_labelFormat);
                            sheet.addCell(tmpLabel);
                        } else {
                            tmpLabel = new Label(1, row, showlevel, yellow_labelFormat);
                            sheet.addCell(tmpLabel);
                        }
                        tmpLabel = new Label(2, row, content, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(3, row, rtime1, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(4, row, rptman, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(5, row, status, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        row++;
                    }
                }

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

    } catch (Exception e) {
        // SysLogger.error("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_informixall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*from  www  .j a v a 2  s.  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 hostname = (String) report_has.get("dbname");
                WritableSheet sheet = wb.createSheet(hostname + "", 0);
                String Ping = (String) report_has.get("Ping");
                String starttime = (String) report_has.get("starttime");
                String totime = (String) report_has.get("totime");
                Hashtable dbinfo = new Hashtable();
                dbinfo = (Hashtable) report_has.get("dbValue");
                Hashtable maxping = (Hashtable) report_has.get("ping");

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

                this.dbTitlePing(sheet, ip, report_has);
                int row = 18;
                Label tmpLabel = null;
                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, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, "  ", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(5, row, 6, row);
                sheet.mergeCells(7, row, 8, row);
                sheet.mergeCells(9, row, 10, row);
                row++;
                // 
                ArrayList dbspaces = new ArrayList();
                if (dbinfo != null) {
                    dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
                }
                if (dbspaces != null) {
                    if (dbspaces.size() > 0) {
                        DecimalFormat df = new DecimalFormat("#.###");
                        for (int i = 0; i < dbspaces.size(); i++) {
                            p_labelFormat = this.colorChange(i);
                            Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                            tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(1, row, (String) tablesVO.get("dbspace"), p_labelFormat);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(2, row, (String) tablesVO.get("owner"), p_labelFormat);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(3, row, (String) tablesVO.get("fname"), p_labelFormat);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(4, row,
                                    df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M",
                                    p_labelFormat);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(5, row,
                                    df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M",
                                    p_labelFormat);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(7, row,
                                    df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M",
                                    p_labelFormat);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(9, row,
                                    df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%",
                                    p_labelFormat);
                            sheet.addCell(tmpLabel);
                            sheet.mergeCells(5, row, 6, row);
                            sheet.mergeCells(7, row, 8, row);
                            sheet.mergeCells(9, row, 10, row);
                            row++;
                        }
                    }
                }
                row = row + 2;
                // Informix
                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, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, row, "  ", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(5, row, 6, row);
                sheet.mergeCells(7, row, 8, row);
                sheet.mergeCells(9, row, 10, row);
                row++;
                List dbsession = (ArrayList) dbinfo.get("sessionList");// 
                if (dbsession != null && dbsession.size() > 0) {
                    for (int i = 0; i < dbsession.size(); i++) {
                        p_labelFormat = this.colorChange(i);
                        Hashtable tablesVO = (Hashtable) dbsession.get(i);
                        String seqscans = String.valueOf(tablesVO.get("seqscans"));
                        if ("null".equals(seqscans)) {
                            seqscans = "";
                        }
                        String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                        if ("null".equals(total_sorts)) {
                            total_sorts = "";
                        }
                        String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                        if ("null".equals(dsksorts)) {
                            dsksorts = "";
                        }
                        tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(3, row, tablesVO.get("access") + "", p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(4, row, tablesVO.get("locksheld") + "", p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(5, row, seqscans, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(7, row, total_sorts, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(9, row, dsksorts, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        sheet.mergeCells(5, row, 6, row);
                        sheet.mergeCells(7, row, 8, row);
                        sheet.mergeCells(9, row, 10, row);
                        row++;
                    }
                }

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

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

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

/**
 * mysql xls/*from  w  w w  .  jav a 2s  .c o m*/
 * 
 * @param filename
 */
public void createReport_mysqlall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;
        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("dbname");
                WritableSheet sheet = wb.createSheet(hostname + "", 0);
                String Ping = (String) report_has.get("Ping");
                String starttime = (String) report_has.get("starttime");
                String totime = (String) report_has.get("totime");
                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");
                Vector val = (Vector) report_has.get("Val");
                if (val == null) {
                    val = new Vector();
                }
                List sessionlist = (ArrayList) report_has.get("sessionlist");
                if (sessionlist == null) {
                    sessionlist = new ArrayList();
                }
                Hashtable tablesHash = (Hashtable) report_has.get("tablesHash");
                if (tablesHash == null) {
                    tablesHash = new Hashtable();
                }
                Vector tableinfo_v = (Vector) report_has.get("tableinfo_v");
                if (tableinfo_v == null) {
                    tableinfo_v = new Vector();
                }
                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(0, 0, hostname + "", labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime, labelFormat1);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, 0, 6, 0);
                sheet.mergeCells(0, 1, 6, 1);
                sheet.mergeCells(0, 2, 6, 2);
                // ip
                tmpLabel = new Label(0, 4, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 4, "IP", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 4, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 4, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 4, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(3, 4, 4, 4);
                sheet.mergeCells(5, 4, 6, 4);
                tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 5, ip, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 5, typename, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 5, runstr, p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 5, grade, p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(3, 5, 4, 5);
                sheet.mergeCells(5, 5, 6, 5);

                // 
                tmpLabel = new Label(0, 7, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 7, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 7, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, 7, 1, 7);
                sheet.mergeCells(2, 7, 4, 7);
                sheet.mergeCells(5, 7, 6, 7);
                tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 8, pingmin + "%", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 8, pingconavg + "%", p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, 8, 1, 8);
                sheet.mergeCells(2, 8, 4, 8);
                sheet.mergeCells(5, 8, 6, 8);

                // 
                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(0, 9, 7, 7, file));
                // allRow = allRow+7;

                tmpLabel = new Label(0, 18, " ", b_labelFormat);
                sheet.mergeCells(0, 18, 6, 18);
                sheet.addCell(tmpLabel);
                int row = 19;
                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";
                            }
                            p_labelFormat = super.colorChange(i);
                            tmpLabel = new Label(0, row, name, p_labelFormat);
                            sheet.mergeCells(0, row, 4, row);
                            sheet.addCell(tmpLabel);
                            tmpLabel = new Label(5, row, value, p_labelFormat);
                            sheet.addCell(tmpLabel);
                            sheet.mergeCells(5, row, 6, row);
                            row++;
                        }
                    }
                }
                // 
                row = row + 2;
                tmpLabel = new Label(0, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 6, 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, " ", b_labelFormat);
                sheet.mergeCells(3, row, 4, row);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                row++;
                if (sessionlist != null && sessionlist.size() > 0) {
                    for (int i = 0; i < sessionlist.size(); i++) {
                        List ipsessionlist = (List) sessionlist.get(i);
                        if (ipsessionlist != null && ipsessionlist.size() > 0) {
                            for (int k = 0; k < ipsessionlist.size(); k++) {
                                String[] sessions = (String[]) ipsessionlist.get(k);
                                if (sessions != null && sessions.length == 5) {
                                    p_labelFormat = super.colorChange(k);
                                    tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat);
                                    sheet.addCell(tmpLabel);
                                    tmpLabel = new Label(1, row, sessions[4], p_labelFormat);
                                    sheet.addCell(tmpLabel);
                                    tmpLabel = new Label(2, row, sessions[0], p_labelFormat);
                                    sheet.addCell(tmpLabel);
                                    tmpLabel = new Label(3, row, sessions[1], p_labelFormat);
                                    sheet.mergeCells(3, row, 4, row);
                                    sheet.addCell(tmpLabel);
                                    tmpLabel = new Label(5, row, sessions[2], p_labelFormat);
                                    sheet.addCell(tmpLabel);
                                    tmpLabel = new Label(6, row, sessions[3], p_labelFormat);
                                    sheet.addCell(tmpLabel);
                                    row++;
                                }

                            }
                        }
                    }
                }

                // 
                row = row + 2;
                tmpLabel = new Label(0, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 6, row);
                row++;
                tmpLabel = new Label(0, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, " ", b_labelFormat);
                sheet.mergeCells(1, row, 2, row);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, row, "   ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, "  ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, row, "  ", b_labelFormat);
                sheet.mergeCells(5, row, 6, row);
                sheet.addCell(tmpLabel);
                row++;
                String[] dbs = vo.getDbName().split(",");
                if (dbs != null && dbs.length > 0) {
                    for (int i = 0; i < dbs.length; i++) {
                        String dbStr = dbs[i];
                        // System.out.println(dbStr+"====="+tablesHash.size());
                        if (tablesHash.containsKey(dbStr)) {
                            List tableslist = (List) tablesHash.get(dbStr);
                            if (tableslist != null && tableslist.size() > 0) {
                                for (int k = 0; k < tableslist.size(); k++) {
                                    String[] tables = (String[]) tableslist.get(k);
                                    if (tables != null && tables.length == 4) {
                                        p_labelFormat = super.colorChange(k);
                                        tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat);
                                        sheet.addCell(tmpLabel);
                                        tmpLabel = new Label(1, row, tables[0], p_labelFormat);
                                        sheet.mergeCells(1, row, 2, row);
                                        sheet.addCell(tmpLabel);
                                        tmpLabel = new Label(3, row, tables[1], p_labelFormat);
                                        sheet.addCell(tmpLabel);
                                        tmpLabel = new Label(4, row, tables[2], p_labelFormat);
                                        sheet.addCell(tmpLabel);
                                        tmpLabel = new Label(5, row, tables[3], p_labelFormat);
                                        sheet.mergeCells(5, row, 6, row);
                                        sheet.addCell(tmpLabel);
                                        row++;
                                    }

                                }
                            }
                        }
                    }
                }

                // 
                row = row + 2;
                tmpLabel = new Label(0, row, "  ", b_labelFormat);
                sheet.mergeCells(0, row, 1, row);
                sheet.mergeCells(0, row, 6, row);
                sheet.addCell(tmpLabel);
                row++;
                tmpLabel = new Label(0, row, "  ", b_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, row, "  ", b_labelFormat);
                sheet.mergeCells(1, row, 3, row);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, row, "  ", b_labelFormat);
                sheet.mergeCells(4, row, 6, row);
                sheet.addCell(tmpLabel);
                row++;
                if (tableinfo_v != null) {// HONGLILI
                    for (int i = 0; i < tableinfo_v.size(); i++) {
                        Hashtable ht = (Hashtable) tableinfo_v.get(i);
                        String size = ht.get("variable_name").toString();
                        String free = ht.get("value").toString();
                        if (size.equalsIgnoreCase("auto_increment_increment")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("auto_increment_offset")) {
                            size = "AUTO_INCREMENT";
                        }
                        if (size.equalsIgnoreCase("automatic_sp_privileges")) {
                            size = "automatic_sp_privileges";
                        }
                        if (size.equalsIgnoreCase("back_log")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("basedir")) {
                            size = "MySQL";
                        }
                        if (size.equalsIgnoreCase("binlog_cache_size")) {
                            size = "SQL";
                        }
                        if (size.equalsIgnoreCase("bulk_insert_buffer_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("character_set_client")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("character_set_connection")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("character_set_database")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("character_set_filesystem")) {
                            size = "character_set_filesystem";
                        }
                        if (size.equalsIgnoreCase("character_set_results")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("character_set_server")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("character_set_system")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("character_sets_dir")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("collation_connection")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("collation_database")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("collation_server")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("completion_type")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("concurrent_insert")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("connect_timeout")) {
                            size = "Bad handshake";
                        }
                        if (size.equalsIgnoreCase("datadir")) {
                            size = "MySQL";
                        }
                        if (size.equalsIgnoreCase("date_format")) {
                            size = "date_format()";
                        }
                        if (size.equalsIgnoreCase("datetime_format")) {
                            size = "datetime_format()";
                        }
                        if (size.equalsIgnoreCase("default_week_format")) {
                            size = "WEEK() ";
                        }
                        if (size.equalsIgnoreCase("delay_key_write")) {
                            size = "DELAY_KEY_WRITE";
                        }
                        if (size.equalsIgnoreCase("delayed_insert_limit")) {
                            size = "INSERT DELAYEDSELECT";
                        }
                        if (size.equalsIgnoreCase("delayed_insert_timeout")) {
                            size = "INSERT DELAYEDINSERT";
                        }
                        if (size.equalsIgnoreCase("delayed_queue_size")) {
                            size = "INSERT DELAYED";
                        }
                        if (size.equalsIgnoreCase("div_precision_increment")) {
                            size = "/";
                        }
                        if (size.equalsIgnoreCase("engine_condition_pushdown")) {
                            size = "NDB";
                        }
                        if (size.equalsIgnoreCase("expire_logs_days")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("flush")) {
                            size = "flushmysqld";
                        }
                        if (size.equalsIgnoreCase("flush_time")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("ft_boolean_syntax")) {
                            size = "IN BOOLEAN MODE";
                        }
                        if (size.equalsIgnoreCase("ft_max_word_len")) {
                            size = "FULLTEXT";
                        }
                        if (size.equalsIgnoreCase("ft_min_word_len")) {
                            size = "FULLTEXT";
                        }
                        if (size.equalsIgnoreCase("ft_query_expansion_limit")) {
                            size = "WITH QUERY EXPANSION";
                        }
                        if (size.equalsIgnoreCase("ft_stopword_file")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("group_concat_max_len")) {
                            size = "GROUP_CONCAT()";
                        }
                        if (size.equalsIgnoreCase("have_archive")) {
                            size = "mysqldARCHIVE";
                        }
                        if (size.equalsIgnoreCase("have_bdb")) {
                            size = "mysqldBDB";
                        }
                        if (size.equalsIgnoreCase("have_blackhole_engine")) {
                            size = "mysqldBLACKHOLE";
                        }
                        if (size.equalsIgnoreCase("have_compress")) {
                            size = "zlib";
                        }
                        if (size.equalsIgnoreCase("have_crypt")) {
                            size = "crypt()";
                        }
                        if (size.equalsIgnoreCase("have_csv")) {
                            size = "mysqldARCHIVE";
                        }
                        if (size.equalsIgnoreCase("have_example_engine")) {
                            size = "mysqldEXAMPLE";
                        }
                        if (size.equalsIgnoreCase("have_federated_engine")) {
                            size = "mysqldFEDERATED";
                        }
                        if (size.equalsIgnoreCase("have_geometry")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("have_innodb")) {
                            size = "mysqldInnoDB";
                        }
                        if (size.equalsIgnoreCase("have_isam")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("have_ndbcluster")) {
                            size = "mysqldNDB CLUSTER";
                        }
                        if (size.equalsIgnoreCase("have_openssl")) {
                            size = "mysqld/SSL()";
                        }
                        if (size.equalsIgnoreCase("have_query_cache")) {
                            size = "mysqld";
                        }
                        if (size.equalsIgnoreCase("have_raid")) {
                            size = "mysqldRAID";
                        }
                        if (size.equalsIgnoreCase("have_rtree_keys")) {
                            size = "RTREE";
                        }
                        if (size.equalsIgnoreCase("have_symlink")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("init_connect")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("init_file")) {
                            size = "--init-file";
                        }
                        if (size.equalsIgnoreCase("init_slave")) {
                            size = "SQL";
                        }
                        if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_autoextend_increment")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) {
                            size = "32WindowsAWE";
                        }
                        if (size.equalsIgnoreCase("innodb_buffer_pool_size")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_checksums")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_commit_concurrency")) {
                            size = "innodb_commit_concurrency";
                        }
                        if (size.equalsIgnoreCase("innodb_concurrency_tickets")) {
                            size = "innodb_concurrency_tickets";
                        }
                        if (size.equalsIgnoreCase("innodb_data_file_path")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("innodb_data_home_dir")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_doublewrite")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_fast_shutdown")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_file_io_threads")) {
                            size = "InnoDBI/O";
                        }
                        if (size.equalsIgnoreCase("innodb_file_per_table")) {
                            size = "InnoDB.ibd";
                        }
                        if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_flush_method")) {
                            size = "InnoDBfsync()";
                        }
                        if (size.equalsIgnoreCase("innodb_force_recovery")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_log_arch_dir")) {
                            size = " ";
                        }
                        if (size.equalsIgnoreCase("innodb_log_archive")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("innodb_log_buffer_size")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_log_file_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("innodb_log_files_in_group")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("innodb_log_group_home_dir")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_max_purge_lag")) {
                            size = "INSERT,UPDATEDELETE";
                        }
                        if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("innodb_open_files")) {
                            size = "InnoDB.ibd";
                        }
                        if (size.equalsIgnoreCase("innodb_support_xa")) {
                            size = "InnoDBXA";
                        }
                        if (size.equalsIgnoreCase("innodb_sync_spin_loops")) {
                            size = "innodb_sync_spin_loops";
                        }
                        if (size.equalsIgnoreCase("innodb_table_locks")) {
                            size = "InnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_thread_concurrency")) {
                            size = "InnoDBInnoDB";
                        }
                        if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) {
                            size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status";
                        }
                        if (size.equalsIgnoreCase("interactive_timeout")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("join_buffer_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("key_buffer_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("key_cache_age_threshold")) {
                            size = "(sub-chain)(sub-chain)";
                        }
                        if (size.equalsIgnoreCase("key_cache_block_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("key_cache_division_limit")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("language")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("large_files_support")) {
                            size = "mysqld";
                        }
                        if (size.equalsIgnoreCase("large_page_size")) {
                            size = "large_page_size";
                        }
                        if (size.equalsIgnoreCase("large_pages")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("license")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("local_infile")) {
                            size = "LOCALLOAD DATA INFILE";
                        }
                        if (size.equalsIgnoreCase("log")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("log_bin")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("log_bin_trust_function_creators")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("log_error")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("log_slave_updates")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("log_slow_queries")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("log_warnings")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("long_query_time")) {
                            size = "Slow_queries";
                        }
                        if (size.equalsIgnoreCase("low_priority_updates")) {
                            size = "sqlSELECTLOCK TABLE READ";
                        }
                        if (size.equalsIgnoreCase("lower_case_file_system")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("lower_case_table_names")) {
                            size = "1";
                        }
                        if (size.equalsIgnoreCase("max_allowed_packet")) {
                            size = "/";
                        }
                        if (size.equalsIgnoreCase("max_binlog_cache_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("max_binlog_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("max_connect_errors")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("max_connections")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("max_delayed_threads")) {
                            size = "INSERT DELAYED";
                        }
                        if (size.equalsIgnoreCase("max_error_count")) {
                            size = "SHOW ERRORSSHOW WARNINGS";
                        }
                        if (size.equalsIgnoreCase("max_heap_table_size")) {
                            size = "MEMORY (HEAP)";
                        }
                        if (size.equalsIgnoreCase("max_insert_delayed_threads")) {
                            size = "INSERT DELAYED(max_delayed_threads)";
                        }
                        if (size.equalsIgnoreCase("max_join_size")) {
                            size = "max_join_size";
                        }
                        if (size.equalsIgnoreCase("max_length_for_sort_data")) {
                            size = "filesort";
                        }
                        if (size.equalsIgnoreCase("max_prepared_stmt_count")) {
                            size = "max_prepared_stmt_count";
                        }
                        if (size.equalsIgnoreCase("max_relay_log_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("max_seeks_for_key")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("max_sort_length")) {
                            size = "BLOBTEXT";
                        }
                        if (size.equalsIgnoreCase("max_sp_recursion_depth")) {
                            size = "max_sp_recursion_depth";
                        }
                        if (size.equalsIgnoreCase("max_tmp_tables")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("max_user_connections")) {
                            size = "MySQL";
                        }
                        if (size.equalsIgnoreCase("max_write_lock_count")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("multi_range_count")) {
                            size = "multi_range_count";
                        }
                        if (size.equalsIgnoreCase("myisam_data_pointer_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("myisam_max_sort_file_size")) {
                            size = "MyISAMMySQL";
                        }
                        if (size.equalsIgnoreCase("myisam_recover_options")) {
                            size = "myisam-recover";
                        }
                        if (size.equalsIgnoreCase("myisam_repair_threads")) {
                            size = "1Repair by sortingMyISAM";
                        }
                        if (size.equalsIgnoreCase("myisam_sort_buffer_size")) {
                            size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM";
                        }
                        if (size.equalsIgnoreCase("myisam_stats_method")) {
                            size = "MyISAMNULL";
                        }
                        if (size.equalsIgnoreCase("named_pipe")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("net_buffer_length")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("net_read_timeout")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("net_retry_count")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("net_write_timeout")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("new")) {
                            size = "MySQL 4.04.1";
                        }
                        if (size.equalsIgnoreCase("old_passwords")) {
                            size = "MySQLpre-4.1-style";
                        }
                        if (size.equalsIgnoreCase("open_files_limit")) {
                            size = "mysqld";
                        }
                        if (size.equalsIgnoreCase("optimizer_prune_level")) {
                            size = " 0";
                        }
                        if (size.equalsIgnoreCase("optimizer_search_depth")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("pid_file")) {
                            size = "ID (PID)";
                        }
                        if (size.equalsIgnoreCase("prepared_stmt_count")) {
                            size = "prepared_stmt_count";
                        }
                        if (size.equalsIgnoreCase("port")) {
                            size = "TCP/IP";
                        }
                        if (size.equalsIgnoreCase("preload_buffer_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("protocol_version")) {
                            size = "MySQL/";
                        }
                        if (size.equalsIgnoreCase("query_alloc_block_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("query_cache_limit")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("query_cache_min_res_unit")) {
                            size = "()";
                        }
                        if (size.equalsIgnoreCase("query_cache_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("query_cache_type")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) {
                            size = "WRITE";
                        }
                        if (size.equalsIgnoreCase("query_prealloc_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("range_alloc_block_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("read_buffer_size")) {
                            size = "()";
                        }
                        if (size.equalsIgnoreCase("read_only")) {
                            size = "ON";
                        }
                        if (size.equalsIgnoreCase("read_only")) {
                            size = "ON";
                        }
                        if (size.equalsIgnoreCase("relay_log_purge")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("read_rnd_buffer_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("secure_auth")) {
                            size = "--secure-authMySQL(4.1)";
                        }
                        if (size.equalsIgnoreCase("shared_memory")) {
                            size = "(Windows)";
                        }
                        if (size.equalsIgnoreCase("shared_memory_base_name")) {
                            size = "(Windows)";
                        }
                        if (size.equalsIgnoreCase("server_id")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("skip_external_locking")) {
                            size = "mysqld";
                        }
                        if (size.equalsIgnoreCase("skip_networking")) {
                            size = "(TCP/IP)";
                        }
                        if (size.equalsIgnoreCase("skip_show_database")) {
                            size = "SHOW DATABASESSHOW DATABASES";
                        }
                        if (size.equalsIgnoreCase("slave_compressed_protocol")) {
                            size = "/";
                        }
                        if (size.equalsIgnoreCase("slave_load_tmpdir")) {
                            size = "LOAD DATA INFILE";
                        }
                        if (size.equalsIgnoreCase("slave_net_timeout")) {
                            size = "/";
                        }
                        if (size.equalsIgnoreCase("slave_skip_errors")) {
                            size = "()";
                        }
                        if (size.equalsIgnoreCase("slave_transaction_retries")) {
                            size = "SQLslave_transaction_retries";
                        }
                        if (size.equalsIgnoreCase("slow_launch_time")) {
                            size = "Slow_launch_threads";
                        }
                        if (size.equalsIgnoreCase("sort_buffer_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("sql_mode")) {
                            size = "SQL";
                        }
                        if (size.equalsIgnoreCase("storage_engine")) {
                            size = "table_typeisMySQL 5.1,storage_engine";
                        }
                        if (size.equalsIgnoreCase("sync_binlog")) {
                            size = "sync_binlog'thMySQL";
                        }
                        if (size.equalsIgnoreCase("sync_frm")) {
                            size = "1,.frm";
                        }
                        if (size.equalsIgnoreCase("system_time_zone")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("table_cache")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("table_type")) {
                            size = "()";
                        }
                        if (size.equalsIgnoreCase("thread_cache_size")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("thread_stack")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("time_format")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("time_zone")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("tmp_table_size")) {
                            size = "MySQLMyISAM";
                        }
                        if (size.equalsIgnoreCase("tmpdir")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("transaction_alloc_block_size")) {
                            size = "()";
                        }
                        if (size.equalsIgnoreCase("transaction_prealloc_size")) {
                            size = "transaction_alloc_blocks";
                        }
                        if (size.equalsIgnoreCase("tx_isolation")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("updatable_views_with_limit")) {
                            size = "LIMIT";
                        }
                        if (size.equalsIgnoreCase("version")) {
                            size = "";
                        }
                        if (size.equalsIgnoreCase("version_bdb")) {
                            size = "BDB";
                        }
                        if (size.equalsIgnoreCase("version_comment")) {
                            size = "configure--with-commentMySQL";
                        }
                        if (size.equalsIgnoreCase("version_compile_machine")) {
                            size = "MySQL";
                        }
                        if (size.equalsIgnoreCase("version_compile_os")) {
                            size = "MySQL";
                        }
                        if (size.equalsIgnoreCase("wait_timeout")) {
                            size = "";
                        }
                        p_labelFormat = super.colorChange(i);
                        tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(1, row, size, p_labelFormat);
                        sheet.mergeCells(1, row, 3, row);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(4, row, free, p_labelFormat);
                        sheet.mergeCells(4, row, 6, row);
                        sheet.addCell(tmpLabel);
                        row++;
                    }
                }

                //    
                row = row + 2;
                tmpLabel = new Label(0, row, "     ", labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 6, row);
                row++;
                tmpLabel = new Label(0, row, "", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 2, row);
                tmpLabel = new Label(3, row, " ", b_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(3, row, 6, row);
                row++;
                tmpLabel = new Label(0, row, (String) report_has.get("downnum"), p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(0, row, 2, row);
                tmpLabel = new Label(3, row, report_has.get("count") + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                sheet.mergeCells(3, row, 6, row);

                // 
                // 
                WritableCellFormat red_labelFormat = new WritableCellFormat();
                WritableCellFormat orange_labelFormat = new WritableCellFormat();
                WritableCellFormat yellow_labelFormat = new WritableCellFormat();

                red_labelFormat.setBackground(jxl.format.Colour.RED);
                orange_labelFormat.setBackground(jxl.format.Colour.ORANGE);
                yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW);

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

                        tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat);
                        sheet.addCell(tmpLabel);
                        if ("3".equals(level)) {
                            tmpLabel = new Label(1, row, showlevel, red_labelFormat);
                            sheet.addCell(tmpLabel);
                        } else if ("2".equals(level)) {
                            tmpLabel = new Label(1, row, showlevel, orange_labelFormat);
                            sheet.addCell(tmpLabel);
                        } else {
                            tmpLabel = new Label(1, row, showlevel, yellow_labelFormat);
                            sheet.addCell(tmpLabel);
                        }
                        tmpLabel = new Label(2, row, content, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        sheet.mergeCells(2, row, 3, row);
                        tmpLabel = new Label(4, row, rtime1, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(5, row, rptman, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        tmpLabel = new Label(6, row, status, p_labelFormat);
                        sheet.addCell(tmpLabel);
                        row++;
                    }
                }

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

    } catch (Exception e) {
        // SysLogger.error("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_dbevent(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//from   www  .  j  a v a  2  s .c o m
        return;
    }
    WritableWorkbook wb = null;
    try {
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));

        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        WritableSheet sheet = wb.createSheet("", 0);
        List memlist = (List) reportHash.get("eventlist");

        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(0, 0, "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime, labelFormat1);
        sheet.addCell(tmpLabel);
        sheet.mergeCells(0, 0, 9, 0);
        sheet.mergeCells(0, 1, 9, 1);
        sheet.mergeCells(0, 2, 9, 2);
        tmpLabel = new Label(0, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 4, "IP", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(6, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(7, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(8, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(9, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        // I_MonitorIpList monitorManager=new MonitoriplistManager();
        int row = 5;
        if (memlist != null && memlist.size() > 0) {
            for (int i = 0; i < memlist.size(); i++) {
                p_labelFormat = super.colorChange(i);
                List mlist = (List) memlist.get(i);
                row = row + (i);
                tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(5, 5 + i, String.valueOf(mlist.get(8)), // 
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(6, 5 + i, String.valueOf(mlist.get(5)), // 
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(7, 5 + i, String.valueOf(mlist.get(6)), // 
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(8, 5 + i, String.valueOf(mlist.get(7)), // 
                        p_labelFormat);
                sheet.addCell(tmpLabel);
                tmpLabel = new Label(9, 5 + i, (String) mlist.get(4), p_labelFormat);
                sheet.addCell(tmpLabel);
            }
        }

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
            sheet.addImage(wi);
        }

        wb.write();
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        try {
            if (wb != null)
                wb.close();
        } catch (Exception e) {
            SysLogger.error("", e);
        }
    }
}

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

public void createReport_SQLServerevent(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*from   w  w  w . j a va 2  s .co  m*/
        return;
    }
    WritableWorkbook wb = null;
    try {
        fileName = ResourceCenter.getInstance().getSysPath() + filename;
        wb = Workbook.createWorkbook(new File(fileName));
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        WritableSheet sheet = wb.createSheet("", 0);
        List memlist = (List) reportHash.get("eventlist");
        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, "", labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 2, ": " + starttime + "  " + totime);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 4, "IP", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, 4, "", _labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(0, 5, 1 + "", p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(1, 5, (String) memlist.get(0), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(2, 5, (String) memlist.get(1), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(3, 5, (String) memlist.get(1), p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(4, 5, "afunms", p_labelFormat);
        sheet.addCell(tmpLabel);
        tmpLabel = new Label(5, 5, (String) memlist.get(2), p_labelFormat);
        sheet.addCell(tmpLabel);

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