List of usage examples for org.apache.poi.ss SpreadsheetVersion EXCEL2007
SpreadsheetVersion EXCEL2007
To view the source code for org.apache.poi.ss SpreadsheetVersion EXCEL2007.
Click Source Link
From source file:android_connector.ExcelReader.java
/** * Konstruktor der Klasse. Ldt eine Excel-Datei mit dem bergebenen Pfad * und speichert diese zur weiteren Verarbeitung. * * @param pathToExcelFile Pfad zur Excel-Datei * @throws IOException Exception, wenn Datei nicht gelesen werden kann *///from w w w . ja v a2 s . c o m public ExcelReader(String pathToExcelFile) throws IOException { //this.sheet = wb.getSheet(sheetName); if (pathToExcelFile.endsWith("xls")) { FileInputStream fileInput = new FileInputStream(new File(pathToExcelFile)); this.wb = new HSSFWorkbook(fileInput); //oder XSSFWorkbook(fileInput); version = SpreadsheetVersion.EXCEL97; } else { FileInputStream fileInput = new FileInputStream(new File(pathToExcelFile)); this.wb = new HSSFWorkbook(fileInput); version = SpreadsheetVersion.EXCEL2007; } }
From source file:com.asakusafw.testdata.generator.excel.SheetBuilderTest.java
License:Apache License
/** * Returns test parameter sets./* w w w .j a v a 2s . co m*/ * @return test parameter sets */ @Parameters public static List<Object[]> parameters() { return Arrays.asList(new Object[][] { { SpreadsheetVersion.EXCEL97 }, { SpreadsheetVersion.EXCEL2007 }, }); }
From source file:com.asakusafw.testdata.generator.excel.WorkbookGenerator.java
License:Apache License
/** * Returns spreadsheet version for the target workbook. * @param fileName the target workbook path * @return the target version//from w ww.j a v a 2 s . co m * @since 0.7.0 */ public static SpreadsheetVersion getSpreadsheetVersion(String fileName) { if (fileName == null) { throw new IllegalArgumentException("fileName must not be null"); //$NON-NLS-1$ } if (fileName.endsWith(".xls")) { //$NON-NLS-1$ return SpreadsheetVersion.EXCEL97; } else if (fileName.endsWith("xlsx")) { //$NON-NLS-1$ return SpreadsheetVersion.EXCEL2007; } else { throw new IllegalArgumentException( MessageFormat.format(Messages.getString("WorkbookGenerator.errorUnsupportedFormat"), //$NON-NLS-1$ fileName)); } }
From source file:com.asakusafw.testdata.generator.excel.WorkbookGenerator.java
License:Apache License
/** * Returns spreadsheet version for the target workbook. * @param workbook the target workbook//from w ww . java2 s .c om * @return the target version * @since 0.7.0 */ public static SpreadsheetVersion getSpreadsheetVersion(Workbook workbook) { if (workbook == null) { throw new IllegalArgumentException("workbook must not be null"); //$NON-NLS-1$ } if (workbook instanceof HSSFWorkbook) { return SpreadsheetVersion.EXCEL97; } else if (workbook instanceof XSSFWorkbook) { return SpreadsheetVersion.EXCEL2007; } else { throw new IllegalArgumentException( MessageFormat.format(Messages.getString("WorkbookGenerator.errorUnsupportedWorkbookApi"), //$NON-NLS-1$ workbook.getClass().getName())); } }
From source file:com.asakusafw.testdriver.excel.Util.java
License:Apache License
static SpreadsheetVersion getSpreadsheetVersionFor(String path) { if (isHssf(path)) { return SpreadsheetVersion.EXCEL97; } else if (isXssf(path)) { return SpreadsheetVersion.EXCEL2007; } else {/*from www .ja va 2 s . c o m*/ return SpreadsheetVersion.EXCEL97; } }
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();/* w w w. ja v a2 s . c o m*/ return new Body(header); }
From source file:com.github.svrtm.xlreport.Excel_2007XL.java
License:Apache License
final static public Body instanceBody(final Header header) { header.init(new SXSSFWorkbook(ROW_ACCESS_WINDOW_SIZE), SpreadsheetVersion.EXCEL2007.getLastRowIndex(), Row07XL.class); header.prepareHeader();/* www. ja va 2 s. c o m*/ return new Body(header); }
From source file:com.github.svrtm.xlreport.Excel_2007XL.java
License:Apache License
final static public Body instanceBody() { return new Body(new SXSSFWorkbook(ROW_ACCESS_WINDOW_SIZE), SpreadsheetVersion.EXCEL2007.getLastRowIndex()); }
From source file:com.miraisolutions.xlconnect.Workbook.java
License:Open Source License
/** * Get the workbook from a Microsoft Excel file. * * Reads the workbook if the file exists, otherwise creates a new workbook of the corresponding format. * * @param excelfile Microsoft Excel file to read or create if not existing * @return Instance of the workbook//from w ww .j a v a 2 s. c om * @throws FileNotFoundException * @throws IOException * @throws InvalidFormatException */ public static Workbook getWorkbook(File excelFile, boolean create) throws FileNotFoundException, IOException, InvalidFormatException { Workbook wb; if (excelFile.exists()) wb = new Workbook(excelFile); else { if (create) { String filename = excelFile.getName().toLowerCase(); if (filename.endsWith(".xls")) { wb = new Workbook(excelFile, SpreadsheetVersion.EXCEL97); } else if (filename.endsWith(".xlsx")) { wb = new Workbook(excelFile, SpreadsheetVersion.EXCEL2007); } else throw new IllegalArgumentException( "File extension \"" + filename.substring(filename.lastIndexOf('.') + 1) + "\" not supported! Only *.xls and *.xlsx are allowed!"); } else throw new FileNotFoundException("File '" + excelFile.getName() + "' could not be found - " + "you may specify to automatically create the file if not existing."); } return wb; }
From source file:de.jlo.talendcomp.excel.SpreadsheetOutput.java
License:Apache License
private boolean extendTable(XSSFTable table, int firstRow, int firstCol, int lastRow) throws Exception { try {/*ww w .j av a 2s . c o m*/ AreaReference currentRef = null; if (currentType == SpreadsheetTyp.XLS) { currentRef = new AreaReference(table.getCTTable().getRef(), SpreadsheetVersion.EXCEL97); } else { currentRef = new AreaReference(table.getCTTable().getRef(), SpreadsheetVersion.EXCEL2007); } CellReference topLeft = currentRef.getFirstCell(); CellReference buttomRight = currentRef.getLastCell(); if (topLeft.getRow() <= firstRow && buttomRight.getRow() >= firstRow && topLeft.getCol() <= firstCol && buttomRight.getCol() >= firstCol) { // this table is within our write area, we have to expand it AreaReference newRef = new AreaReference(topLeft, // left top including the header line new CellReference(lastRow, buttomRight.getCol())); // bottom right table.getCTTable().setRef(newRef.formatAsString()); return true; } else { return false; } } catch (Exception t) { if (workbook instanceof SXSSFWorkbook) { throw new Exception( "Extending table ranges cannot work in a workbook which is not fully loaded because of the memory saving mode. Uncheck Memory saving mode in tFileExcelWorkbookOpen!", t); } else { throw t; } } }