jxl.write.WritableWorkbook Java Examples
The following examples show how to use
jxl.write.WritableWorkbook.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResultExport.java From yeti with MIT License | 8 votes |
public static void ExportCertToXLS(String filename, ArrayList<Object> data) throws IOException { try { WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, true); WritableCellFormat titleformat = new WritableCellFormat(titleFont); WritableWorkbook workbook = Workbook.createWorkbook(new File(filename)); WritableSheet sheet = workbook.createSheet("SSLCert CN", 0); sheet.addCell(new Label(0, 0, "IP address", titleformat)); sheet.addCell(new Label(1, 0, "Host name", titleformat)); sheet.addCell(new Label(2, 0, "Domain name", titleformat)); int nextRow = 1; Iterator i = data.iterator(); while (i.hasNext()) { CertResult res = (CertResult) i.next(); sheet.addCell(new Label(0, nextRow, res.getIpAddress())); sheet.addCell(new Label(1, nextRow, res.getHostName())); sheet.addCell(new Label(2, nextRow, res.getDomainName())); nextRow++; } workbook.write(); workbook.close(); } catch (WriteException ex) { Logger.getLogger("resultExport.ExportForwardLookupsToXLS").log(Level.SEVERE, null, ex); } }
Example #2
Source File: ResultExport.java From yeti with MIT License | 8 votes |
public static void ExportTLDToXLS(String filename, ArrayList<Object> data) throws IOException { try { WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, true); WritableCellFormat titleformat = new WritableCellFormat(titleFont); WritableWorkbook workbook = Workbook.createWorkbook(new File(filename)); WritableSheet sheet = workbook.createSheet("TLD Expand", 0); sheet.addCell(new Label(0, 0, "Domain name", titleformat)); sheet.addCell(new Label(1, 0, "Name server", titleformat)); sheet.addCell(new Label(2, 0, "Admin name", titleformat)); sheet.addCell(new Label(3, 0, "Registrant", titleformat)); int nextRow = 1; Iterator i = data.iterator(); while (i.hasNext()) { DomainResult res = (DomainResult) i.next(); sheet.addCell(new Label(0, nextRow, res.getDomainName())); sheet.addCell(new Label(1, nextRow, res.getNameServer())); sheet.addCell(new Label(2, nextRow, res.getAdminName())); sheet.addCell(new Label(3, nextRow, res.getRegistrant())); nextRow++; } workbook.write(); workbook.close(); } catch (WriteException ex) { Logger.getLogger("resultExport.ExportForwardLookupsToXLS").log(Level.SEVERE, null, ex); } }
Example #3
Source File: ResultExport.java From yeti with MIT License | 8 votes |
public static void ExportForwardLookupsToXLS(String filename, List<Object> data) throws IOException { try { WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, true); WritableCellFormat titleformat = new WritableCellFormat(titleFont); WritableWorkbook workbook = Workbook.createWorkbook(new File(filename)); WritableSheet sheet = workbook.createSheet("Forward lookups", 0); sheet.addCell(new Label(0, 0, "Domain name", titleformat)); sheet.addCell(new Label(1, 0, "Host name", titleformat)); sheet.addCell(new Label(2, 0, "IP address", titleformat)); sheet.addCell(new Label(3, 0, "Type", titleformat)); int nextRow = 1; Iterator i = data.iterator(); while (i.hasNext()) { ForwardLookupResult res = (ForwardLookupResult) i.next(); sheet.addCell(new Label(0, nextRow, res.getDomainName())); sheet.addCell(new Label(1, nextRow, res.getHostName())); sheet.addCell(new Label(2, nextRow, res.getIpAddress())); sheet.addCell(new Label(3, nextRow, res.getLookupType())); nextRow++; } workbook.write(); workbook.close(); } catch (WriteException ex) { Logger.getLogger("resultExport.ExportForwardLookupsToXLS").log(Level.SEVERE, null, ex); } }
Example #4
Source File: ResultExport.java From yeti with MIT License | 7 votes |
public static void ExportReverseToXLS(String filename, ArrayList<Object> data) throws IOException { try { WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, true); WritableCellFormat titleformat = new WritableCellFormat(titleFont); WritableWorkbook workbook = Workbook.createWorkbook(new File(filename)); WritableSheet sheet = workbook.createSheet("Bing IP search", 0); sheet.addCell(new Label(0, 0, "IP address", titleformat)); sheet.addCell(new Label(1, 0, "Domain name", titleformat)); sheet.addCell(new Label(2, 0, "Host name", titleformat)); int nextRow = 1; Iterator i = data.iterator(); while (i.hasNext()) { ReverseLookupResult res = (ReverseLookupResult) i.next(); sheet.addCell(new Label(0, nextRow, res.getIpAddress())); sheet.addCell(new Label(1, nextRow, res.getDomainName())); sheet.addCell(new Label(2, nextRow, res.getHostName())); nextRow++; } workbook.write(); workbook.close(); } catch (WriteException ex) { Logger.getLogger("resultExport.ExportReverseToXLS").log(Level.SEVERE, null, ex); } }
Example #5
Source File: DownloadFileService.java From pacbot with Apache License 2.0 | 6 votes |
/** * Gets the file bytes. * * @param issueDetails the issue details * @param methodType the method type * @param columns the columns * @return the file bytes * @throws WriteException the write exception * @throws IOException Signals that an I/O exception has occurred. */ private byte[] getFileBytes(JsonArray issueDetails, String methodType, List<String>columns) throws WriteException, IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); WritableWorkbook workbook = Workbook.createWorkbook(baos); WritableSheet writablesheet = workbook.createSheet(methodType, 0); formatWritableSheet(writablesheet,columns); addWritableSheetCells(writablesheet, issueDetails,columns); workbook.write(); workbook.close(); return baos.toByteArray(); }
Example #6
Source File: WriteExcel.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public java.io.InputStream write( List<WorkItem> list) throws IOException, WriteException { java.io.OutputStream os = new java.io.ByteArrayOutputStream() ; WorkbookSettings wbSettings = new WorkbookSettings(); wbSettings.setLocale(new Locale("en", "EN")); // Create a Workbook - pass the OutputStream WritableWorkbook workbook = Workbook.createWorkbook(os, wbSettings); workbook.createSheet("Work Item Report", 0); WritableSheet excelSheet = workbook.getSheet(0); createLabel(excelSheet) ; int size = createContent(excelSheet, list); // Close the workbook workbook.write(); workbook.close(); // Get an inputStram that represents the Report java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream(); stream = (java.io.ByteArrayOutputStream)os; byte[] myBytes = stream.toByteArray(); java.io.InputStream is = new java.io.ByteArrayInputStream(myBytes) ; return is ; }
Example #7
Source File: TestSpreadsheetDataSetConsumer.java From morf with Apache License 2.0 | 6 votes |
@Test public void testUnsupportedColumns() { TableOutputter outputter = mock(TableOutputter.class); final SpreadsheetDataSetConsumer consumer = new SpreadsheetDataSetConsumer( mock(OutputStream.class), Optional.<Map<String, Integer>>empty(), outputter ); Table one = table("one"); Table two = table("two"); when(outputter.tableHasUnsupportedColumns(one)).thenReturn(true); when(outputter.tableHasUnsupportedColumns(two)).thenReturn(false); consumer.table(one, NO_RECORDS); consumer.table(two, NO_RECORDS); verify(outputter).table(anyInt(), any(WritableWorkbook.class), eq(two), eq(NO_RECORDS)); verify(outputter, times(0)).table(anyInt(), any(WritableWorkbook.class), eq(one), eq(NO_RECORDS)); }
Example #8
Source File: ClassifierResultsAnalysis.java From tsml with GNU General Public License v3.0 | 5 votes |
protected static void jxl_buildStatSheets_timings(WritableWorkbook wb, String basePath, PerformanceMetric metric, int statIndex, String evalSet, String timingType) { // ************* the difference: timings folder assumed instead of going by the specific metric name //i.e Timings/TRAIN/TrainTimings and Timings/TEST/TestTimings //instead of TrainTimings/TRAIN/TrainTimings ... String metricPath = basePath + "Timings"+timingType+"/" + evalSet + "/"; WritableSheet avgsSheet = wb.createSheet(metric.name, wb.getNumberOfSheets()); String testCSV = metricPath + fileNameBuild_avgsFile(evalSet, metric); jxl_copyCSVIntoSheet(avgsSheet, testCSV); WritableSheet summarySheet = wb.createSheet(metric.name+"SigDiffs", wb.getNumberOfSheets()); String summaryCSV = metricPath + fileNameBuild_summaryFile(evalSet, metric); jxl_copyCSVIntoSheet(summarySheet, summaryCSV); }
Example #9
Source File: ExportStoriesFromProductBacklogAction.java From ezScrum with GNU General Public License v2.0 | 5 votes |
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ProjectObject mProject = SessionManager.getProjectObject(request); IUserSession mUserSession = (IUserSession) request.getSession().getAttribute("UserSession"); // get all stories ArrayList<StoryObject> mStories = new ProductBacklogLogic(mProject).getStories(); // set the path of the temp file File mTempFile = File.createTempFile("ezScrumExcel", Long.toString(System.nanoTime())); String mPath = mTempFile.getAbsolutePath(); try { // 建立 Excel WritableWorkbook workbook = Workbook.createWorkbook(new File(mPath)); WritableSheet sheet = workbook.createSheet("BACKLOG", 0); // delicate to excel handler ExcelHandler handler = new ExcelHandler(mProject.getId(), sheet); handler.save(mStories); // 寫入excel workbook.write(); // 關閉excel的連結 workbook.close(); } catch (Exception e) { e.printStackTrace(); } response.setHeader("Content-disposition", "inline; filename=" + mProject.getName() + "_ProductBacklog.xls"); String contentType = "application/vnd.ms-excel"; File file = new File(mPath); ScrumRole sr = new ScrumRoleLogic().getScrumRole(mProject, mUserSession.getAccount()); if (sr.getAccessProductBacklog()) { return new FileStreamInfo(contentType, file); } else { return null; } }
Example #10
Source File: AbstractJExcelView2.java From JDeSurvey with GNU Affero General Public License v3.0 | 5 votes |
/** * Renders the Excel view, given the specified model. */ @Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Set the content type and get the output stream. response.setContentType(getContentType()); OutputStream outputStream = response.getOutputStream(); WritableWorkbook writableWorkbook; if (this.url != null) { Workbook workbook = getTemplateSource(this.url, request); //this was modified from the standard AbstractJExcelView2 spring library to handle an error parsing out the //username in linux environments WorkbookSettings workbookSettings = ((WorkbookParser) workbook).getSettings(); workbookSettings.setWriteAccess("BSAS"); writableWorkbook = Workbook.createWorkbook(outputStream, workbook,workbookSettings); } else { logger.debug("Creating Excel Workbook from scratch"); writableWorkbook = Workbook.createWorkbook(outputStream); } buildExcelDocument(model, writableWorkbook, request, response); // Should we set the content length here? // response.setContentLength(workbook.getBytes().length); writableWorkbook.write(); outputStream.flush(); writableWorkbook.close(); }
Example #11
Source File: ExcelUtils.java From jshERP with GNU General Public License v3.0 | 5 votes |
public static String createTempFile(String[] names, String title, List<String[]> objects) throws Exception { File excelFile = File.createTempFile(System.currentTimeMillis() + "", ".xls"); WritableWorkbook wtwb = Workbook.createWorkbook(excelFile); WritableSheet sheet = wtwb.createSheet(title, 0); sheet.getSettings().setDefaultColumnWidth(20); WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15); WritableCellFormat format = new WritableCellFormat(wfont); WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); WritableCellFormat wcfFC = new WritableCellFormat(wfc); wcfFC.setAlignment(Alignment.CENTRE); wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE); // CellView cellView = new CellView(); // cellView.setAutosize(true); //设置自动大小 format.setAlignment(Alignment.LEFT); format.setVerticalAlignment(VerticalAlignment.TOP); sheet.mergeCells(0, 0, names.length - 1, 0); sheet.addCell(new Label(0, 0, title, wcfFC)); int rowNum = 2; for (int i = 0; i < names.length; i++) { sheet.addCell(new Label(i, 1, names[i], format)); } for (int j = 0; j < objects.size(); j++) { String[] obj = objects.get(j); for (int h = 0; h < obj.length; h++) { sheet.addCell(new Label(h, rowNum, obj[h], format)); } rowNum = rowNum + 1; } wtwb.write(); wtwb.close(); return excelFile.getName(); }
Example #12
Source File: ExcelUtils.java From jshERP with GNU General Public License v3.0 | 5 votes |
public static File exportObjects(String fileName, String[] names, String title, List<String[]> objects) throws Exception { File excelFile = new File("fileName.xls"); WritableWorkbook wtwb = Workbook.createWorkbook(excelFile); WritableSheet sheet = wtwb.createSheet(title, 0); sheet.getSettings().setDefaultColumnWidth(20); WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15); WritableCellFormat format = new WritableCellFormat(wfont); WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); WritableCellFormat wcfFC = new WritableCellFormat(wfc); wcfFC.setAlignment(Alignment.CENTRE); wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE); // CellView cellView = new CellView(); // cellView.setAutosize(true); //设置自动大小 format.setAlignment(Alignment.LEFT); format.setVerticalAlignment(VerticalAlignment.TOP); sheet.mergeCells(0, 0, names.length - 1, 0); sheet.addCell(new Label(0, 0, title, wcfFC)); int rowNum = 2; for (int i = 0; i < names.length; i++) { sheet.addCell(new Label(i, 1, names[i], format)); } for (int j = 0; j < objects.size(); j++) { String[] obj = objects.get(j); for (int h = 0; h < obj.length; h++) { sheet.addCell(new Label(h, rowNum, obj[h], format)); } rowNum = rowNum + 1; } wtwb.write(); wtwb.close(); return excelFile; }
Example #13
Source File: CreateFilePane.java From pattypan with MIT License | 5 votes |
/** * * @param workbook * @throws WriteException */ private void createTemplateSheet(WritableWorkbook workbook) throws WriteException { WritableSheet templateSheet = workbook.createSheet("Template", 1); templateSheet.addCell(new Label(0, 0, "'" + Session.WIKICODE)); // ^^ // leading apostrophe prevents turning wikitext into formula in Excel autoSizeColumn(0, templateSheet); }
Example #14
Source File: CreateFilePane.java From pattypan with MIT License | 5 votes |
private void createSpreadsheet() throws IOException, BiffException, WriteException { File f = new File(Session.DIRECTORY, fileName.getText() + ".xls"); WritableWorkbook workbook = Workbook.createWorkbook(f); createDataSheet(workbook); createTemplateSheet(workbook); workbook.write(); workbook.close(); Session.FILE = f; }
Example #15
Source File: AbstractJExcelView.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Renders the Excel view, given the specified model. */ @Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Set the content type and get the output stream. response.setContentType(getContentType()); OutputStream out = response.getOutputStream(); WritableWorkbook workbook; if (this.url != null) { Workbook template = getTemplateSource(this.url, request); workbook = Workbook.createWorkbook(out, template); } else { logger.debug("Creating Excel Workbook from scratch"); workbook = Workbook.createWorkbook(out); } buildExcelDocument(model, workbook, request, response); // Should we set the content length here? // response.setContentLength(workbook.getBytes().length); workbook.write(); out.flush(); workbook.close(); }
Example #16
Source File: HRExcelJExcelBuilder.java From Spring-MVC-Blueprints with MIT License | 5 votes |
@Override protected void buildExcelDocument(Map<String, Object> model, WritableWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception { // get data model which is passed by the Spring container List<HrmsLogin> users = (List<HrmsLogin>) model.get("allUsers"); // create a new Excel sheet WritableSheet sheet = workbook.createSheet("Master List of Users", 0); // create header row sheet.addCell(new Label(0, 0, "Employee ID")); sheet.addCell(new Label(1, 0, "Username")); sheet.addCell(new Label(2, 0, "Password")); sheet.addCell(new Label(3, 0, "Role")); // create data rows int rowCount = 1; for (HrmsLogin user : users) { sheet.addCell(new Label(0, rowCount, user.getHrmsEmployeeDetails().getEmpId()+"")); sheet.addCell(new Label(1, rowCount, user.getUsername())); sheet.addCell(new Label(2, rowCount, user.getPassword())); sheet.addCell(new Label(3, rowCount, user.getRole())); rowCount++; } }
Example #17
Source File: ExcelExporter.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
public boolean write() throws Exception { if (writer != null) { writer.init(); } if (output != null && writer != null) { Workbook templateWorkbook = null; WritableWorkbook workbook = null; boolean closed = false; try { String templateFileName = writer.getTemplateFileName(); if (templateFileName != null && templateFileName.length() > 0) { templateWorkbook = Workbook.getWorkbook(new File(templateFileName)); workbook = Workbook.createWorkbook(output.getOutputStream(), templateWorkbook, writer.getSettings()); } else { workbook = Workbook.createWorkbook(output.getOutputStream(), writer.getSettings()); } writer.writeSpreadSheets(workbook); workbook.write(); workbook.close(); // before save! closed = true; return output.save(); } finally { if (workbook != null && !closed) { workbook.close(); } if (templateWorkbook != null) { templateWorkbook.close(); } } } else { return false; } }
Example #18
Source File: WorkbookWriter.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void writeSpreadSheets(WritableWorkbook workbook) throws Exception { Iterator<SpreadSheetWriter> spreadSheetWriterIt = getSpreadSheetWriters().iterator(); int sheetIndex = 0; while (spreadSheetWriterIt.hasNext()) { applySpreadsheetSettings(spreadSheetWriterIt.next().writeSpreadSheet(workbook), sheetIndex); sheetIndex++; } }
Example #19
Source File: XlsExporter.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
private long printRows(XlsExporterContext context, RowWriter writer) throws Throwable { ByteArrayOutputStream buffer = null; try { WritableWorkbook workbook; WorkbookSettings workbookSettings = writer.getWorkbookSettings(); if (!CommonUtil.isEmptyString(context.getFileName())) { jobOutput.println("writing to file " + context.getFileName()); if (workbookSettings != null) { workbook = Workbook.createWorkbook(new File(context.getFileName()), workbookSettings); } else { workbook = Workbook.createWorkbook(new File(context.getFileName())); } } else { buffer = new ByteArrayOutputStream(); if (workbookSettings != null) { workbook = Workbook.createWorkbook(buffer, workbookSettings); } else { workbook = Workbook.createWorkbook(buffer); } } context.setWorkbook(workbook); writer.init(); writer.printRows(); workbook.write(); workbook.close(); } catch (Exception e) { throw new IllegalArgumentException("row " + (writer.getLineCount() + 1) + ": error writing row", e); } if (buffer != null) { jobOutput.addEmailXlsAttachment(buffer.toByteArray()); } jobOutput.println(writer.getLineCount() + " rows exported"); return writer.getLineCount(); }
Example #20
Source File: AbstractJExcelView.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Renders the Excel view, given the specified model. */ @Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Set the content type and get the output stream. response.setContentType(getContentType()); OutputStream out = response.getOutputStream(); WritableWorkbook workbook; if (this.url != null) { Workbook template = getTemplateSource(this.url, request); workbook = Workbook.createWorkbook(out, template); } else { logger.debug("Creating Excel Workbook from scratch"); workbook = Workbook.createWorkbook(out); } buildExcelDocument(model, workbook, request, response); // Should we set the content length here? // response.setContentLength(workbook.getBytes().length); workbook.write(); out.flush(); workbook.close(); }
Example #21
Source File: ClassifierResultsAnalysis.java From tsml with GNU General Public License v3.0 | 5 votes |
protected static void jxl_buildStatSheets(WritableWorkbook wb, String basePath, PerformanceMetric metric, int statIndex) { String metricPath = basePath + metric + "/"; String testMetricPath = metricPath + testLabel + "/"; WritableSheet testSheet = wb.createSheet(metric+"Test", wb.getNumberOfSheets()); String testCSV = testMetricPath+ fileNameBuild_avgsFile(testLabel, metric); jxl_copyCSVIntoSheet(testSheet, testCSV); WritableSheet summarySheet = wb.createSheet(metric+"TestSigDiffs", wb.getNumberOfSheets()); String summaryCSV = testMetricPath + fileNameBuild_summaryFile(testLabel, metric); jxl_copyCSVIntoSheet(summarySheet, summaryCSV); }
Example #22
Source File: ExcelUtils.java From jshERP with GNU General Public License v3.0 | 4 votes |
public static String createCheckRandomTempFile(String[] names, String title, List<String[]> objects,Map<String,String> infoMap) throws Exception { File excelFile = File.createTempFile(System.currentTimeMillis() + "", ".xls"); WritableWorkbook wtwb = Workbook.createWorkbook(excelFile); WritableSheet sheet = wtwb.createSheet(title, 0); sheet.getSettings().setDefaultColumnWidth(20); WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 14); WritableCellFormat format = new WritableCellFormat(wfont); format.setBorder(Border.ALL, BorderLineStyle.THIN); format.setAlignment(Alignment.CENTRE); format.setVerticalAlignment(VerticalAlignment.CENTRE); WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); WritableCellFormat wcfFC = new WritableCellFormat(wfc); wcfFC.setAlignment(Alignment.LEFT); wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE); WritableFont nameWfc = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); WritableCellFormat nameFormat = new WritableCellFormat(nameWfc); nameFormat.setBorder(Border.ALL, BorderLineStyle.THIN); nameFormat.setAlignment(Alignment.CENTRE); nameFormat.setVerticalAlignment(VerticalAlignment.CENTRE); WritableCellFormat infoFormat = new WritableCellFormat(wfont); infoFormat.setAlignment(Alignment.LEFT); infoFormat.setVerticalAlignment(VerticalAlignment.CENTRE); sheet.mergeCells(0, 0, names.length - 1, 0); sheet.addCell(new Label(0, 0, infoMap.get("title"), wcfFC)); sheet.addCell(new Label(0, 2, infoMap.get("info"), infoFormat)); sheet.addCell(new Label(2, 2, infoMap.get("dvrnvr"), infoFormat)); sheet.addCell(new Label(4, 2, infoMap.get("char"), infoFormat)); sheet.addCell(new Label(0, 3, infoMap.get("infoPercent"), infoFormat)); sheet.addCell(new Label(2, 3, infoMap.get("dvrnvrPercent"), infoFormat)); sheet.addCell(new Label(4, 3, infoMap.get("charPercent"), infoFormat)); int rowNum = 5; for (int i = 0; i < names.length; i++) { sheet.addCell(new Label(i, 4, names[i], nameFormat)); } for (int j = 0; j < objects.size(); j++) { String[] obj = objects.get(j); for (int h = 0; h < obj.length; h++) { sheet.addCell(new Label(h, rowNum, obj[h], format)); } rowNum = rowNum + 1; } wtwb.write(); wtwb.close(); return excelFile.getName(); }
Example #23
Source File: XlsExporterContext.java From ctsms with GNU Lesser General Public License v2.1 | 4 votes |
public void setWorkbook(WritableWorkbook workbook) { this.workbook = workbook; }
Example #24
Source File: XlsExporterContext.java From ctsms with GNU Lesser General Public License v2.1 | 4 votes |
public WritableWorkbook getWorkbook() { return workbook; }
Example #25
Source File: AbstractJExcelView.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Subclasses must implement this method to create an Excel Workbook * document, given the model. * @param model the model Map * @param workbook the Excel workbook to complete * @param request in case we need locale etc. Shouldn't look at attributes. * @param response in case we need to set cookies. Shouldn't write to it. * @throws Exception in case of failure */ protected abstract void buildExcelDocument(Map<String, Object> model, WritableWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception;
Example #26
Source File: AbstractJExcelView2.java From JDeSurvey with GNU Affero General Public License v3.0 | 2 votes |
/** * Subclasses must implement this method to create an Excel Workbook * document, given the model. * @param model the model Map * @param workbook the Excel workbook to complete * @param request in case we need locale etc. Shouldn't look at attributes. * @param response in case we need to set cookies. Shouldn't write to it. * @throws Exception in case of failure */ protected abstract void buildExcelDocument(Map<String, Object> model, WritableWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception;
Example #27
Source File: AbstractJExcelView.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Subclasses must implement this method to create an Excel Workbook * document, given the model. * @param model the model Map * @param workbook the Excel workbook to complete * @param request in case we need locale etc. Shouldn't look at attributes. * @param response in case we need to set cookies. Shouldn't write to it. * @throws Exception in case of failure */ protected abstract void buildExcelDocument(Map<String, Object> model, WritableWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception;
Example #28
Source File: PanExcelWriter.java From Astrosoft with GNU General Public License v2.0 | 2 votes |
public PanExcelWriter(int year) throws Exception { WritableWorkbook workbook = null; PanchangList pl = new PanchangList(year); WritableSheet sheet= null; int sheetNo = 0; for(Panchang p:pl){ Calendar cal = p.getDate(); if (cal.get(Calendar.DATE) == 1) { workbook = Workbook.createWorkbook(new File(PARENT_DIR, "pan_" + monFormat.format(cal.getTime()) + ".xls" )); sheetNo = 0; } sheet = workbook.createSheet(dateFormat.format(cal.getTime()), sheetNo++); sheet.setColumnView(0, 10); sheet.setColumnView(1, 30); TableData<MapTableRow> data = p.getPanchangTableData(); for(int i = 0; i < data.getRowCount(); i++){ TableRowData row = data.getRow(i); String key = row.getColumnData(AstrosoftTableColumn.Key).toString(); if (!key.equals("Auspicious Time") && !key.equals("Rahu Kala") && !key.equals("Yama Kanda") ){ if (key.indexOf("End") >= 0){ key = key.substring(0, key.length()-9); } writeRow(sheet, i, key, row.getColumnData(AstrosoftTableColumn.Value).toString()); } } if (cal.get(Calendar.DATE) == cal.getActualMaximum(Calendar.DATE)){ workbook.write(); workbook.close(); } } }
Example #29
Source File: ExcelWriter.java From ctsms with GNU Lesser General Public License v2.1 | votes |
public void writeSpreadSheets(WritableWorkbook workbook) throws Exception;