if(_sh.getPhysicalNumberOfRows() > 0 && rownum <= _sh.getLastRowNum() ) { throw new IllegalArgumentException( "Attempting to write a row["+rownum+"] " +
/** * Construct a XSSFRow. * * @param row the xml bean containing all cell definitions for this row. * @param sheet the parent sheet. */ protected XSSFRow(CTRow row, XSSFSheet sheet) { _row = row; _sheet = sheet; _cells = new TreeMap<>(); for (CTCell c : row.getCArray()) { XSSFCell cell = new XSSFCell(this, c); // Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory final Integer colI = Integer.valueOf(cell.getColumnIndex()); // NOSONAR _cells.put(colI, cell); sheet.onReadCell(cell); } if (! row.isSetR()) { // Certain file format writers skip the row number // Assume no gaps, and give this the next row number int nextRowNum = sheet.getLastRowNum()+2; if (nextRowNum == 2 && sheet.getPhysicalNumberOfRows() == 0) { nextRowNum = 1; } row.setR(nextRowNum); } }
try { System.out.println("destDir==> "+destDir); XSSFWorkbook workBook = new XSSFWorkbook(destDir); XSSFSheet sheet = workBook.getSheetAt(0); totalRows = sheet.getPhysicalNumberOfRows(); System.out.println("total no of rows >>>>"+totalRows); } catch (IOException e) { e.printStackTrace(); }
private int buildMaxColumn(XSSFSheet sheet){ int rowCount=sheet.getPhysicalNumberOfRows(); int maxColumnCount=0; for(int i=0;i<rowCount;i++){ XSSFRow row=sheet.getRow(i); if(row==null){ continue; } int columnCount=row.getPhysicalNumberOfCells(); if(columnCount>maxColumnCount){ maxColumnCount=columnCount; } } return maxColumnCount; }
// TODO Auto-generated method stub XmlSuite suite = new XmlSuite(); suite.setName("TmpSuite"); XmlTest test = new XmlTest(suite); test.setName("TmpTest"); List<XmlClass> classes = new ArrayList<XmlClass>(); List<XmlSuite> suites = new ArrayList<XmlSuite>(); FileInputStream file=new FileInputStream(new File("D:\\TestCases.xlsx")); XSSFWorkbook workbook=new XSSFWorkbook(file); XSSFSheet sheet=workbook.getSheetAt(0); for(int i=1; i<sheet.getPhysicalNumberOfRows(); i++){ if(sheet.getRow(i).getCell(1).getStringCellValue().equals("Y")){ classes.add(new XmlClass(sheet.getRow(i).getCell(0).getStringCellValue())); } } test.setXmlClasses(classes) ; suites.add(suite); TestNG tng = new TestNG(); tng.setXmlSuites(suites); tng.run();
if(_sh.getPhysicalNumberOfRows() > 0 && rownum <= _sh.getLastRowNum() ) { throw new IllegalArgumentException( "Attempting to write a row["+rownum+"] " +
//data sheet XSSFSheet data = wb.getSheet("DATA SHEET"); // sheet you want pivot table in XSSFSheet sheet = wb.createSheet("PIVOT SHEET"); CellReference cr = new CellReference("A1"); CellReference c1 = new CellReference(0, 0); CellReference c2 = new CellReference(data.getPhysicalNumberOfRows() - 1, data.getRow(0).getLastCellNum() - 1); //source data AreaReference ar = new AreaReference(c1, c2); XSSFPivotTable pivotTable = sheet.createPivotTable(ar, cr, data); //add row labels and other stuff to pivot table pivotTable.addRowLabel(10); pivotTable.addRowLabel(11); pivotTable.addRowLabel(1); pivotTable.addColumnLabel(DataConsolidateFunction.COUNT, 0);
/** * Construct a XSSFRow. * * @param row the xml bean containing all cell definitions for this row. * @param sheet the parent sheet. */ protected XSSFRow(CTRow row, XSSFSheet sheet) { _row = row; _sheet = sheet; _cells = new TreeMap<>(); for (CTCell c : row.getCArray()) { XSSFCell cell = new XSSFCell(this, c); // Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory final Integer colI = Integer.valueOf(cell.getColumnIndex()); // NOSONAR _cells.put(colI, cell); sheet.onReadCell(cell); } if (! row.isSetR()) { // Certain file format writers skip the row number // Assume no gaps, and give this the next row number int nextRowNum = sheet.getLastRowNum()+2; if (nextRowNum == 2 && sheet.getPhysicalNumberOfRows() == 0) { nextRowNum = 1; } row.setR(nextRowNum); } }
int newRowIndex = sheet.getPhysicalNumberOfRows(); XSSFRow newRow = sheet.createRow(newRowIndex);
int totalNumberOfNames = sheet.getPhysicalNumberOfRows() - 1; // removes the header row nameUploadedEvent.setTotalNumberOfNames(totalNumberOfNames); nameUploadedEvent.isUploading(true);
XSSFWorkbook wookbook = new XSSFWorkbook(new FileInputStream(filePath)); XSSFSheet sheet = wookbook.getSheet("Sheet1"); int rows = sheet.getPhysicalNumberOfRows();
public void onReadClick(View view) { printlnToUser("reading XLSX file from resources"); InputStream stream = getResources().openRawResource(R.raw.test1); try { XSSFWorkbook workbook = new XSSFWorkbook(stream); XSSFSheet sheet = workbook.getSheetAt(0); int rowsCount = sheet.getPhysicalNumberOfRows(); FormulaEvaluator formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator(); for (int r = 0; r<rowsCount; r++) { Row row = sheet.getRow(r); int cellsCount = row.getPhysicalNumberOfCells(); for (int c = 0; c<cellsCount; c++) { String value = getCellAsString(row, c, formulaEvaluator); String cellInfo = "r:"+r+"; c:"+c+"; v:"+value; printlnToUser(cellInfo); } } } catch (Exception e) { /* proper exception handling to be here */ printlnToUser(e.toString()); } }
int rows = sheet.getPhysicalNumberOfRows();
XSSFSheet sheet=book.getSheetAt(0); int firstRow=0; int rowCount=sheet.getPhysicalNumberOfRows(); int maxColumnCount=buildMaxColumn(sheet); for(int i=firstRow;i<rowCount;i++){
XSSFSheet pivot = (XSSFSheet) wb.createSheet("summary"); for(String[] dataRow : data){ XSSFRow row = sheet.createRow(sheet.getPhysicalNumberOfRows()); for(String dataCell : dataRow){ XSSFCell cell = row.createCell(row.getPhysicalNumberOfCells());