Example usage for org.apache.poi.ss.usermodel Workbook write

List of usage examples for org.apache.poi.ss.usermodel Workbook write

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Workbook write.

Prototype

void write(OutputStream stream) throws IOException;

Source Link

Document

Write out this workbook to an Outputstream.

Usage

From source file:com.skt.adcas.lte.action.DownLinkByNMSStatsAction.java

public String selectCellTrafficStatsCompExcelDownload() {

    this.log.debug("selectCellTrafficStatsCompExcelDownload Start");
    SqlSession session = null;//from   www  . java2s  .  co  m
    FileOutputStream fileOut = null;

    try {
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);
        Map<String, Object> mapAfter = gson.fromJson(this.JSONDATA2, type);

        log.debug("json data : " + this.JSONDATA);
        log.debug("json2 data : " + this.JSONDATA2);

        String searchType = this.SEARCHTYPE;

        Workbook wb = new HSSFWorkbook();
        //CreationHelper createHelper = wb.getCreationHelper();

        //sheet 
        String sheetName = "";
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet sheet = wb.createSheet(safeName);

        // Sheet ?
        createCellTrafficStatsExcelSheet(sheet, searchType, map);

        //After sheet 
        sheetName = "";
        safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet sheetAfter = wb.createSheet(safeName);

        // Sheet ?
        createCellTrafficStatsExcelSheet(sheetAfter, searchType, mapAfter);

        log.debug("selectCellTrafficStatsExcelDownload : file start");

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkStatsCompData(NMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);
        log.debug("selectCellTrafficStatsExcelDownload : file end");

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        if (session != null) {
            session.rollback();
        }
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (session != null) {
            session.close();
        }
    }

    this.log.debug("selectCellTrafficStatsCompExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByNMSStatsAction.java

public String selectCellTrafficStatsHistogramExcelDownload() {

    this.log.debug("selectCellTrafficStatsHistogramExcelDownload Start");
    SqlSession session = null;/* w  ww  . ja va2s  . co m*/
    FileOutputStream fileOut = null;

    try {
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        log.debug("json data : " + this.JSONDATA);

        Workbook wb = new HSSFWorkbook();
        //CreationHelper createHelper = wb.getCreationHelper();

        String sheetName = this.FROMYMD + "~" + this.TOYMD;
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);

        //sheet 
        Sheet sheet = wb.createSheet(safeName);

        //header ?
        Row hrow0 = sheet.createRow((short) 0);
        hrow0.setHeightInPoints(20);
        hrow0.createCell(0).setCellValue("MBPS");
        hrow0.createCell(1).setCellValue("COUNT");
        hrow0.createCell(2).setCellValue("??");
        hrow0.createCell(3).setCellValue("CDF");

        StringMap categoryVal = (StringMap) map.get("categoryVal");
        StringMap rVal = (StringMap) map.get("rVal");
        StringMap rate = (StringMap) map.get("rate");
        StringMap cdf = (StringMap) map.get("cdf");

        short i = 1;
        for (int j = 0; j < 10; j++) {
            //  
            Row row = sheet.createRow((short) i);
            row.setHeightInPoints(20);
            row.createCell(0).setCellValue(Double.parseDouble(categoryVal.get(String.valueOf(j)).toString()));
            row.createCell(1).setCellValue(Double.parseDouble(rVal.get(String.valueOf(j)).toString()));
            row.createCell(2).setCellValue(Double.parseDouble(rate.get(String.valueOf(j)).toString()));
            row.createCell(3).setCellValue(Double.parseDouble(cdf.get(String.valueOf(j)).toString()));
            i++;
        }

        log.debug("selectCellTrafficStatsHistogramExcelDownload : file start");

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkStatsHistogram(NMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);
        log.debug("selectCellTrafficStatsHistogramExcelDownload : file end");

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        if (session != null) {
            session.rollback();
        }
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (session != null) {
            session.close();
        }
    }

    this.log.debug("selectCellTrafficStatsHistogramExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByNMSStatsAction.java

public String selectCellTrafficStatsThrpCompGraphExcelDownload() {

    this.log.debug("selectCellTrafficStatsThrpCompGraphExcelDownload Start");
    SqlSession session = null;//from w ww. j  a v  a  2 s  .c  o m
    FileOutputStream fileOut = null;

    try {
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        log.debug("json data : " + this.JSONDATA);

        Workbook wb = new HSSFWorkbook();
        //CreationHelper createHelper = wb.getCreationHelper();

        String sheetName = " ?";
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);

        //sheet 
        Sheet sheet = wb.createSheet(safeName);

        //header ?
        Row hrow0 = sheet.createRow((short) 0);
        hrow0.setHeightInPoints(20);
        hrow0.createCell(0).setCellValue("");
        hrow0.createCell(1).setCellValue("(" + this.FROMYMD + ")");
        hrow0.createCell(2).setCellValue("(" + this.TOYMD + ")");

        StringMap categories = (StringMap) map.get("categories");
        StringMap beforeSeries = (StringMap) map.get("beforeSeries");
        StringMap afterSeries = (StringMap) map.get("afterSeries");

        short i = 1;
        for (int j = 0; j < categories.size(); j++) {
            //  
            Row row = sheet.createRow((short) i);
            row.setHeightInPoints(20);
            row.createCell(0)
                    .setCellValue(categories.get(String.valueOf(j)).toString().replaceAll("<br>", " : "));
            row.createCell(1).setCellValue(Double.parseDouble(beforeSeries.get(String.valueOf(j)).toString()));
            row.createCell(2).setCellValue(Double.parseDouble(afterSeries.get(String.valueOf(j)).toString()));
            i++;
        }

        log.debug("selectCellTrafficStatsThrpCompGraphExcelDownload : file start");

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkStatsThrpCompGraph(NMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);
        log.debug("selectCellTrafficStatsThrpCompGraphExcelDownload : file end");

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        if (session != null) {
            session.rollback();
        }
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (session != null) {
            session.close();
        }
    }

    this.log.debug("selectCellTrafficStatsThrpCompGraphExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByQMSAction.java

public String selectCellTrafficCQIExcelDownload() {

    this.log.debug("selectCellTrafficCQIExcelDownload Start");

    FileOutputStream fileOut = null;

    try {//from w w w  . j  av  a  2 s.  co m
        parseParam();

        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        Workbook wb = new HSSFWorkbook();

        //PDFsheet 
        String sheetName = "CQI PDF";
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet PDFsheet = wb.createSheet(safeName);

        createCellTrafficCQIExcelSheet(PDFsheet, "PDF", map);

        //CDFsheet 
        sheetName = "CQI CDF";
        safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet CDFsheet = wb.createSheet(safeName);

        createCellTrafficCQIExcelSheet(CDFsheet, "CDF", map);

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkCQI(PDF_CDF)(QMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    this.log.debug("selectCellTrafficCQIExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByQMSAction.java

public String selectCellTrafficExcelDownload() {

    this.log.debug("selectCellTrafficExcelDownload Start");
    FileOutputStream fileOut = null;

    try {//from  w  w  w . j  a v a2  s .  c o m
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        log.debug("json data : " + this.JSONDATA);

        Workbook wb = new HSSFWorkbook();
        //CreationHelper createHelper = wb.getCreationHelper();

        String sheetName = "data";
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet sheet = wb.createSheet(safeName);

        createCellTrafficExcelSheet(sheet, map);

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkData(QMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    this.log.debug("selectCellTrafficExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByQMSAction.java

public String selectCellTrafficHistogramExcelDownload() {

    this.log.debug("selectCellTrafficHistogramExcelDownload Start");
    SqlSession session = null;/*from   w w  w.  ja v a  2s.  com*/
    FileOutputStream fileOut = null;

    try {
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        log.debug("json data : " + this.JSONDATA);

        Workbook wb = new HSSFWorkbook();
        //CreationHelper createHelper = wb.getCreationHelper();

        String sheetName = this.FROMYMD + "~" + this.TOYMD;
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);

        //sheet 
        Sheet sheet = wb.createSheet(safeName);

        //header ?
        Row hrow0 = sheet.createRow((short) 0);
        hrow0.setHeightInPoints(20);
        hrow0.createCell(0).setCellValue("MBPS");
        hrow0.createCell(1).setCellValue("COUNT");
        hrow0.createCell(2).setCellValue("??");
        hrow0.createCell(3).setCellValue("CDF");

        StringMap categoryVal = (StringMap) map.get("categoryVal");
        StringMap rVal = (StringMap) map.get("rVal");
        StringMap rate = (StringMap) map.get("rate");
        StringMap cdf = (StringMap) map.get("cdf");

        short i = 1;
        for (int j = 0; j < 10; j++) {
            //  
            Row row = sheet.createRow((short) i);
            row.setHeightInPoints(20);
            row.createCell(0).setCellValue(Double.parseDouble(categoryVal.get(String.valueOf(j)).toString()));
            row.createCell(1).setCellValue(Double.parseDouble(rVal.get(String.valueOf(j)).toString()));
            row.createCell(2).setCellValue(Double.parseDouble(rate.get(String.valueOf(j)).toString()));
            row.createCell(3).setCellValue(Double.parseDouble(cdf.get(String.valueOf(j)).toString()));
            i++;
        }

        log.debug("selectCellTrafficHistogramExcelDownload : file start");

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkHistogram(QMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);
        log.debug("selectCellTrafficHistogramExcelDownload : file end");

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        if (session != null) {
            session.rollback();
        }
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (session != null) {
            session.close();
        }
    }

    this.log.debug("selectCellTrafficHistogramExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByQMSStatsAction.java

public String selectCellTrafficStatsCQIExcelDownload() {

    this.log.debug("selectCellTrafficStatsCQIExcelDownload Start");
    SqlSession session = null;/*  www .  j  av a 2s. c  o m*/
    FileOutputStream fileOut = null;

    try {
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        log.debug("json data : " + this.JSONDATA);

        String searchType = this.SEARCHTYPE;
        log.debug("SEARCHTYPE : " + searchType);

        Workbook wb = new HSSFWorkbook();

        //PDFsheet
        String sheetName = "CQI PDF";
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet PDFsheet = wb.createSheet(safeName);

        createCellTrafficStatsCQIExcelSheet(PDFsheet, "PDF", searchType, map);

        //CDFsheet
        sheetName = "CQI CDF";
        safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet CDFsheet = wb.createSheet(safeName);

        createCellTrafficStatsCQIExcelSheet(CDFsheet, "CDF", searchType, map);

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkStatsCQI(PDF_CDF)(QMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        if (session != null) {
            session.rollback();
        }
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (session != null) {
            session.close();
        }
    }

    this.log.debug("selectCellTrafficStatsCQIExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByQMSStatsAction.java

public String selectCellTrafficStatsExcelDownload() {

    this.log.debug("selectCellTrafficStatsExcelDownload Start");
    SqlSession session = null;/*ww  w .java  2  s . c om*/
    FileOutputStream fileOut = null;

    try {
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        log.debug("json data : " + this.JSONDATA);

        String searchType = this.SEARCHTYPE;

        Workbook wb = new HSSFWorkbook();
        //CreationHelper createHelper = wb.getCreationHelper();

        String sheetName = "data";
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);

        //sheet 
        Sheet sheet = wb.createSheet(safeName);

        //            CellStyle cellStyle = wb.createCellStyle();
        //            cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
        //            cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        createCellTrafficStatsExcelSheet(sheet, searchType, map);

        log.debug("selectCellTrafficStatsExcelDownload : file start");

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkStatsData(QMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);
        log.debug("selectCellTrafficStatsExcelDownload : file end");

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        if (session != null) {
            session.rollback();
        }
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (session != null) {
            session.close();
        }
    }

    this.log.debug("selectCellTrafficStatsExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkByQMSStatsAction.java

public String selectCellTrafficStatsHistogramExcelDownload() {

    this.log.debug("selectCellTrafficStatsHistogramExcelDownload Start");
    SqlSession session = null;//from www . j a  va2s.  c om
    FileOutputStream fileOut = null;

    try {
        //parseParam();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        log.debug("json data : " + this.JSONDATA);

        Workbook wb = new HSSFWorkbook();
        //CreationHelper createHelper = wb.getCreationHelper();

        String sheetName = this.FROMYMD + "~" + this.TOYMD;
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);

        //sheet 
        Sheet sheet = wb.createSheet(safeName);

        //header ?
        Row hrow0 = sheet.createRow((short) 0);
        hrow0.setHeightInPoints(20);
        hrow0.createCell(0).setCellValue("MBPS");
        hrow0.createCell(1).setCellValue("COUNT");
        hrow0.createCell(2).setCellValue("??");
        hrow0.createCell(3).setCellValue("CDF");

        StringMap categoryVal = (StringMap) map.get("categoryVal");
        StringMap rVal = (StringMap) map.get("rVal");
        StringMap rate = (StringMap) map.get("rate");
        StringMap cdf = (StringMap) map.get("cdf");

        short i = 1;
        for (int j = 0; j < 10; j++) {
            //  
            Row row = sheet.createRow((short) i);
            row.setHeightInPoints(20);
            row.createCell(0).setCellValue(Double.parseDouble(categoryVal.get(String.valueOf(j)).toString()));
            row.createCell(1).setCellValue(Double.parseDouble(rVal.get(String.valueOf(j)).toString()));
            row.createCell(2).setCellValue(Double.parseDouble(rate.get(String.valueOf(j)).toString()));
            row.createCell(3).setCellValue(Double.parseDouble(cdf.get(String.valueOf(j)).toString()));
            i++;
        }

        log.debug("selectCellTrafficStatsHistogramExcelDownload : file start");

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkStatsHistogram(QMS).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);
        log.debug("selectCellTrafficStatsHistogramExcelDownload : file end");

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        if (session != null) {
            session.rollback();
        }
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (session != null) {
            session.close();
        }
    }

    this.log.debug("selectCellTrafficStatsHistogramExcelDownload End");
    return SUCCESS;
}

From source file:com.skt.adcas.lte.action.DownLinkBySTDAction.java

public String selectCellTrafficCQIExcelDownload() {

    this.log.debug("selectCellTrafficCQIExcelDownload Start");

    FileOutputStream fileOut = null;

    try {/*from   ww w.  j ava  2 s .  co  m*/
        parseParam();

        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Gson gson = new Gson();
        Map<String, Object> map = gson.fromJson(this.JSONDATA, type);

        Workbook wb = new HSSFWorkbook();

        //PDFsheet 
        String sheetName = "CQI PDF";
        String safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet PDFsheet = wb.createSheet(safeName);

        createCellTrafficCQIExcelSheet(PDFsheet, "PDF", map);

        //CDFsheet 
        sheetName = "CQI CDF";
        safeName = WorkbookUtil.createSafeSheetName(sheetName);
        Sheet CDFsheet = wb.createSheet(safeName);

        createCellTrafficCQIExcelSheet(CDFsheet, "CDF", map);

        String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH");
        String tempFolder = "/" + UUID.randomUUID().toString();
        String xlsFileName = "/DownLinkCQI(PDF_CDF)(STD).xls";

        if (!(new File(writeFolderPath + tempFolder)).mkdir()) {
            throw new Exception("? ??  .");
        }

        String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName;
        fileOut = new FileOutputStream(xlsFileFullPath);
        wb.write(fileOut);

        this.msg = "? ? ?";
        this.status = "SUCCESS";
        this.downloadurl = "download" + tempFolder + xlsFileName;

    } catch (Exception e) {
        this.msg = e.getMessage();
        this.status = "ERROR";
        this.error = true;
        e.printStackTrace();
    } finally {
        try {
            if (fileOut != null)
                fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    this.log.debug("selectCellTrafficCQIExcelDownload End");
    return SUCCESS;
}