List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook createCellStyle
@Override
public HSSFCellStyle createCellStyle()
From source file:org.clickframes.renderer.RequirementsGenerator.java
License:Open Source License
public static HSSFCellStyle createHeaderColumnStyle(HSSFWorkbook wb) { HSSFCellStyle cellStyle = wb.createCellStyle(); HSSFFont font = wb.createFont();/*from www . j a v a2 s.c o m*/ font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); cellStyle.setFont(font); return cellStyle; }
From source file:org.clickframes.renderer.RequirementsGenerator.java
License:Open Source License
public static HSSFCellStyle createIdentifierColumnStyle(HSSFWorkbook wb) { HSSFCellStyle cellStyle = wb.createCellStyle(); return cellStyle; }
From source file:org.clickframes.renderer.RequirementsGenerator.java
License:Open Source License
public static HSSFCellStyle createRequirementColumnStyle(HSSFWorkbook wb) { HSSFCellStyle cellStyle = wb.createCellStyle(); // cellStyle.setWrapText(true); return cellStyle; }
From source file:org.cyberoam.iview.servlets.ExcelFileGenerator.java
License:Open Source License
void getWorkBook(ResultSetWrapper rsw, ReportBean reportBean, HSSFWorkbook wb) { try {//from w w w . j a v a 2s. c om ReportColumnBean[] reportColumns = (ReportColumnBean[]) ReportColumnBean .getReportColumnsByReportID(reportBean.getReportId()).toArray(new ReportColumnBean[0]); HSSFSheet newSheet = wb.createSheet(reportBean.getTitle()); HSSFRow row; HSSFCell cell; HSSFCellStyle cellStyle = wb.createCellStyle(); HSSFFont fontStyle = wb.createFont(); fontStyle.setFontHeightInPoints((short) 10); fontStyle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); cellStyle.setFont(fontStyle); // getting number of records & fields for report rsw.last(); int rowCount = rsw.getRow(); int colCount = reportColumns.length; //For Freezing the first row newSheet.createFreezePane(0, 1, 0, 1); // Adding column headings to Excel row = newSheet.createRow((short) 0); for (int cCount = 0; cCount < colCount; cCount++) { cell = row.createCell(cCount); cell.setCellStyle(cellStyle); cell.setCellValue(reportColumns[cCount].getColumnName()); } //Adding data for each record to Excel rsw.first(); for (int rcount = 1; rcount <= rowCount; rcount++) { row = newSheet.createRow(rcount); for (int cCount = 0; cCount < colCount; cCount++) { String data = rsw.getString(reportColumns[cCount].getDbColumnName()); cell = row.createCell(cCount); newSheet.autoSizeColumn((short) cCount); if (reportColumns[cCount].getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { data = ByteInUnit.getBytesInUnit(rsw.getLong(reportColumns[cCount].getDbColumnName())); } else if (reportColumns[cCount].getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING && data.indexOf(':') != -1) { String xdata = ProtocolBean.getProtocolNameById( Integer.parseInt(rsw.getString(reportColumns[cCount].getDbColumnName()).substring(0, data.indexOf(':')))); data = xdata + rsw.getString(reportColumns[cCount].getDbColumnName()) .substring(data.indexOf(':'), data.length()); } // Setting value to the cell if (cCount == 0 && (data == null || "".equalsIgnoreCase(data))) data = "N/A"; if (reportColumns[cCount].getColumnFormat() == TabularReportConstants.PERCENTAGE_FORMATTING) { try { cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(Double.parseDouble(data)); } catch (NumberFormatException e) { cell.setCellValue(data); } } else if (rsw.getMetaData().getColumnTypeName(cCount + 1).equalsIgnoreCase("numeric") && reportColumns[cCount].getColumnFormat() != TabularReportConstants.BYTE_FORMATTING) { try { cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(Integer.parseInt(data)); } catch (NumberFormatException e) { cell.setCellValue(data); } } else { cell.setCellValue(data); } } rsw.next(); } } catch (Exception e) { CyberoamLogger.appLog.error("***Error in getWorkbook function***" + e, e); } }
From source file:org.deployom.core.AuditService.java
License:Open Source License
public HSSFWorkbook saveAudit() { // Create book HSSFWorkbook workbook = new HSSFWorkbook(); HSSFCreationHelper creationHelper = workbook.getCreationHelper(); // Default Style HSSFCellStyle style = workbook.createCellStyle(); style.setWrapText(true);/* w w w .j a v a2 s .com*/ HSSFFont font = workbook.createFont(); font.setFontName("Courier New"); style.setFont(font); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); // Header Style HSSFCellStyle styleHeader = workbook.createCellStyle(); styleHeader.cloneStyleFrom(style); styleHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER); font = workbook.createFont(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); font.setColor(HSSFColor.WHITE.index); styleHeader.setFillForegroundColor(IndexedColors.BLACK.getIndex()); styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleHeader.setFont(font); // Error Style HSSFCellStyle styleError = workbook.createCellStyle(); styleError.cloneStyleFrom(style); styleError.setFillForegroundColor(IndexedColors.CORAL.getIndex()); styleError.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleError.setWrapText(true); // Link Style HSSFCellStyle styleLink = workbook.createCellStyle(); styleLink.cloneStyleFrom(style); font = workbook.createFont(); font.setUnderline(HSSFFont.U_SINGLE); font.setColor(IndexedColors.BLUE.getIndex()); styleLink.setFont(font); // Create Summary HSSFSheet summarySheet = workbook.createSheet("Summary"); int summaryRownum = 0; int summaryCellnum = 0; //Create a new row in current sheet Row summaryRow = summarySheet.createRow(summaryRownum++); // 0 Cell summaryCell = summaryRow.createCell(summaryCellnum++); summaryCell.setCellValue("Job"); summaryCell.setCellStyle(styleHeader); // 1 summaryCell = summaryRow.createCell(summaryCellnum++); summaryCell.setCellValue("Finished"); summaryCell.setCellStyle(styleHeader); // 2 summaryCell = summaryRow.createCell(summaryCellnum++); summaryCell.setCellValue("Errors"); summaryCell.setCellStyle(styleHeader); for (Job job : releaseService.getJobs()) { // Open Job JobService jobService = new JobService(siteService.getSiteName(), job.getJobName()); // Create Sheet HSSFSheet sheet = workbook.createSheet(job.getJobName()); int rownum = 0; int cellnum = 0; int errors = 0; //Create a new row in current sheet Row row = sheet.createRow(rownum++); // 0 Cell cell = row.createCell(cellnum++); cell.setCellValue("Host"); cell.setCellStyle(styleHeader); // 1 cell = row.createCell(cellnum++); cell.setCellValue("Service"); cell.setCellStyle(styleHeader); // 2 cell = row.createCell(cellnum++); cell.setCellValue("Command"); cell.setCellStyle(styleHeader); // 3 cell = row.createCell(cellnum++); cell.setCellValue("Executable"); cell.setCellStyle(styleHeader); // 4 cell = row.createCell(cellnum++); cell.setCellValue("Error"); cell.setCellStyle(styleHeader); // 5 cell = row.createCell(cellnum++); cell.setCellValue("Output"); cell.setCellStyle(styleHeader); // Check all hosts for (Host host : jobService.getHosts()) { // Check all services for (Service service : host.getServices()) { // Get a Commands for (Command command : service.getCommands()) { //Create a new row in current sheet row = sheet.createRow(rownum++); cellnum = 0; // 0 cell = row.createCell(cellnum++); cell.setCellValue(host.getHostName()); cell.setCellStyle(style); // 1 cell = row.createCell(cellnum++); cell.setCellValue(service.getServiceName()); cell.setCellStyle(style); // 2 cell = row.createCell(cellnum++); cell.setCellValue(command.getTitle()); cell.setCellStyle(style); // 3 cell = row.createCell(cellnum++); cell.setCellValue(command.getExec()); cell.setCellStyle(style); // 4 cell = row.createCell(cellnum++); cell.setCellValue("N"); cell.setCellStyle(style); // 5 cell = row.createCell(cellnum++); if (command.getOut().length() > 1024) { cell.setCellValue(command.getOut().substring(0, 1024) + "..."); } else { cell.setCellValue(command.getOut()); } cell.setCellStyle(style); // Error if (command.isError() == true) { row.getCell(0).setCellStyle(styleError); row.getCell(1).setCellStyle(styleError); row.getCell(2).setCellStyle(styleError); row.getCell(3).setCellStyle(styleError); row.getCell(4).setCellStyle(styleError); row.getCell(5).setCellStyle(styleError); row.getCell(4).setCellValue("Y"); errors++; } } } } // Set Size sheet.setColumnWidth(0, 6000); sheet.setColumnWidth(1, 4000); sheet.setColumnWidth(2, 8000); sheet.setColumnWidth(3, 14000); sheet.setColumnWidth(4, 3000); sheet.setColumnWidth(5, 20000); // Summary summaryRow = summarySheet.createRow(summaryRownum++); summaryCellnum = 0; // 0 summaryCell = summaryRow.createCell(summaryCellnum++); summaryCell.setCellValue(job.getJobName()); summaryCell.setCellStyle(style); // Set Link HSSFHyperlink link = creationHelper.createHyperlink(Hyperlink.LINK_DOCUMENT); link.setAddress("" + job.getJobName() + "!A1"); summaryCell.setHyperlink(link); summaryCell.setCellStyle(styleLink); // 1 summaryCell = summaryRow.createCell(summaryCellnum++); summaryCell.setCellValue(jobService.getJob().getFinished()); summaryCell.setCellStyle(style); // 2 summaryCell = summaryRow.createCell(summaryCellnum++); summaryCell.setCellValue(errors); summaryCell.setCellStyle(style); // If errors found if (errors > 0) { summaryRow.getCell(0).setCellStyle(styleError); summaryRow.getCell(1).setCellStyle(styleError); summaryRow.getCell(2).setCellStyle(styleError); } } // Set Summary Size summarySheet.setColumnWidth(0, 6000); summarySheet.setColumnWidth(1, 10000); summarySheet.setColumnWidth(2, 4000); // Save try { FileOutputStream out = new FileOutputStream(new File(getFileName())); workbook.write(out); out.close(); logger.log(Level.INFO, "{0} generated successfully..", getFileName()); return workbook; } catch (FileNotFoundException ex) { logger.log(Level.WARNING, "Audit: {0}", ex); } catch (IOException ex) { logger.log(Level.WARNING, "Audit: {0}", ex); } return null; }
From source file:org.displaytag.export.excel.ExcelHssfView.java
License:Open Source License
/** * Templated method that is called for all non-header and non-total cells. * * @param wb the wb/*from w w w . ja v a2 s . c om*/ * @param rowCtr the row ctr * @param column the column * @return the HSSF cell style */ public HSSFCellStyle createRowStyle(HSSFWorkbook wb, int rowCtr, Column column) { return wb.createCellStyle(); }
From source file:org.eclipse.scada.ae.ui.views.export.excel.impl.ExportEventsImpl.java
License:Open Source License
private IStatus storeExcel(final File file, final List<Event> events, final List<Field> columns, final IProgressMonitor monitor) throws IOException { final HSSFWorkbook workbook = new HSSFWorkbook(); final HSSFDataFormat dateFormat = workbook.createDataFormat(); final HSSFCellStyle dateCellStyle = workbook.createCellStyle(); dateCellStyle.setDataFormat(dateFormat.getFormat("YYYY-MM-DD hh:mm:ss.000")); try {/*from w w w. j a v a 2 s . com*/ monitor.beginTask(Messages.ExportImpl_Progress_ExportingEvents, events.size() + 3 + columns.size()); try { monitor.subTask(Messages.ExportImpl_Progress_CreateWorkbook); monitor.worked(1); final HSSFSheet sheet = createSheet(events, workbook, columns); monitor.worked(1); monitor.setTaskName(Messages.ExportImpl_Progress_ExportEvents); for (int i = 0; i < events.size(); i++) { final HSSFRow row = sheet.createRow(i + 1); final Event e = events.get(i); for (int j = 0; j < columns.size(); j++) { final Field field = columns.get(j); final ExcelCell cell = new ExcelCell(row, j, dateCellStyle); field.render(e, cell); } monitor.worked(1); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } } sheet.setRepeatingRows(new CellRangeAddress(0, 1, -1, -1)); monitor.setTaskName("Auto sizing"); for (int i = 0; i < columns.size(); i++) { monitor.subTask(String.format("Auto sizing column: %s", columns.get(i).getHeader())); sheet.autoSizeColumn(i); monitor.worked(1); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } } } finally { monitor.subTask(Messages.ExportImpl_Progress_CloseFile); if (workbook != null) { makeDocInfo(workbook); final FileOutputStream stream = new FileOutputStream(file); workbook.write(stream); stream.close(); } monitor.worked(1); } } finally { monitor.done(); } return Status.OK_STATUS; }
From source file:org.eclipse.titanium.markers.export.XlsProblemExporter.java
License:Open Source License
/** * Export the code smells of a project to an excel workbook. * <p>//from w w w. j a va 2 s . c o m * The first sheet of the workbook is a summary page, showing the number of * hits for each code smell, and an expressive bar chart of these data. The * further sheets enumerate the specific code smells of each kind, including * the message of the code smell, and the file name and line where it * occurred. * <p> * Note: All code smell types are used in the analysis and are written in * the output. Some code smells use external settings, which can be fine * tuned on the preference page. * * @param filename * the file to save the xls * @param date * the time stamp to write on the summary page * * @throws IOException * when writing the file fails */ @Override // Flow analysis thinks 'sheet' may be referenced as null, but it is // guaranteed to be initialized first. public void exportMarkers(final IProgressMonitor monitor, final String filename, final Date date) throws IOException { final SubMonitor progress = SubMonitor.convert(monitor, 100); final File file = new File(filename); POIFSFileSystem fs = null; HSSFWorkbook workbook = null; try { fs = new POIFSFileSystem(XlsProblemExporter.class.getResourceAsStream("ProblemMarkers.xlt")); workbook = new HSSFWorkbook(fs, true); } catch (IOException e) { ErrorReporter.logExceptionStackTrace("Error while exporting to excel", e); // Error on opening the template xls. Create an empty // one (without the chart). if (reportDebugInformation) { TITANDebugConsole.println("Error on opening ProblemMarkers.xlt. Chartless xls will be generated"); } workbook = new HSSFWorkbook(new FileInputStream(file)); workbook.createSheet("Summary"); workbook.setSheetOrder("Summary", 0); } catch (Exception e) { ErrorReporter.logExceptionStackTrace("Error while exporting to excel", e); return; } progress.worked(10); try { final HSSFSheet summarySheet = workbook.getSheetAt(0); createTimeSheet(workbook); final Map<String, Integer> smellCount = new HashMap<String, Integer>(); int summaryRow = 4; Cell label = null; Cell numberCell = null; final Map<TaskType, List<IMarker>> markers = collectMarkers(); // export the task markers: for (final TaskType t : TaskType.values()) { createTaskSheet(workbook, t, markers.get(t)); final Row row1 = summarySheet.createRow(summaryRow++); label = row1.createCell(0); label.setCellValue(t.getHumanReadableName()); final int nofMarkers = markers.get(t).size(); numberCell = row1.createCell(1); numberCell.setCellValue(nofMarkers); // row-1 is the number of found markers smellCount.put(t.name(), nofMarkers); } progress.worked(20); final MarkerHandler mh = AnalyzerCache.withAll().analyzeProject(progress.newChild(30), project); progress.setWorkRemaining(CodeSmellType.values().length + 1); // export the semantic problem markers: for (final CodeSmellType t : CodeSmellType.values()) { createCodeSmellSheet(workbook, mh, t); final Row row1 = summarySheet.createRow(summaryRow++); label = row1.createCell(0); label.setCellValue(t.getHumanReadableName()); smellCount.put(t.name(), mh.numberOfOccurrences(t)); numberCell = row1.createCell(1); numberCell.setCellValue(mh.numberOfOccurrences(t)); progress.worked(1); } final Row row0 = summarySheet.createRow(0); row0.createCell(0).setCellValue("Project: " + project.getName()); final Row row1 = summarySheet.createRow(1); row1.createCell(0).setCellValue("Code smell \\ date"); final CellStyle cellStyle = workbook.createCellStyle(); cellStyle.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat("yyyy.mm.dd")); label = row1.createCell(1); label.setCellValue(date); label.setCellStyle(cellStyle); final Row row2 = summarySheet.createRow(2); row2.createCell(0).setCellValue("Commulative Project Risk Factor"); final int riskFactor = new RiskFactorCalculator().measure(project, smellCount); row2.createCell(1).setCellValue(riskFactor); summarySheet.autoSizeColumn(0); summarySheet.autoSizeColumn(1); progress.worked(1); } catch (Exception e) { ErrorReporter.logExceptionStackTrace("Error while exporting to excel", e); } finally { FileOutputStream fileOutputStream = null; try { fileOutputStream = new FileOutputStream(file); workbook.write(fileOutputStream); } catch (Exception e) { ErrorReporter.logExceptionStackTrace("Error while closing the generated excel", e); } finally { IOUtils.closeQuietly(fileOutputStream); } } }
From source file:org.egov.infra.web.displaytag.export.EGovExcelReadOnlyView.java
License:Open Source License
/** * @see org.displaytag.export.BinaryExportView#doExport(OutputStream) *///from w w w . ja v a2s .c om @Override public void doExport(final OutputStream out) throws JspException { try { final HSSFWorkbook wb = new HSSFWorkbook(); wb.writeProtectWorkbook("egov", "egov");// To make the workbook read-only this.sheet = wb.createSheet("-"); int rowNum = 0; int colNum = 0; if (this.header) { // Create an header row final HSSFRow xlsRow = this.sheet.createRow(rowNum++); final HSSFCellStyle headerStyle = wb.createCellStyle(); headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS); headerStyle.setFillBackgroundColor(HSSFColor.BLUE_GREY.index); final HSSFFont bold = wb.createFont(); bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); bold.setColor(HSSFColor.WHITE.index); headerStyle.setFont(bold); final Iterator iterator = this.model.getHeaderCellList().iterator(); while (iterator.hasNext()) { final HeaderCell headerCell = (HeaderCell) iterator.next(); String columnHeader = headerCell.getTitle(); if (columnHeader == null) { columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName()); } final HSSFCell cell = xlsRow.createCell(colNum++); cell.setCellValue(escapeColumnValue(columnHeader)); cell.setCellStyle(headerStyle); } } // get the correct iterator (full or partial list according to the exportFull field) final RowIterator rowIterator = this.model.getRowIterator(this.exportFull); // iterator on rows while (rowIterator.hasNext()) { final Row row = rowIterator.next(); final HSSFRow xlsRow = this.sheet.createRow(rowNum++); colNum = 0; // iterator on columns final ColumnIterator columnIterator = row.getColumnIterator(this.model.getHeaderCellList()); while (columnIterator.hasNext()) { final Column column = columnIterator.nextColumn(); // Get the value to be displayed for the column final Object value = column.getValue(this.decorated); final HSSFCell cell = xlsRow.createCell(colNum++); if (value instanceof Number) { final Number num = (Number) value; cell.setCellValue(num.doubleValue()); } else if (value instanceof Date) { cell.setCellValue((Date) value); } else if (value instanceof Calendar) { cell.setCellValue((Calendar) value); } else { cell.setCellValue(escapeColumnValue(value)); } } } for (short i = 0; i < colNum; i++) { this.sheet.autoSizeColumn(i, true); } wb.write(out); } catch (final Exception e) { throw new ExcelGenerationException(e); } }
From source file:org.emmanet.controllers.statsSpreadsheetController.java
License:Apache License
public Boolean populateReqShipSheets(Map arg0, int irowStart, HSSFSheet sheetID, String state, HSSFWorkbook wb) { //state can equal either Reqs or Ship // GREY background STYLES NOT WORKING??? HSSFCellStyle style = wb.createCellStyle(); style.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index); // style.setFillPattern(CellStyle.BIG_SPOTS); List results = (List) arg0.get("EUCOMM" + state.toLowerCase() + "MonthYear");///## String sheetTitle = ""; if (state.equals("Ship")) { sheetTitle = "Strains Shipped"; }//from w w w. j a va 2s. co m if (state.equals("Reqs")) { sheetTitle = "Strains Requested"; } Map map = new HashMap(); Object O = arg0.get("Centres"); int irow = irowStart; HSSFRow rowTitle = sheetID.createRow(irow - 1); HSSFRichTextString titleData = new HSSFRichTextString(sheetTitle); //rowTitle.createCell((short) 0).setCellValue(titleData); HSSFCell cell = rowTitle.createCell((short) 0); cell.setCellValue(titleData); if (sheetTitle.equals("Strains Requested")) { sheetID.autoSizeColumn((short) 0); } cell.setCellStyle((HSSFCellStyle) style); map = (Map) O; System.out.println("Object [0])" + O.toString()); Iterator it = map.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); HSSFRow row = sheetID.createRow(irow); HSSFRichTextString data = new HSSFRichTextString(key); row.createCell((short) 0).setCellValue(data); /*use same row to create cell + results list value and count*/ double[] CNB = (double[]) arg0.get("EUCOMM" + state + "ByMonthYearCentre-CNB"); double[] CNR = (double[]) arg0.get("EUCOMM" + state + "ByMonthYearCentre-CNR"); double[] HMGU = (double[]) arg0.get("EUCOMM" + state + "ByMonthYearCentre-HMGU"); double[] ICS = (double[]) arg0.get("EUCOMM" + state + "ByMonthYearCentre-ICS"); double[] MRC = (double[]) arg0.get("EUCOMM" + state + "ByMonthYearCentre-MRC"); double[] SANG = (double[]) arg0.get("EUCOMM" + state + "ByMonthYearCentre-SANG"); double[] CNRS = (double[]) arg0.get("CNRS" + state + "ByMonthYearCentre-CNRS"); for (int ii = 0; ii < results.size(); ii++) { String colData = ""; if (key.equals("CNB")) { int iDbleVal = (int) CNB[ii]; System.out.println("CNB Val is:" + iDbleVal); colData = "" + iDbleVal + ""; } if (key.equals("CNR")) { int iDbleVal = (int) CNR[ii]; System.out.println("CNR Val is:" + iDbleVal); colData = "" + iDbleVal + ""; } if (key.equals("HMGU")) { int iDbleVal = (int) HMGU[ii]; System.out.println("HMGU Val is:" + iDbleVal); colData = "" + iDbleVal + ""; } if (key.equals("ICS")) { int iDbleVal = (int) ICS[ii]; System.out.println("ICS Val is:" + iDbleVal); colData = "" + iDbleVal + ""; } if (key.equals("MRC")) { int iDbleVal = (int) MRC[ii]; System.out.println("MRC Val is:" + iDbleVal); colData = "" + iDbleVal + ""; } if (key.equals("SANG")) { int iDbleVal = (int) SANG[ii]; System.out.println("SANG Val is:" + iDbleVal); colData = "" + iDbleVal + ""; } /* if (key.equals("CNRS")) { int iDbleVal = (int) CNRS[ii]; System.out.println("CNRS Val is:" + iDbleVal); colData = "" + iDbleVal + ""; }*/ HSSFRichTextString Data = new HSSFRichTextString(colData); int iCell = ii + 1; row.createCell((short) iCell).setCellValue(Data); } System.out.println("key value=" + key); irow++; } // HSSFRow row = sheet2.getRow(1); HSSFRow row = sheet2.createRow(irowStart - 1); System.out.println("results size" + results.size() + " row " + row); int iCol = 1; for (Iterator it1 = results.listIterator(); it1.hasNext();) { Object[] o = (Object[]) it1.next(); HSSFRichTextString data = new HSSFRichTextString(o[0].toString() + " " + o[1].toString()); row.createCell((short) iCol).setCellValue(data); iCol++; //System.out.println("\t" + sendDataCNB[j] + "\t" + sendDataCNR[j] + "\t" + sendDataHMGU[j] + "\t" + sendDataICS[j] + "\t" + sendDataMRC[j] + "\t" + sendDataSANG[j] + "\t"); } //shipped counts int iirow = 0; int iirow1 = 0; int[] lists = null; int[] lists1 = null; // boolean reqsSet = false;///# HSSFRichTextString header = new HSSFRichTextString(""); HSSFRichTextString header1 = new HSSFRichTextString(""); if (state.equals("Ship")) { iirow = 36;//29; header = new HSSFRichTextString("Shipped Totals"); lists = (int[]) arg0.get(state.toLowerCase() + "Counts"); } else if (state.equals("Reqs")) { iirow = 12;//0; // reqsSet = true;//# header = new HSSFRichTextString("Request Totals"); lists = (int[]) arg0.get(state.toLowerCase() + "Counts"); if (state.equals("Reqs")) {//# iirow1 = 12;//0;//# header1 = new HSSFRichTextString("Requests Cancelled Totals");//# lists1 = (int[]) arg0.get("reqsCountsCanc"); } } ///// int[] lists = (int[]) arg0.get(state.toLowerCase() + "Counts"); /* now base on Reqs set new data list if not empty then dump it out or construct a method * * to write extra out */ HSSFRow rowHeader = sheet2.createRow(iirow - 1); rowHeader.createCell((short) 1).setCellValue(header); it = map.keySet().iterator(); int iCodeRow = iirow; while (it.hasNext()) { String key = (String) it.next(); HSSFRow rowSiteCodes = sheet2.createRow(iCodeRow); HSSFRichTextString dataSiteCodes = new HSSFRichTextString(key); if (state.equals("CancReqs")) {//# rowSiteCodes.createCell((short) 4).setCellValue(dataSiteCodes);//NEEDS CHANGING FOR CANC } else { rowSiteCodes.createCell((short) 0).setCellValue(dataSiteCodes);//NEEDS CHANGING FOR CANC } iCodeRow++; } for (int i = 0; i < lists.length; i++) { Object o = (Object) lists[i]; HSSFRow rowLists = sheet2.createRow(iirow); HSSFRichTextString data = new HSSFRichTextString(o.toString()); rowLists.createCell((short) 1).setCellValue(data); iirow++; } // cancelled request counts. if (lists1 != null) { HSSFRow rowHeader1 = sheet2.createRow(iirow1 - 1); rowHeader1.createCell((short) 5).setCellValue(header1); for (int i = 0; i < lists1.length; i++) { Object o = (Object) lists1[i]; HSSFRow rowLists = sheet2.createRow(iirow1); HSSFRichTextString data = new HSSFRichTextString(o.toString()); rowLists.createCell((short) 5).setCellValue(data); iirow1++; } } //end shipped counts return true; }