List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook HSSFWorkbook
public HSSFWorkbook()
From source file:com.github.crab2died.ExcelUtils.java
License:Open Source License
private Workbook exportExcelBySimpleHandler(List<SimpleSheetWrapper> sheets, boolean isXSSF) { Workbook workbook;/*from w w w . jav a 2 s. c o m*/ if (isXSSF) { workbook = new XSSFWorkbook(); } else { workbook = new HSSFWorkbook(); } // ?sheet for (SimpleSheetWrapper sheet : sheets) { this.generateSheet(workbook, sheet.getData(), sheet.getHeader(), sheet.getSheetName()); } return workbook; }
From source file:com.github.cutstock.excel.ExcelWriterSupport.java
License:Apache License
public void init() { if (getSheetVersion().equalsIgnoreCase(FileVersion2003)) { wb = new HSSFWorkbook(); } else {/*from w w w. j a va 2 s.co m*/ wb = new XSSFWorkbook(); } Sheet sheet = wb.createSheet(); sheetBuilder = new SheetBuilder(sheet); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.GeneralGUIComponents.HCAFLIMPluginFrame.java
License:Minecraft Mod Public
public void saveSequencingTablesFunction() { // write sheets to .xls wb = new HSSFWorkbook(); xYSequencing1.tableModel_.saveFOVTableModelAsSpreadsheet(); spectralSequencing1.tableModel_.saveFilterTableModelAsSpreadsheet(); timeCourseSequencing1.tableModel_.saveTimeCourseTableModelAsSpreadsheet(); FileOutputStream fileOut = null; try {/*from w w w .j a v a2s.co m*/ fileOut = new FileOutputStream(var_.basepath + "\\OpenHCAFLIM_Sequenzing.xls"); wb.write(fileOut); fileOut.close(); } catch (FileNotFoundException ex) { Logger.getLogger(FOVTableModel.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FOVTableModel.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.GeneralGUIComponents.HCAFLIMPluginFrame.java
License:Minecraft Mod Public
public void saveSequencingTablesForDebugging(String path) { // write sheets to .xls wb = new HSSFWorkbook(); xYSequencing1.tableModel_.saveFOVTableModelAsSpreadsheet(); spectralSequencing1.tableModel_.saveFilterTableModelAsSpreadsheet(); timeCourseSequencing1.tableModel_.saveTimeCourseTableModelAsSpreadsheet(); FileOutputStream fileOut = null; try {//from w w w . jav a2s . c o m fileOut = new FileOutputStream(path + ".xls"); wb.write(fileOut); fileOut.close(); } catch (FileNotFoundException ex) { Logger.getLogger(FOVTableModel.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FOVTableModel.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.github.gaborfeher.grantmaster.framework.base.ExcelExporter.java
License:Open Source License
private HSSFWorkbook createSpreadSheet() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("GrantMaster exported data"); int rowId = 0; rowId = addExcelRow(workbook, sheet, rowId, getTableViewHeader()); for (Object tableRowEntity : getTableItems()) { rowId = addExcelRow(workbook, sheet, rowId, getTableViewRow(tableRowEntity)); }/*from w w w .ja va 2 s . c om*/ return workbook; }
From source file:com.github.gujou.deerbelling.sonarqube.service.XlsTasksGenerator.java
License:Open Source License
public static File generateFile(Project sonarProject, FileSystem sonarFileSystem, String sonarUrl, String sonarLogin, String sonarPassword) { short formatIndex; HSSFDataFormat dataFormat = null;/*from w w w. j av a 2 s . co m*/ FileOutputStream out = null; HSSFWorkbook workbook = null; String filePath = sonarFileSystem.workDir().getAbsolutePath() + File.separator + "tasks_report_" + sonarProject.getEffectiveKey().replace(':', '-') + "." + ReportsKeys.TASKS_REPORT_TYPE_XLS_EXTENSION; File resultFile = new File(filePath); try { out = new FileOutputStream(resultFile); workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Tasks list"); // Date format. dataFormat = workbook.createDataFormat(); formatIndex = dataFormat.getFormat("yyyy-MM-ddTHH:mm:ss"); HSSFCellStyle dateStyle = workbook.createCellStyle(); dateStyle.setDataFormat(formatIndex); Issues rootIssue = IssueGateway.getOpenIssues(sonarProject.getEffectiveKey(), sonarUrl, sonarLogin, sonarPassword); if (rootIssue == null) { return null; } DataValidationHelper validationHelper = new HSSFDataValidationHelper(sheet); DataValidationConstraint constraint = validationHelper.createExplicitListConstraint( new String[] { "OPENED", "CONFIRMED", "REOPENED", "RESOLVED", "CLOSE" }); CellRangeAddressList addressList = new CellRangeAddressList(1, rootIssue.getIssues().size() + 1, STATUS_COLUMN_INDEX, STATUS_COLUMN_INDEX); DataValidation dataValidation = validationHelper.createValidation(constraint, addressList); dataValidation.setSuppressDropDownArrow(false); sheet.addValidationData(dataValidation); int rownum = 0; Row row = sheet.createRow(rownum++); row.createCell(STATUS_COLUMN_INDEX).setCellValue("Status"); row.createCell(SEVERITY_COLUMN_INDEX).setCellValue("Severity"); row.createCell(COMPONENT_COLUMN_INDEX).setCellValue("Component"); row.createCell(LINE_COLUMN_INDEX).setCellValue("Line"); row.createCell(MESSAGE_COLUMN_INDEX).setCellValue("Message"); row.createCell(AUTHOR_COLUMN_INDEX).setCellValue("Author"); row.createCell(ASSIGNED_COLUMN_INDEX).setCellValue("Assigned"); row.createCell(CREATION_DATE_COLUMN_INDEX).setCellValue("CreationDate"); row.createCell(UPDATE_DATE_COLUMN_INDEX).setCellValue("UpdateDate"); row.createCell(COMPONENT_PATH_COLUMN_INDEX).setCellValue("Path"); for (Issue issue : rootIssue.getIssues()) { if (issue != null) { row = sheet.createRow(rownum++); int componentIndex = 0; if (issue.getComponent() != null) { componentIndex = issue.getComponent().lastIndexOf('/'); } String component; String path; if (componentIndex > 0) { component = issue.getComponent().substring(componentIndex + 1); path = issue.getComponent().substring(0, componentIndex); } else { component = issue.getComponent(); path = ""; } // Set values. row.createCell(STATUS_COLUMN_INDEX).setCellValue(issue.getStatus()); row.createCell(SEVERITY_COLUMN_INDEX).setCellValue(issue.getSeverity()); row.createCell(COMPONENT_COLUMN_INDEX).setCellValue(component); row.createCell(LINE_COLUMN_INDEX).setCellValue(issue.getLine()); row.createCell(MESSAGE_COLUMN_INDEX).setCellValue(issue.getMessage()); row.createCell(AUTHOR_COLUMN_INDEX).setCellValue(issue.getAuthor()); row.createCell(ASSIGNED_COLUMN_INDEX).setCellValue(issue.getAssignee()); row.createCell(CREATION_DATE_COLUMN_INDEX).setCellValue(issue.getCreationDate()); row.createCell(UPDATE_DATE_COLUMN_INDEX).setCellValue(issue.getUpdateDate()); row.createCell(COMPONENT_PATH_COLUMN_INDEX).setCellValue(path); // Set date style to date column. row.getCell(CREATION_DATE_COLUMN_INDEX).setCellStyle(dateStyle); row.getCell(UPDATE_DATE_COLUMN_INDEX).setCellStyle(dateStyle); } } // Auto-size sheet columns. sheet.autoSizeColumn(STATUS_COLUMN_INDEX); sheet.autoSizeColumn(STATUS_COLUMN_INDEX); sheet.autoSizeColumn(COMPONENT_COLUMN_INDEX); sheet.autoSizeColumn(LINE_COLUMN_INDEX); sheet.autoSizeColumn(MESSAGE_COLUMN_INDEX); sheet.autoSizeColumn(AUTHOR_COLUMN_INDEX); sheet.autoSizeColumn(ASSIGNED_COLUMN_INDEX); sheet.autoSizeColumn(CREATION_DATE_COLUMN_INDEX); sheet.autoSizeColumn(UPDATE_DATE_COLUMN_INDEX); sheet.autoSizeColumn(COMPONENT_PATH_COLUMN_INDEX); workbook.write(out); } catch (FileNotFoundException e) { // TODO manage error. e.printStackTrace(); } catch (IOException e) { // TODO manage error. e.printStackTrace(); } finally { IOUtils.closeQuietly(workbook); IOUtils.closeQuietly(out); } return resultFile; }
From source file:com.github.jferard.spreadsheetwrapper.xls.poi.XlsPoiDocumentFactory.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from w w w . j a va 2 s.co m*/ protected Workbook newSpreadsheetDocument(/*@Nullable*/final OutputStream outputStream) throws SpreadsheetException { return new HSSFWorkbook(); }
From source file:com.github.luischavez.lat.excel.Excel.java
License:Open Source License
public File generate(String groupName, LocalDateTime dateTime) { String datetime = dateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME).replaceAll("-", "_") .replaceAll(":", "_").replaceAll("\\.", "_"); String path = System.getProperty("user.dir").concat("/excel/").concat(datetime).concat("/"); File file = new File(path); if (!file.exists()) { file.mkdirs();/*from ww w . ja v a2 s . co m*/ } file = new File(path.concat(groupName).concat(".xls")); Workbook workbook = new HSSFWorkbook(); Sheet sheet = workbook.createSheet(groupName); this.setContent(workbook, sheet, groupName); for (int i = 0; i < 11; i++) { sheet.autoSizeColumn(i); } try (FileOutputStream outputStream = new FileOutputStream(file)) { workbook.write(outputStream); } catch (IOException ex) { throw new RuntimeException(ex); } return file; }
From source file:com.github.svrtm.xlreport.Excel_97.java
License:Apache License
final static public Body instanceBody(final Header header) { header.init(new HSSFWorkbook(), SpreadsheetVersion.EXCEL97.getLastRowIndex(), Row97.class); header.prepareHeader();//from w w w .j a v a 2 s .c o m return new Body(header); }
From source file:com.github.svrtm.xlreport.Excel_97.java
License:Apache License
final static public Body instanceBody() { return new Body(new HSSFWorkbook(), SpreadsheetVersion.EXCEL97.getLastRowIndex()); }