public void close() { if ( workbook != null ) { workbook.close(); } }
public int getRow() { return cell.getRow(); } }
private boolean isTemplateContained( Workbook templateWorkbook, File targetFile ) throws IOException, BiffException { Workbook targetFileWorkbook = Workbook.getWorkbook( targetFile ); int templateWorkbookNumberOfSheets = templateWorkbook.getNumberOfSheets(); int targetWorkbookNumberOfSheets = targetFileWorkbook.getNumberOfSheets(); if ( templateWorkbookNumberOfSheets > targetWorkbookNumberOfSheets ) { return false; Sheet templateWorkbookSheet = templateWorkbook.getSheet( worksheetNumber ); Sheet targetWorkbookSheet = targetFileWorkbook.getSheet( worksheetNumber ); int templateWorkbookSheetColumns = templateWorkbookSheet.getColumns(); int targetWorkbookSheetColumns = targetWorkbookSheet.getColumns(); if ( templateWorkbookSheetColumns > targetWorkbookSheetColumns ) { return false; int templateWorkbookSheetRows = templateWorkbookSheet.getRows(); int targetWorkbookSheetRows = targetWorkbookSheet.getRows(); if ( templateWorkbookSheetRows > targetWorkbookSheetRows ) { return false; Cell[] templateWorkbookSheetRow = templateWorkbookSheet.getRow( currentRowNumber ); Cell[] targetWorkbookSheetRow = targetWorkbookSheet.getRow( currentRowNumber ); if ( templateWorkbookSheetRow.length > targetWorkbookSheetRow.length ) { return false; Cell templateWorksheetCell = templateWorkbookSheetRow[currentCellNumber]; Cell targetWorksheetCell = targetWorkbookSheetRow[currentCellNumber]; if ( !templateWorksheetCell.getContents().equals( targetWorksheetCell.getContents() ) ) { return false;
excelOutput.dispose( meta, data ); Workbook workbook = Workbook.getWorkbook( excelFile ); Assert.assertEquals( 1, workbook.getSheets().length ); Assert.assertEquals( 2, workbook.getSheet( CREATED_SHEET_NAME ).getRows() );
public XLSWorkbook( InputStream inputStream, String encoding ) throws KettleException { this.encoding = encoding; WorkbookSettings ws = new WorkbookSettings(); if ( !Utils.isEmpty( encoding ) ) { ws.setEncoding( encoding ); } try { workbook = Workbook.getWorkbook( inputStream, ws ); } catch ( Exception e ) { throw new KettleException( e ); } }
public Object getValue() { switch ( getType() ) { case BOOLEAN_FORMULA: case BOOLEAN: return Boolean.valueOf( ( (BooleanCell) cell ).getValue() ); case DATE_FORMULA: case DATE: return ( (DateCell) cell ).getDate(); case NUMBER_FORMULA: case NUMBER: return Double.valueOf( ( (NumberCell) cell ).getValue() ); case STRING_FORMULA: case LABEL: return ( (LabelCell) cell ).getString(); case EMPTY: default: return null; } }
WorkbookSettings ws = new WorkbookSettings(); ws.setEncoding("Cp1252"); Workbook workbook = Workbook.getWorkbook(stream, ws);
public String getContents() { return cell.getContents(); }
public int getRows() { return sheet.getRows(); }
@Override public KSheet getSheet( String sheetName ) { Sheet sheet = workbook.getSheet( sheetName ); if ( sheet == null ) { return null; } return new XLSSheet( sheet ); }
public String getName() { return sheet.getName(); }
public KCell getCell( int colnr, int rownr ) { Cell cell = sheet.getCell( colnr, rownr ); if ( cell == null ) { return null; } return new XLSCell( cell ); } }
public KCell[] getRow( int rownr ) { Cell[] cells = sheet.getRow( rownr ); XLSCell[] xlsCells = new XLSCell[cells.length]; for ( int i = 0; i < cells.length; i++ ) { if ( cells[i] != null ) { xlsCells[i] = new XLSCell( cells[i] ); } } return xlsCells; }
public KCellType getType() { CellType type = cell.getType(); if ( type.equals( CellType.BOOLEAN ) ) { return KCellType.BOOLEAN; } else if ( type.equals( CellType.BOOLEAN_FORMULA ) ) { return KCellType.BOOLEAN_FORMULA; } else if ( type.equals( CellType.DATE ) ) { return KCellType.DATE; } else if ( type.equals( CellType.DATE_FORMULA ) ) { return KCellType.DATE_FORMULA; } else if ( type.equals( CellType.LABEL ) ) { return KCellType.LABEL; } else if ( type.equals( CellType.STRING_FORMULA ) ) { return KCellType.STRING_FORMULA; } else if ( type.equals( CellType.EMPTY ) ) { return KCellType.EMPTY; } else if ( type.equals( CellType.NUMBER ) ) { return KCellType.NUMBER; } else if ( type.equals( CellType.NUMBER_FORMULA ) ) { return KCellType.NUMBER_FORMULA; } return null; }
public int getNumberOfSheets() { return workbook.getNumberOfSheets(); }
public String[] getSheetNames() { return workbook.getSheetNames(); }
excelOutput.dispose( meta, data ); Workbook workbook = Workbook.getWorkbook( excelFile ); Assert.assertEquals( 1, workbook.getSheets().length ); Assert.assertEquals( 1, workbook.getSheet( CREATED_SHEET_NAME ).getRows() );
public XLSWorkbook( String filename, String encoding ) throws KettleException { this.filename = filename; this.encoding = encoding; WorkbookSettings ws = new WorkbookSettings(); if ( !Utils.isEmpty( encoding ) ) { ws.setEncoding( encoding ); } try { workbook = Workbook.getWorkbook( KettleVFS.getInputStream( filename ), ws ); } catch ( Exception e ) { throw new KettleException( e ); } }
public KSheet getSheet( int sheetNr ) { Sheet sheet = workbook.getSheet( sheetNr ); if ( sheet == null ) { return null; } return new XLSSheet( sheet ); }