List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook XSSFWorkbook
public XSSFWorkbook()
From source file:com.github.pascalgn.jiracli.command.ReadTest.java
License:Apache License
@Test public void test1() throws Exception { File file = folder.newFile("temp.xlsx"); try (Workbook wb = new XSSFWorkbook()) { Sheet sheet1 = wb.createSheet("Sheet1"); for (int row = 10; row <= 110; row++) { ExcelUtils.writeCell(sheet1, row, 20, "ISSUE-" + row); }/*from ww w . jav a 2 s . co m*/ try (OutputStream out = new FileOutputStream(file)) { wb.write(out); } } Context context = new MockContext(); Read re = new Read(file.getAbsolutePath(), "Sheet1", "U"); TextList list = re.execute(context, None.getInstance()); assertNotNull(list); List<Text> texts = list.remaining(Hint.none()); assertNotNull(texts); assertEquals(101, texts.size()); assertEquals("ISSUE-10", texts.get(0).getText()); assertEquals("ISSUE-110", texts.get(100).getText()); }
From source file:com.github.pascalgn.jiracli.util.SimpleExcelHelperTest.java
License:Apache License
@Test public void test1() throws Exception { byte[] buf;//from w ww . jav a2 s . c o m try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { try (Workbook wb = new XSSFWorkbook()) { Sheet sheet1 = wb.createSheet("Sheet1"); for (int row = 0; row < 10; row++) { for (int column = 0; column < 10; column++) { String cell = row + "/" + column; ExcelUtils.writeCell(sheet1, row, column, cell); } } wb.write(out); } buf = out.toByteArray(); } final List<String> cellValues = new ArrayList<String>(); try (InputStream inputStream = new ByteArrayInputStream(buf)) { ExcelHelper excelHelper = new SimpleExcelHelper(); excelHelper.parseWorkbook(inputStream, new CellHandler() { @Override public void handleCell(int row, String column, String value) { cellValues.add(value); } }); } assertEquals(100, cellValues.size()); assertEquals("1/2", cellValues.get(12)); assertEquals("4/3", cellValues.get(43)); assertEquals("9/9", cellValues.get(99)); }
From source file:com.github.svrtm.xlreport.Excel_2007.java
License:Apache License
final static public Body instanceBody(final Header header) { header.init(new XSSFWorkbook(), SpreadsheetVersion.EXCEL2007.getLastRowIndex(), Row07.class); header.prepareHeader();//from ww w. ja v a2 s .c o m return new Body(header); }
From source file:com.github.svrtm.xlreport.Excel_2007.java
License:Apache License
final static public Body instanceBody() { return new Body(new XSSFWorkbook(), -1); }
From source file:com.github.wnameless.workbookaccessor.WorkbookReaderTest.java
License:Apache License
@Test public void testClose() { WorkbookReader.open(new XSSFWorkbook()).close(); }
From source file:com.github.wnameless.workbookaccessor.WorkbookWriter.java
License:Apache License
private WorkbookWriter(boolean xlsx) { workbook = xlsx ? new XSSFWorkbook() : new HSSFWorkbook(); sheet = workbook.createSheet(); }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
public File runQAChecksAndGenerateReport(long p_taskId) throws Exception { Task task = TaskHelper.getTask(p_taskId); Company company = CompanyWrapper.getCompanyById(task.getCompanyId()); if (!company.getEnableDitaChecks()) { return null; }/* w w w . j a v a 2s .c o m*/ // Create report // Note: as SXSSFWorkbook does not support "RichTextString" to highlight // check failed segment, we have to use XSSFWorkbook, this need more // memory. Workbook workBook = new XSSFWorkbook(); createReport(workBook, task); // Write workbook to file File reportDir = DITAQACheckerHelper.getReportFileDir(task); // As only store one copy for every task, before generate the new report // file, delete old ones if exists. FileUtil.deleteFile(reportDir); reportDir.mkdirs(); String fileName = getReportFileName(task); File reportFile = new File(reportDir, fileName); FileOutputStream out = new FileOutputStream(reportFile); workBook.write(out); out.close(); return reportFile; }
From source file:com.grant.report.StockOut.java
public static void main(String[] args) throws SQLException { ItemDAO d = new ItemDAO(); Map<String, Object[]> data = new TreeMap<String, Object[]>(); // data = d.getAllItemOutReport(); //Blank workbook XSSFWorkbook workbook = new XSSFWorkbook(); //Create a blank sheet XSSFSheet sheet = workbook.createSheet("Employee Data"); //This data needs to be written (Object[]) /*/* ww w. j a v a2s . co m*/ Map<String, Object[]> data = new TreeMap<String, Object[]>(); data.put("1", new Object[] {"ID", "NAME", "LASTNAME"}); data.put("2", new Object[] {1, "Amit", "Shukla"}); data.put("3", new Object[] {2, "Lokesh", "Gupta"}); data.put("4", new Object[] {3, "John", "Adwards"}); data.put("5", new Object[] {4, "Brian", "Schultz"}); */ //Iterate over data and write to sheet Set<String> keyset = data.keySet(); int rownum = 0; for (String key : keyset) { Row row = sheet.createRow(rownum++); Object[] objArr = data.get(key); int cellnum = 0; for (Object obj : objArr) { Cell cell = row.createCell(cellnum++); if (obj instanceof String) { cell.setCellValue((String) obj); } else if (obj instanceof Integer) { cell.setCellValue((Integer) obj); } } } try { //Write the workbook in file system FileOutputStream out = new FileOutputStream(new File("howtodoinjava_demo.xlsx")); workbook.write(out); out.close(); System.out.println("howtodoinjava_demo.xlsx written successfully on disk."); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.griffinslogistics.document.excel.BDLGenerator.java
public static void generateAll(OutputStream outputStream, Map<String, List<BookBoxModel>> bookBoxModelsForTransportation, Pulsiodetails pulsioDetails, String packageNumber) {// w w w .j av a2 s. c om try { Workbook workbook = new XSSFWorkbook(); for (String bookspackageNumber : bookBoxModelsForTransportation.keySet()) { List<BookBoxModel> bookBoxModels = bookBoxModelsForTransportation.get(bookspackageNumber); generate(workbook, bookBoxModels, pulsioDetails, bookspackageNumber); } workbook.write(outputStream); } catch (FileNotFoundException ex) { logger.log(Level.SEVERE, null, ex); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } }
From source file:com.griffinslogistics.document.excel.BDLGenerator.java
public static void generateSingle(OutputStream outputStream, List<BookBoxModel> bookBoxModels, Pulsiodetails pulsiodetails, String packageNumber) { try {//from ww w.j av a2 s. c om Workbook workbook = new XSSFWorkbook(); generate(workbook, bookBoxModels, pulsiodetails, packageNumber); workbook.write(outputStream); } catch (FileNotFoundException ex) { logger.log(Level.SEVERE, null, ex); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } }