List of usage examples for org.apache.poi.ss.util WorkbookUtil createSafeSheetName
public static String createSafeSheetName(final String nameProposal)
From source file:com.rapidminer.operator.io.ExcelExampleSetWriter.java
License:Open Source License
/** * Writes the example set into a excel file with XLSX format. If you want to write it in XLS * format use {@link #write(ExampleSet, Charset, OutputStream)}. * * @param exampleSet/* w ww . ja v a 2 s .c om*/ * the exampleSet to write * @param sheetName * name of the excel sheet which will be created. * @param dateFormat * a string which describes the format used for dates. * @param numberFormat * a string which describes the format used for numbers. * @param outputStream * the stream to write the file to * @param op * needed for checkForStop */ public static void writeXLSX(ExampleSet exampleSet, String sheetName, String dateFormat, String numberFormat, OutputStream outputStream, Operator op) throws WriteException, IOException, ProcessStoppedException { // .xlsx files can only store up to 16384 columns, so throw error in case of more if (exampleSet.getAttributes().allSize() > 16384) { throw new IllegalArgumentException( I18N.getMessage(I18N.getErrorBundle(), "export.excel.excel_xlsx_file_exceeds_column_limit")); } try (SXSSFWorkbook workbook = new SXSSFWorkbook(null, SXSSFWorkbook.DEFAULT_WINDOW_SIZE, false, true)) { Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName)); dateFormat = dateFormat == null ? DEFAULT_DATE_FORMAT : dateFormat; numberFormat = numberFormat == null ? "#.0" : numberFormat; writeXLSXDataSheet(workbook, sheet, dateFormat, numberFormat, exampleSet, op); workbook.write(outputStream); } finally { outputStream.flush(); outputStream.close(); } }
From source file:com.skt.adcas.lte.action.DownLinkByNMSAction.java
public String selectDailyCellTrafficCQIExcelDownload() { this.log.debug("selectDailyCellTrafficCQIExcelDownload Start"); SqlSession session = null;/*from w w w . j a v a 2s .c o m*/ FileOutputStream fileOut = null; try { parseParam(); log.debug(this.MFC_CD); String[] CQINAME = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; if (MFC_CD.equals("MFC00002")) { CQINAME[0] = "1"; CQINAME[1] = "2"; CQINAME[2] = "3"; CQINAME[3] = "4"; CQINAME[4] = "5"; CQINAME[5] = "6"; CQINAME[6] = "7"; CQINAME[7] = "8"; CQINAME[8] = "9"; CQINAME[9] = "10"; CQINAME[10] = "11"; CQINAME[12] = "12"; CQINAME[13] = "13"; CQINAME[14] = "14"; CQINAME[15] = "15"; } 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(); //PDFsheet String sheetName = "CQI PDF"; String safeName = WorkbookUtil.createSafeSheetName(sheetName); Sheet PDFsheet = wb.createSheet(safeName); //CDFsheet sheetName = "CQI CDF"; safeName = WorkbookUtil.createSafeSheetName(sheetName); Sheet CDFsheet = wb.createSheet(safeName); //header ? Row PDFhrow0 = PDFsheet.createRow((short) 0); PDFhrow0.setHeightInPoints(20); PDFhrow0.createCell(0).setCellValue(""); // "YMD" PDFhrow0.createCell(1).setCellValue(""); // "MB_TIME" PDFhrow0.createCell(2).setCellValue("DU"); // "BTS_NM" PDFhrow0.createCell(3).setCellValue("CELL ID"); // "CELL_ID" PDFhrow0.createCell(4).setCellValue("CELL "); // "CELL_NM" PDFhrow0.createCell(5).setCellValue("MCID"); // "MCID" PDFhrow0.createCell(6).setCellValue(""); // "MCID" PDFhrow0.createCell(7).setCellValue("PDF-" + CQINAME[0]); PDFhrow0.createCell(8).setCellValue("PDF-" + CQINAME[1]); PDFhrow0.createCell(9).setCellValue("PDF-" + CQINAME[2]); PDFhrow0.createCell(10).setCellValue("PDF-" + CQINAME[3]); PDFhrow0.createCell(11).setCellValue("PDF-" + CQINAME[4]); PDFhrow0.createCell(12).setCellValue("PDF-" + CQINAME[5]); PDFhrow0.createCell(13).setCellValue("PDF-" + CQINAME[6]); PDFhrow0.createCell(14).setCellValue("PDF-" + CQINAME[7]); PDFhrow0.createCell(15).setCellValue("PDF-" + CQINAME[8]); PDFhrow0.createCell(16).setCellValue("PDF-" + CQINAME[9]); PDFhrow0.createCell(17).setCellValue("PDF-" + CQINAME[10]); PDFhrow0.createCell(18).setCellValue("PDF-" + CQINAME[11]); PDFhrow0.createCell(19).setCellValue("PDF-" + CQINAME[12]); PDFhrow0.createCell(20).setCellValue("PDF-" + CQINAME[13]); PDFhrow0.createCell(21).setCellValue("PDF-" + CQINAME[14]); PDFhrow0.createCell(22).setCellValue("PDF-" + CQINAME[15]); //header ? Row CDFhrow0 = CDFsheet.createRow((short) 0); CDFhrow0.setHeightInPoints(20); CDFhrow0.createCell(0).setCellValue(""); // "YMD" CDFhrow0.createCell(1).setCellValue(""); // "MB_TIME" CDFhrow0.createCell(2).setCellValue("DU"); // "BTS_NM" CDFhrow0.createCell(3).setCellValue("CELL ID"); // "CELL_ID" CDFhrow0.createCell(4).setCellValue("CELL "); // "CELL_NM" CDFhrow0.createCell(5).setCellValue("MCID"); // "MCID" CDFhrow0.createCell(6).setCellValue(""); // "MCID" CDFhrow0.createCell(7).setCellValue("CDF-" + CQINAME[0]); CDFhrow0.createCell(8).setCellValue("CDF-" + CQINAME[1]); CDFhrow0.createCell(9).setCellValue("CDF-" + CQINAME[2]); CDFhrow0.createCell(10).setCellValue("CDF-" + CQINAME[3]); CDFhrow0.createCell(11).setCellValue("CDF-" + CQINAME[4]); CDFhrow0.createCell(12).setCellValue("CDF-" + CQINAME[5]); CDFhrow0.createCell(13).setCellValue("CDF-" + CQINAME[6]); CDFhrow0.createCell(14).setCellValue("CDF-" + CQINAME[7]); CDFhrow0.createCell(15).setCellValue("CDF-" + CQINAME[8]); CDFhrow0.createCell(16).setCellValue("CDF-" + CQINAME[9]); CDFhrow0.createCell(17).setCellValue("CDF-" + CQINAME[10]); CDFhrow0.createCell(18).setCellValue("CDF-" + CQINAME[11]); CDFhrow0.createCell(19).setCellValue("CDF-" + CQINAME[12]); CDFhrow0.createCell(20).setCellValue("CDF-" + CQINAME[13]); CDFhrow0.createCell(21).setCellValue("CDF-" + CQINAME[14]); CDFhrow0.createCell(22).setCellValue("CDF-" + CQINAME[15]); ArrayList list01 = (ArrayList) map.get("rows"); Iterator iterator = (Iterator) list01.iterator(); short i = 1; while (iterator.hasNext()) { StringMap jrow = (StringMap) iterator.next(); // Row PDFrow = PDFsheet.createRow((short) i); Row CDFrow = CDFsheet.createRow((short) i); PDFrow.setHeightInPoints(20); CDFrow.setHeightInPoints(20); PDFrow.createCell(0).setCellValue((String) jrow.get("YMD")); PDFrow.createCell(1).setCellValue((String) jrow.get("MB_TIME")); PDFrow.createCell(2).setCellValue((String) jrow.get("BTS_NM")); PDFrow.createCell(3).setCellValue((String) jrow.get("CELL_ID")); PDFrow.createCell(4).setCellValue((String) jrow.get("CELL_NM")); PDFrow.createCell(5).setCellValue((String) jrow.get("MCID")); PDFrow.createCell(6).setCellValue((String) jrow.get("FREQ_KIND")); CDFrow.createCell(0).setCellValue((String) jrow.get("YMD")); CDFrow.createCell(1).setCellValue((String) jrow.get("MB_TIME")); CDFrow.createCell(2).setCellValue((String) jrow.get("BTS_NM")); CDFrow.createCell(3).setCellValue((String) jrow.get("CELL_ID")); CDFrow.createCell(4).setCellValue((String) jrow.get("CELL_NM")); CDFrow.createCell(5).setCellValue((String) jrow.get("MCID")); CDFrow.createCell(6).setCellValue((String) jrow.get("FREQ_KIND")); PDFrow.createCell(7).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_00") ? jrow.get("CQI_PDF_00").toString() : "0")); PDFrow.createCell(8).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_01") ? jrow.get("CQI_PDF_01").toString() : "0")); PDFrow.createCell(9).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_02") ? jrow.get("CQI_PDF_02").toString() : "0")); PDFrow.createCell(10).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_03") ? jrow.get("CQI_PDF_03").toString() : "0")); PDFrow.createCell(11).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_04") ? jrow.get("CQI_PDF_04").toString() : "0")); PDFrow.createCell(12).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_05") ? jrow.get("CQI_PDF_05").toString() : "0")); PDFrow.createCell(13).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_06") ? jrow.get("CQI_PDF_06").toString() : "0")); PDFrow.createCell(14).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_07") ? jrow.get("CQI_PDF_07").toString() : "0")); PDFrow.createCell(15).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_08") ? jrow.get("CQI_PDF_08").toString() : "0")); PDFrow.createCell(16).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_09") ? jrow.get("CQI_PDF_09").toString() : "0")); PDFrow.createCell(17).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_10") ? jrow.get("CQI_PDF_10").toString() : "0")); PDFrow.createCell(18).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_11") ? jrow.get("CQI_PDF_11").toString() : "0")); PDFrow.createCell(19).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_12") ? jrow.get("CQI_PDF_12").toString() : "0")); PDFrow.createCell(20).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_13") ? jrow.get("CQI_PDF_13").toString() : "0")); PDFrow.createCell(21).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_14") ? jrow.get("CQI_PDF_14").toString() : "0")); PDFrow.createCell(22).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_15") ? jrow.get("CQI_PDF_15").toString() : "0")); CDFrow.createCell(7).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_00") ? jrow.get("CQI_CDF_00").toString() : "0")); CDFrow.createCell(8).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_01") ? jrow.get("CQI_CDF_01").toString() : "0")); CDFrow.createCell(9).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_02") ? jrow.get("CQI_CDF_02").toString() : "0")); CDFrow.createCell(10).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_03") ? jrow.get("CQI_CDF_03").toString() : "0")); CDFrow.createCell(11).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_04") ? jrow.get("CQI_CDF_04").toString() : "0")); CDFrow.createCell(12).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_05") ? jrow.get("CQI_CDF_05").toString() : "0")); CDFrow.createCell(13).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_06") ? jrow.get("CQI_CDF_06").toString() : "0")); CDFrow.createCell(14).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_07") ? jrow.get("CQI_CDF_07").toString() : "0")); CDFrow.createCell(15).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_08") ? jrow.get("CQI_CDF_08").toString() : "0")); CDFrow.createCell(16).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_09") ? jrow.get("CQI_CDF_09").toString() : "0")); CDFrow.createCell(17).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_10") ? jrow.get("CQI_CDF_10").toString() : "0")); CDFrow.createCell(18).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_11") ? jrow.get("CQI_CDF_11").toString() : "0")); CDFrow.createCell(19).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_12") ? jrow.get("CQI_CDF_12").toString() : "0")); CDFrow.createCell(20).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_13") ? jrow.get("CQI_CDF_13").toString() : "0")); CDFrow.createCell(21).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_14") ? jrow.get("CQI_CDF_14").toString() : "0")); CDFrow.createCell(22).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_15") ? jrow.get("CQI_CDF_15").toString() : "0")); i++; } String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH"); String tempFolder = "/" + UUID.randomUUID().toString(); String xlsFileName = "/DownLinkCQI(PDF_CDF).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("selectDailyCellTrafficCQIExcelDownload End"); return SUCCESS; }
From source file:com.skt.adcas.lte.action.DownLinkByNMSAction.java
public String selectDailyCellTrafficExcelDownload() { this.log.debug("selectDailyCellTrafficExcelDownload Start"); SqlSession session = null;/*from w w w. j a va 2s .c o m*/ FileOutputStream fileOut = null; try { parseParam(); log.debug(this.MFC_CD); 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 ? jump this.makeTrafficSheet(wb, safeName, map); String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH"); String tempFolder = "/" + UUID.randomUUID().toString(); String xlsFileName = "/DownLinkData.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) { e.printStackTrace(); 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("selectDailyCellTrafficExcelDownload End"); return SUCCESS; }
From source file:com.skt.adcas.lte.action.DownLinkByNMSAction.java
public String selectDailyCellTrafficCompExcelDownload() { this.log.debug("selectDailyCellTrafficCompExcelDownload Start"); SqlSession session = null;//from www . j a v a 2s .c o m FileOutputStream fileOut = null; try { parseParam(); log.debug(this.MFC_CD); Type type = new TypeToken<Map<String, Object>>() { }.getType(); Gson gson = new Gson(); log.debug("json data : " + this.JSONDATA); Workbook wb = new HSSFWorkbook(); CreationHelper createHelper = wb.getCreationHelper(); // Map<String, Object> map = gson.fromJson(this.JSONDATA, type); String sheetName = " data"; String safeName = WorkbookUtil.createSafeSheetName(sheetName); this.makeTrafficSheet(wb, safeName, map); // Map<String, Object> mapAfter = gson.fromJson(this.JSONDATAAFTER, type); String sheetNameAfter = " data"; String safeNameAfter = WorkbookUtil.createSafeSheetName(sheetNameAfter); this.makeTrafficSheet(wb, safeNameAfter, mapAfter); String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH"); String tempFolder = "/" + UUID.randomUUID().toString(); String xlsFileName = "/DownLinkDataComp.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) { e.printStackTrace(); 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("selectDailyCellTrafficCompExcelDownload End"); return SUCCESS; }
From source file:com.skt.adcas.lte.action.DownLinkByNMSStatsAction.java
public String selectCellTrafficStatsCQIExcelDownload() { this.log.debug("selectCellTrafficStatsCQIExcelDownload Start"); SqlSession session = null;//from w w w. ja v a 2 s . 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); 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)(NMS).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.DownLinkByNMSStatsAction.java
public String selectCellTrafficStatsCompCQIExcelDownload() { this.log.debug("selectCellTrafficStatsCompCQIExcelDownload Start"); SqlSession session = null;// w ww . j a v a 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); 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; 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); //PDFsheet sheetName = " CQI PDF"; safeName = WorkbookUtil.createSafeSheetName(sheetName); Sheet PDFsheetAfter = wb.createSheet(safeName); createCellTrafficStatsCQIExcelSheet(PDFsheetAfter, "PDF", searchType, mapAfter); //CDFsheet sheetName = " CQI CDF"; safeName = WorkbookUtil.createSafeSheetName(sheetName); Sheet CDFsheetAfter = wb.createSheet(safeName); createCellTrafficStatsCQIExcelSheet(CDFsheetAfter, "CDF", searchType, mapAfter); String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH"); String tempFolder = "/" + UUID.randomUUID().toString(); String xlsFileName = "/DownLinkStatsCompCQI(PDF_CDF)(NMS).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("selectCellTrafficStatsCompCQIExcelDownload End"); return SUCCESS; }
From source file:com.skt.adcas.lte.action.DownLinkByNMSStatsAction.java
public String selectCellTrafficStatsExcelDownload() { this.log.debug("selectCellTrafficStatsExcelDownload Start"); SqlSession session = null;/* w w w. j a v 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; Workbook wb = new HSSFWorkbook(); //CreationHelper createHelper = wb.getCreationHelper(); String sheetName = "data"; String safeName = WorkbookUtil.createSafeSheetName(sheetName); //sheet Sheet sheet = wb.createSheet(safeName); 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(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("selectCellTrafficStatsExcelDownload End"); return SUCCESS; }
From source file:com.skt.adcas.lte.action.DownLinkByNMSStatsAction.java
public String selectCellTrafficStatsCompExcelDownload() { this.log.debug("selectCellTrafficStatsCompExcelDownload Start"); SqlSession session = null;/*from ww w .j a v a 2s. 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); 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 w w .j a v 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); 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 . ja v a2 s . 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 = " ?"; 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; }