Example usage for org.apache.poi.ss SpreadsheetVersion EXCEL97

List of usage examples for org.apache.poi.ss SpreadsheetVersion EXCEL97

Introduction

In this page you can find the example usage for org.apache.poi.ss SpreadsheetVersion EXCEL97.

Prototype

SpreadsheetVersion EXCEL97

To view the source code for org.apache.poi.ss SpreadsheetVersion EXCEL97.

Click Source Link

Document

Excel97 format aka BIFF8
  • The total number of available rows is 64k (2^16)
  • The total number of available columns is 256 (2^8)
  • The maximum number of arguments to a function is 30
  • Number of conditional format conditions on a cell is 3
  • Number of cell styles is 4000
  • Length of text cell contents is 32767

Usage

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
 *///w w  w  .  j  a v  a  2s. 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./*from   ww w .j  a  v a2  s . 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//  w  w  w  .  j a va  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/* w w w .  j  av a 2s .c  o  m*/
 * @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.testdata.generator.excel.WorkbookGeneratorTest.java

License:Apache License

/**
 * many columns./* w w w. j  av  a  2s  . c o  m*/
 * @throws Exception if occur
 */
@Test
public void many_columns() throws Exception {
    ModelDeclaration model = load("many_columns.dmdl", "many_columns");
    WorkbookGenerator generator = new WorkbookGenerator(folder.getRoot(), WorkbookFormat.DATA);

    generator.generate(model);
    Workbook workbook = open(folder.getRoot(), model, WorkbookFormat.DATA);

    Sheet sheet = workbook.getSheet(WorkbookFormat.DATA.getSheets().get(0).getName());
    assertThat(sheet.getRow(0).getLastCellNum(), is((short) SpreadsheetVersion.EXCEL97.getMaxColumns()));
}

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 {// w  w  w  . j a va 2  s.c  o m
        return SpreadsheetVersion.EXCEL97;
    }
}

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   www. j  ava2s  . 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());
}

From source file:com.haulmont.yarg.formatters.impl.xls.HSSFRangeHelper.java

License:Apache License

public static AreaReference getAreaForRange(HSSFWorkbook workbook, String rangeName) {
    int rangeNameIdx = workbook.getNameIndex(rangeName);
    if (rangeNameIdx == -1)
        return null;

    HSSFName aNamedRange = workbook.getNameAt(rangeNameIdx);
    return new AreaReference(aNamedRange.getRefersToFormula(), SpreadsheetVersion.EXCEL97);
}

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 w  w  .  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;
}