List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook write
private void write(POIFSFileSystem fs) throws IOException
From source file:com.pureinfo.srm.reports.table.data.pinggu.PingGuReportsTasker.java
License:Open Source License
/** * @see java.util.TimerTask#run()/*from w ww. j av a2 s .c o m*/ */ public void run() { logger.debug("run..."); ArkHelper.setLoginUser(user); init(); LocalContextHelper.setAttribute(PingGuConstants.ATTRIBUTE_NAME_OF_PARAMETER, parameterVO); String sTempFile = null; OutputStream fos = null; StringBuffer msg = new StringBuffer(); String sFileName; Date startDate = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String title = formatter.format(startDate) + ""; try { sFileName = ""; title += sFileName + "(" + parameterVO.getDeptCode() + ")"; String sFileExt = ".xls"; IMultiSheetExporter exporter = (IMultiSheetExporter) PureFactory.getBean("ExcelExporterMultiSheet"); long totalTime = 0, startTime = startDate.getTime(); // to expor the data into temporay file sTempFile = factory.getNextFileName("EX", sFileExt, true); logger.debug("the file name:" + sTempFile); HSSFWorkbook book = new HSSFWorkbook(); StringBuffer errorBuffer = new StringBuffer(); for (Iterator iterator = exportBeanSet.iterator(); iterator.hasNext();) { DolphinExportGoods goods = new DolphinExportGoods(); ReportsBase report = (ReportsBase) iterator.next(); IConvertor convertor = new SceneryConvertorImpl(report.getExportSenery(), "content"); IObjects objs = null; try { objs = report.getObjs(); List colInfos = getColsInfo(report); String[] headers = new String[colInfos.size()]; String[] properties = new String[colInfos.size()]; for (int i = 0; i < colInfos.size(); i++) { ColumnInfo colInfo = (ColumnInfo) colInfos.get(i); String sHeader = colInfo.getTitle(); headers[i] = sHeader.replaceAll("[\\\\\\[\\]\\?/<>]+", "_"); properties[i] = colInfo.getName(); } goods.setType(ExportHelper.TYPE_EXCEL); goods.setName(report.getReportName()); goods.setHeaders(headers); goods.setData(objs, properties, convertor); exporter.export(book, goods); } catch (Exception e) { logger.error("===============export error.", e); errorBuffer.append(report.getReportName() + ":" + e.getMessage() + "\n\n"); } finally { if (objs != null) objs.clear(); goods.clear(); } } fos = new FileOutputStream(sTempFile); book.write(fos); fos.flush(); fos.close(); fos = null; totalTime = new Date().getTime() - startTime; msg.append("\n" + sFileName + "\n" + getUrl(sTempFile)); msg.append("\n" + ((totalTime) / 60000.0) + " ."); msg.append("\n0.\n"); if (errorBuffer.length() != 0) { msg.append("------------------------------------\n\n"); msg.append("\n"); msg.append(errorBuffer.toString()); } msg.append("------------------------------------\n\n"); msg.append( "\nexcel6553565535"); } catch (Exception ex) { logger.error("failed to export data", ex); msg.append("\n" + ex.getMessage()); } finally { if (fos != null) try { fos.close(); } catch (Exception ex) { } sendSysMsg(msg.toString(), title); } }
From source file:com.qcadoo.report.api.xls.XlsDocumentService.java
License:Open Source License
@Override public final void generateDocument(final Entity entity, final Locale locale, final Rectangle pageSize) throws IOException { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(getReportTitle(locale)); addHeader(sheet, locale, entity);/* w w w . jav a2 s . c o m*/ addSeries(sheet, entity); sheet.setZoom(4, 3); FileOutputStream outputStream = null; try { outputStream = new FileOutputStream(fileService.createReportFile( (String) entity.getField("fileName") + "." + ReportService.ReportType.XLS.getExtension())); workbook.write(outputStream); } catch (IOException e) { LOG.error("Problem with generating document - " + e.getMessage()); if (outputStream != null) { outputStream.close(); } throw e; } outputStream.close(); }
From source file:com.quix.aia.cn.imo.mapper.InterviewMaintenance.java
License:Open Source License
/** * <p>Method is used to create csv to store registration list for 3rd interview </p> * @param HttpServletRequest request //from ww w . j a va 2 s .co m * @return csv path as String */ public String createCsv(ArrayList regList, HttpServletRequest request) { log.log(Level.INFO, "Csv Generation Starts"); String xlsPath = ""; DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); FileWriter fw = null; /*BufferedWriter writer=null; String serverFilename = request.getRealPath("/"); if(!serverFilename.endsWith("/")) serverFilename = serverFilename + File.separator; try{ serverFilename = serverFilename + "resources" + File.separator + "downloads" + File.separator + "csv"; File dir = new File(serverFilename); if(!dir.exists()) dir.mkdirs(); serverFilename = serverFilename + File.separator +df.format(new Date()) + ".csv" ; File file = new File(serverFilename); if(!file.exists()) file.createNewFile(); writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); writer.write("Interview Session Name|"); writer.write("Interview Date|"); writer.write("Start Time|"); writer.write("End Time|"); writer.write("Candidate Name|"); writer.write("Servicing Agent|"); writer.write("Agent Name|"); writer.write("BU|"); writer.write("District|"); writer.write("Branch|"); writer.write("City|"); writer.write("Office|"); writer.write("SSC|"); writer.write("Agency Leader Code|"); writer.write("Agency Leader Name|"); writer.write("Source of Referral|"); writer.write("Age|"); writer.write("Date of Birth|"); writer.write("Gender|"); writer.write("Contact Number|"); writer.write("CC Test Result|"); writer.write("Recruitment Scheme|"); writer.newLine(); if(regList!=null && regList.size()>0){ Iterator iteObj= regList.iterator(); for(int i=0;i<regList.size();i++){ Object [] obj= (Object []) iteObj.next(); writer.write(obj[0]+"|"); //Interview Session Name if(obj[1]!=null ) writer.write(LMSUtil.convertDateToString((Date)obj[1]) +"|"); //Interview Date else writer.write("|"); if(obj[2]!=null ) writer.write(LMSUtil.converDateIntoHHMMAMPM((Date)obj[2]) +"|");//Start Time else writer.write("|"); if(obj[3]!=null) writer.write(LMSUtil.converDateIntoHHMMAMPM((Date)obj[3]) +"|");//End Time else writer.write("|"); if(obj[4]!=null)writer.write(obj[4]+"|");else writer.write("|");//Candidate Name if(obj[5]!=null)writer.write(obj[5]+"|");else writer.write("|");//Servicing Agent if(obj[6]!=null)writer.write(obj[6]+"|");else writer.write("|");//Agent Name if(obj[7]!=null)writer.write(obj[7]+"|");else writer.write("|");//BU if(obj[8]!=null)writer.write(obj[8]+"|");else writer.write("|");//District if(obj[9]!=null)writer.write(obj[9]+"|");else writer.write("|");//Branch if(obj[10]!=null)writer.write(obj[10]+"|");else writer.write("|");//City if(obj[11]!=null)writer.write(obj[11]+"|");else writer.write("|");//Office if(obj[12]!=null)writer.write(obj[12]+"|");else writer.write("|");//SSC if(obj[13]!=null)writer.write(obj[13]+"|");else writer.write("|");//Agency Leader Code if(obj[14]!=null)writer.write(obj[14]+"|");else writer.write("|");//Agency Leader Name if(obj[15]!=null)writer.write(obj[15]+"|");else writer.write("|");//Source of Referral if(obj[16]!=null)writer.write(obj[16]+"|");else writer.write("|");//Age if(obj[17]!=null ) writer.write(LMSUtil.convertDateToString((Date)obj[17]) +"|");//DOB else writer.write("|"); String gender = ""; if(obj[18]!=null){ if("F".equalsIgnoreCase((String)obj[18])) gender = "Female"; else if("M".equalsIgnoreCase((String)obj[18]))//Gender gender = "Male"; } writer.write(gender+"|"); if(obj[19]!=null)writer.write(obj[19]+"|");else writer.write("|");//Contact Number if(obj[20]!=null)writer.write(obj[20]+"|");else writer.write("|");//CC Test Result if(obj[21]!=null)writer.write(obj[21]+"|");else writer.write("|");//Recruitment Scheme writer.newLine(); } }else{ log.log(Level.INFO,"InterviewMaintenace - > createCsv : No candidate registration for 3rd interview"); } }catch(Exception e){ log.log(Level.SEVERE, e.getMessage()); e.printStackTrace();LogsMaintenance logsMain=new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("InterViewMaintenance",Level.SEVERE+"",errors.toString()); }finally{ try{ if(writer != null){ writer.flush(); } if(writer != null){ writer.close(); } if(fw!=null) fw.close(); }catch(Exception ioExc){ log.log(Level.SEVERE, ioExc.getMessage()); ioExc.printStackTrace(); } } */ ArrayList arList = null; ArrayList al = null; String thisLine; int count = 0; try { xlsPath = request.getRealPath("/") + "resources" + File.separator + "downloads" + File.separator + "xls"; File dir = new File(xlsPath); if (!dir.exists()) dir.mkdirs(); //df.format(new Date()) xlsPath = xlsPath + File.separator + df.format(new Date()) + ".xls"; HSSFWorkbook hwb = new HSSFWorkbook(); HSSFSheet sheet = (HSSFSheet) hwb.createSheet("Sheet1"); int rownum = 0; HSSFRow row = sheet.createRow(rownum++); int cellnum = 0; HSSFCell cell = row.createCell((short) cellnum++); cell.setCellValue("? ?"); cell = row.createCell((short) cellnum++); cell.setCellValue("? "); cell = row.createCell((short) cellnum++); cell.setCellValue(" "); cell = row.createCell((short) cellnum++); cell.setCellValue("? "); cell = row.createCell((short) cellnum++); cell.setCellValue(" ??"); cell = row.createCell((short) cellnum++); cell.setCellValue("??"); cell = row.createCell((short) cellnum++); cell.setCellValue("????"); cell = row.createCell((short) cellnum++); cell.setCellValue("?"); cell = row.createCell((short) cellnum++); cell.setCellValue(""); cell = row.createCell((short) cellnum++); cell.setCellValue("?"); cell = row.createCell((short) cellnum++); cell.setCellValue(""); cell = row.createCell((short) cellnum++); cell.setCellValue("?"); cell = row.createCell((short) cellnum++); cell.setCellValue("SSC"); cell = row.createCell((short) cellnum++); cell.setCellValue(""); cell = row.createCell((short) cellnum++); cell.setCellValue("??"); cell = row.createCell((short) cellnum++); cell.setCellValue("?? ?"); cell = row.createCell((short) cellnum++); cell.setCellValue("Age"); cell = row.createCell((short) cellnum++); cell.setCellValue(""); cell = row.createCell((short) cellnum++); cell.setCellValue(""); cell = row.createCell((short) cellnum++); cell.setCellValue("? ??"); cell = row.createCell((short) cellnum++); cell.setCellValue("CC "); cell = row.createCell((short) cellnum++); cell.setCellValue("?"); cell = row.createCell((short) cellnum++); if (regList != null && regList.size() > 0) { Iterator iteObj = regList.iterator(); for (int i = 0; i < regList.size(); i++) { row = sheet.createRow(rownum++); cellnum = 0; Object[] obj = (Object[]) iteObj.next(); //writer.write(obj[0]+"|"); //Interview Session Name if (obj[0] instanceof String) cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[0]); if (obj[1] != null) { //writer.write(LMSUtil.convertDateToString((Date)obj[1]) +"|"); //Interview Date if (obj[1] instanceof Date) { cell = row.createCell((short) cellnum++); cell.setCellValue(LMSUtil.convertDateToString((Date) obj[1])); } } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[2] != null) { //writer.write(LMSUtil.converDateIntoHHMMAMPM((Date)obj[2]) +"|");//Start Time if (obj[2] instanceof Date) { cell = row.createCell((short) cellnum++); cell.setCellValue(LMSUtil.converDateIntoHHMMAMPM((Date) obj[2])); } } else { //writer.write("|"); cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[3] != null) { //writer.write(LMSUtil.converDateIntoHHMMAMPM((Date)obj[3]) +"|");//End Time if (obj[3] instanceof Date) { cell = row.createCell((short) cellnum++); cell.setCellValue(LMSUtil.converDateIntoHHMMAMPM((Date) obj[3])); } } else { //writer.write("|"); cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[4] != null) { //writer.write(obj[4]+"|");//Candidate Name cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[4]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[5] != null) { //Servicing Agent cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[5]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[6] != null) { //Agent Name cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[6]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[7] != null) { //BU cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[7]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[8] != null) { //District cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[8]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[9] != null) { //Branch cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[9]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[10] != null) { //City cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[10]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[11] != null) { //Office cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[11]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[12] != null) { //SSC cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[12]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[13] != null) { //Agency Leader Code cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[13]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[14] != null) { //Agency Leader Name cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[14]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[15] != null) { //Source of Referral cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[15]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[16] != null) { //Age cell = row.createCell((short) cellnum++); cell.setCellValue((Integer) obj[16]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[17] != null) { //writer.write(LMSUtil.convertDateToString((Date)obj[17]) +"|");//DOB if (obj[3] instanceof Date) { cell = row.createCell((short) cellnum++); cell.setCellValue(LMSUtil.convertDateToString((Date) obj[17])); } } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } String gender = ""; if (obj[18] != null) { if ("F".equalsIgnoreCase((String) obj[18])) gender = "Female"; else if ("M".equalsIgnoreCase((String) obj[18]))//Gender gender = "Male"; } cell = row.createCell((short) cellnum++); cell.setCellValue(gender); if (obj[19] != null) { //Contact Number cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[19]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[20] != null) { //CC Test Result cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[20]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } if (obj[21] != null) { //Recruitment Scheme cell = row.createCell((short) cellnum++); cell.setCellValue((String) obj[21]); } else { cell = row.createCell((short) cellnum++); cell.setCellValue(""); } } } FileOutputStream fileOut = new FileOutputStream(xlsPath); hwb.write(fileOut); fileOut.close(); System.out.println("Your excel file has been generated"); } catch (Exception ex) { ex.printStackTrace(); } //main method ends return xlsPath; }
From source file:com.safetys.framework.jmesa.view.excel.ExcelViewExporter.java
License:Apache License
public void export() throws Exception { HttpServletResponse response = super.getResponse(); HSSFWorkbook workbook = (HSSFWorkbook) this.getView().render(); responseHeaders(response);/*from w ww . j a va2s. com*/ workbook.write(response.getOutputStream()); }
From source file:com.save.reports.ExportDataGridToExcel.java
public void workSheet() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Sample sheet"); int rownum = 1; for (Object itemId : getDataGrid().getContainerDataSource().getItemIds()) { Row row = sheet.createRow(rownum); int cellcount = 0; if ((rownum - 1) == 0) { Row rowHeader = sheet.createRow(rownum - 1); for (Object propertyId : getDataGrid().getContainerDataSource().getContainerPropertyIds()) { Cell cell = rowHeader.createCell(cellcount); cell.setCellValue(propertyId.toString().toUpperCase()); sheet.autoSizeColumn(cellcount); cellcount++;/*from w w w .ja va 2s .c o m*/ } } Item item = getDataGrid().getContainerDataSource().getItem(itemId); int cellnum = 0; for (Object propertyId : item.getItemPropertyIds()) { Cell cell = row.createCell(cellnum); if (propertyId.equals("employee")) { cell.setCellValue(item.getItemProperty(propertyId).getValue().toString().toUpperCase()); } else { cell.setCellValue((item.getItemProperty(propertyId).getValue() == null) ? " " : item.getItemProperty(propertyId).getValue().toString()); } sheet.autoSizeColumn(cellnum); cellnum++; } rownum++; } try { Date date = new Date(); file = File.createTempFile("file-" + date.getTime(), ".xls"); FileOutputStream fos = new FileOutputStream(file.getAbsolutePath()); workbook.write(fos); fos.flush(); fos.close(); } catch (FileNotFoundException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } }
From source file:com.schneider.tsm.process.addXPRDataManager.java
private void add2ExistingReport() throws InterruptedException { final SwingWorker worker = new SwingWorker() { @Override//from w w w . j a va 2 s. com protected Object doInBackground() throws Exception { try { FileInputStream file = new FileInputStream(new File( "C:\\softwaretest\\FileOutput\\Manager\\NPR_CPR_Report_" + requestorManager + ".xls")); HSSFWorkbook workbook = new HSSFWorkbook(file); HSSFSheet sheet = workbook.getSheetAt(0); int sheetsize = sheet.getPhysicalNumberOfRows(); Cell cell = null; int numm = 1; for (int i = 7; i < sheetsize; i++) { cell = sheet.getRow(i).getCell(1); if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK) { cell.setCellValue("" + numm); cell = sheet.getRow(i).getCell(2); cell.setCellValue(requestID); cell = sheet.getRow(i).getCell(3); cell.setCellValue(requestorID); cell = sheet.getRow(i).getCell(4); cell.setCellValue(dayFromSubmit); cell = sheet.getRow(i).getCell(5); cell.setCellValue(requestStatus); cell = sheet.getRow(i).getCell(6); cell.setCellValue(submitDate); cell = sheet.getRow(i).getCell(7); cell.setCellValue(requestType); i = sheetsize; } numm++; } file.close(); FileOutputStream outFile = new FileOutputStream(new File( "C:\\softwaretest\\FileOutput\\Manager\\NPR_CPR_Report_" + requestorManager + ".xls")); workbook.write(outFile); outFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }; worker.execute(); Thread.sleep(160); }
From source file:com.schneider.tsm.process.addXPRDataManager.java
private void createNewFileReport() throws InterruptedException { final SwingWorker worker = new SwingWorker() { @Override// w w w . ja va2 s . c o m protected Object doInBackground() throws Exception { try { FileInputStream file = new FileInputStream(new File("C:\\softwaretest\\template.xls")); HSSFWorkbook workbook = new HSSFWorkbook(file); HSSFSheet sheet = workbook.getSheetAt(0); Cell cell = null; cell = sheet.getRow(7).getCell(1); cell.setCellValue("1"); cell = sheet.getRow(7).getCell(2); cell.setCellValue(requestID); cell = sheet.getRow(7).getCell(3); cell.setCellValue(requestorID); cell = sheet.getRow(7).getCell(4); cell.setCellValue(dayFromSubmit); cell = sheet.getRow(7).getCell(5); cell.setCellValue(requestStatus); cell = sheet.getRow(7).getCell(6); cell.setCellValue(submitDate); cell = sheet.getRow(7).getCell(7); cell.setCellValue(requestType); file.close(); FileOutputStream outFile = new FileOutputStream(new File( "C:\\softwaretest\\FileOutput\\Manager\\NPR_CPR_Report_" + requestorManager + ".xls")); workbook.write(outFile); outFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }; worker.execute(); Thread.sleep(160); }
From source file:com.schneider.tsm.process.addXPRDataManager.java
private String getManager() { String manager = "No_Manager_Assigned"; try {//from w ww.jav a 2 s . c o m FileInputStream file = new FileInputStream(new File("C:\\softwaretest\\LibraryTest.xls")); HSSFWorkbook workbook = new HSSFWorkbook(file); HSSFSheet sheet = workbook.getSheetAt(0); Cell cell = null; int sheetsize = sheet.getPhysicalNumberOfRows(); for (int i = 1; i < sheetsize; i++) { cell = sheet.getRow(i).getCell(0); if (cell.getStringCellValue().equals(requestorID)) { cell = sheet.getRow(i).getCell(2); manager = cell.getStringCellValue(); } } file.close(); FileOutputStream outFile = new FileOutputStream(new File("C:\\softwaretest\\LibraryTest.xls")); workbook.write(outFile); outFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return manager; }
From source file:com.schneider.tsm.process.addXPRDataQuality.java
private void add2ExistingReport() throws InterruptedException { final SwingWorker worker = new SwingWorker() { @Override//from w w w . j av a 2 s . c o m protected Object doInBackground() throws Exception { try { FileInputStream file = new FileInputStream(new File( "C:\\softwaretest\\FileOutput\\Quality\\NPR_CPR_Report_" + requestorQuality + ".xls")); HSSFWorkbook workbook = new HSSFWorkbook(file); HSSFSheet sheet = workbook.getSheetAt(0); int sheetsize = sheet.getPhysicalNumberOfRows(); Cell cell = null; int numm = 1; for (int i = 7; i < sheetsize; i++) { cell = sheet.getRow(i).getCell(1); if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK) { cell.setCellValue("" + numm); cell = sheet.getRow(i).getCell(2); cell.setCellValue(requestID); cell = sheet.getRow(i).getCell(3); cell.setCellValue(requestorID); cell = sheet.getRow(i).getCell(4); cell.setCellValue(dayFromSubmit); cell = sheet.getRow(i).getCell(5); cell.setCellValue(requestStatus); cell = sheet.getRow(i).getCell(6); cell.setCellValue(submitDate); cell = sheet.getRow(i).getCell(7); cell.setCellValue(requestType); i = sheetsize; } numm++; } file.close(); FileOutputStream outFile = new FileOutputStream(new File( "C:\\softwaretest\\FileOutput\\Quality\\NPR_CPR_Report_" + requestorQuality + ".xls")); workbook.write(outFile); outFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }; worker.execute(); Thread.sleep(160); }
From source file:com.schneider.tsm.process.addXPRDataQuality.java
private void createNewFileReport() throws InterruptedException { final SwingWorker worker = new SwingWorker() { @Override/*from w ww . java2s . c o m*/ protected Object doInBackground() throws Exception { try { FileInputStream file = new FileInputStream(new File("C:\\softwaretest\\template.xls")); HSSFWorkbook workbook = new HSSFWorkbook(file); HSSFSheet sheet = workbook.getSheetAt(0); Cell cell = null; cell = sheet.getRow(7).getCell(1); cell.setCellValue("1"); cell = sheet.getRow(7).getCell(2); cell.setCellValue(requestID); cell = sheet.getRow(7).getCell(3); cell.setCellValue(requestorID); cell = sheet.getRow(7).getCell(4); cell.setCellValue(dayFromSubmit); cell = sheet.getRow(7).getCell(5); cell.setCellValue(requestStatus); cell = sheet.getRow(7).getCell(6); cell.setCellValue(submitDate); cell = sheet.getRow(7).getCell(7); cell.setCellValue(requestType); file.close(); FileOutputStream outFile = new FileOutputStream(new File( "C:\\softwaretest\\FileOutput\\Quality\\NPR_CPR_Report_" + requestorQuality + ".xls")); workbook.write(outFile); outFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }; worker.execute(); Thread.sleep(160); }