List of usage examples for org.apache.poi.ss.usermodel Cell getRowIndex
int getRowIndex();
From source file:ExcelConverter.java
public List<ScheduleClass> Converter() throws FileNotFoundException, IOException { ArrayList<ScheduleClass> scheduleList = new ArrayList<>(); FileInputStream fis = new FileInputStream(pathFile); XSSFWorkbook wb = new XSSFWorkbook(fis); XSSFSheet sheet = wb.getSheetAt(0);/*from w w w. j av a2 s . c o m*/ Iterator<Row> rowIterator = sheet.iterator(); CellRangeAddress add; int colNoIdx = 0; ArrayList<String> dosen = new ArrayList<>(); ArrayList<Integer> idxDosen = new ArrayList<>(); ArrayList<Integer> colDosen = new ArrayList<>(); ArrayList<String> location = new ArrayList<>(); int idxNumber = 0; ArrayList<Integer> locationIdx = new ArrayList<>(); outerloop: for (int j = 0; j < sheet.getLastRowNum(); j++) { row = sheet.getRow(j); for (int f = 0; f < row.getLastCellNum(); f++) { Cell cell = row.getCell(j); if (cell.getStringCellValue().contains("No.")) { rowNoIdx = j; colNoIdx = cell.getColumnIndex(); break outerloop; } } } outerloop2: for (int i = 0; i < sheet.getLastRowNum(); i++) { row = sheet.getRow(i); outerloop: for (int j = 0; j < row.getLastCellNum(); j++) { Cell cell = row.getCell(j); FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); if (cell.getColumnIndex() == colNoIdx && i > rowNoIdx + 3 && evaluator.evaluate(cell).getCellType() != Cell.CELL_TYPE_NUMERIC) { i = sheet.getLastRowNum(); break outerloop2; } if (cell.getRowIndex() > rowNoIdx + 1 && cell.getColumnIndex() == (colNoIdx + 1)) { String delims = "[,. ]"; String[] sumary = cell.getStringCellValue().split(delims); for (int l = 0; l < sumary.length; l++) { if (sumary[l].equalsIgnoreCase("Mrt")) { sumary[l] = "3"; } } lc = LocalDate.of(Integer.parseInt(sumary[5]), Integer.parseInt(sumary[3]), Integer.parseInt(sumary[2])); } if (cell.getRowIndex() > rowNoIdx + 1 && cell.getColumnIndex() == (colNoIdx + 2)) { if (cell.getStringCellValue().equalsIgnoreCase("LIBUR")) { i = i + 1; break outerloop; } else { String delimsJam = "[-]"; String[] arrJam = cell.getStringCellValue().split(delimsJam); for (int k = 0; k < arrJam.length; k++) { arrJam[k] = arrJam[k].replace('.', ':'); } lt = LocalTime.parse(arrJam[0]); } } if (cell.getRowIndex() > rowNoIdx + 1 && cell.getColumnIndex() == (colNoIdx + 5)) { subject = cell.getStringCellValue(); } if (cell.getRowIndex() > rowNoIdx && cell.getColumnIndex() >= colNoIdx + 6 && cell.getColumnIndex() < row.getLastCellNum()) { if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { } if (cell.getCellType() == Cell.CELL_TYPE_STRING) { if (cell.getStringCellValue().contains(":")) { String[] splt = cell.getStringCellValue().split(":"); String[] splt2 = splt[1].split(","); for (int l = 0; l < splt2.length; l++) { dosen.add(splt2[l].trim()); location.add("Lab"); } } else { CellReference cr = new CellReference(1, cell.getColumnIndex()); Row row2 = sheet.getRow(cr.getRow()); Cell c = row2.getCell(cr.getCol()); if (!cell.getStringCellValue().isEmpty()) { dosen.add(cell.getStringCellValue().trim()); location.add(String.valueOf((int) c.getNumericCellValue()).trim()); } } } if (cell.getCellType() == Cell.CELL_TYPE_BLANK && cell.getRowIndex() > 2) { CellReference cr = new CellReference(cell.getRowIndex() - 1, cell.getColumnIndex()); Row row2 = sheet.getRow(cr.getRow()); Cell c = row2.getCell(cr.getCol()); CellReference cr2 = new CellReference(1, cell.getColumnIndex()); Row row3 = sheet.getRow(cr2.getRow()); Cell c2 = row3.getCell(cr2.getCol()); if (c.getStringCellValue().contains(":")) { String[] splt = c.getStringCellValue().split(":"); String[] splt2 = splt[1].split(","); for (int l = 0; l < splt2.length; l++) { dosen.add("".trim()); location.add(""); } } else { if (!c.getStringCellValue().isEmpty()) { dosen.add(""); location.add(""); } } } } } for (int j = 0; j < dosen.size(); j++) { scheduleList .add(new ScheduleClass(lc, lt, lt.plusHours(2), subject, dosen.get(j), location.get(j))); } dosen.clear(); location.clear(); } return Mergering(scheduleList); }
From source file:ExampleClass.java
public static void main(String[] args) throws Exception { File src = new File( "C:\\Users\\Ariq\\Documents\\NetBeansProjects\\Skripsi-Jadwal-Mengawas-Ujian\\Contoh File\\Jadwal_Pengawas_ Ujian_Pak_ Pascal.xlsx"); //File src = new File("D:\\\\Skripsi\\\\Data Baru\\\\Daftar Dosen.xlsx"); FileInputStream fis = new FileInputStream(src); XSSFWorkbook wb = new XSSFWorkbook(fis); XSSFSheet sheet1 = wb.getSheetAt(0); // Iterator< Row> rowIterator = sheet1.iterator(); int colIndex = 0; int ex = 0;/*w w w . j a v a2 s . c om*/ int lastCol = sheet1.getLastRowNum(); int i = 0; int idx = 0; CellRangeAddress add; // while (rowIterator.hasNext()) { // row = (XSSFRow) rowIterator.next(); // Iterator< Cell> cellIterator = row.cellIterator(); // //System.out.println("i = "+i+", ex:"+ex); // // if (row.getRowNum() > 53) { // break; // } //// if(lastCol-(ex+1) == i) break; // while (cellIterator.hasNext()) { // Cell cell = cellIterator.next(); // for (int f = 0; f < sheet1.getNumMergedRegions(); f++) { // add = sheet1.getMergedRegion(f); // // int col = add.getFirstColumn(); // int rowNum = add.getFirstRow(); // if (rowNum != 0 && rowNum == cell.getRowIndex() && colIndex == cell.getColumnIndex()) { // System.out.println("col:"+col+" "+",row :"+rowNum); // String b = String.valueOf(sheet1.getRow(rowNum).getCell(col)); // System.out.println(b); // // } // // } // switch (cell.getCellType()) // { // case Cell.CELL_TYPE_FORMULA: // ex++; // switch (cell.getCachedFormulaResultType()) // { // case Cell.CELL_TYPE_NUMERIC: // i = (int)cell.getNumericCellValue(); // System.out.print( // (int)cell.getNumericCellValue() + " \t\t " ); // // // break; // } // break; // case Cell.CELL_TYPE_NUMERIC: // if (cell.getColumnIndex() >= 6) // { // System.out.print( // (int)cell.getNumericCellValue() + " \t\t " ); // } // break; // case Cell.CELL_TYPE_STRING: // add = sheet1.getMergedRegion(cell.getRowIndex()); // // if (cell.getStringCellValue().contentEquals("No.")) // { // colIndex = cell.getColumnIndex(); // } // if (cell.getColumnIndex() == 1) // { // System.out.print( // cell.getStringCellValue() + " \t\t " ); // } // break; // // } // } // // System.out.println(); // } for (int j = 0; j < sheet1.getLastRowNum(); j++) { row = sheet1.getRow(j); for (int k = 0; k < row.getLastCellNum(); k++) { Cell cell = row.getCell(k); // if (cell.getColumnIndex() == 1) // { // System.out.println(cell.getStringCellValue()); // } FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); if (cell.getColumnIndex() == 0 && j > 3 && evaluator.evaluate(cell).getCellType() != Cell.CELL_TYPE_NUMERIC) { System.exit(k); } if (cell.getColumnIndex() >= 6 && cell.getColumnIndex() <= 11) { if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { System.out.print((int) cell.getNumericCellValue() + " "); } if (cell.getCellType() == Cell.CELL_TYPE_STRING) { if (cell.getStringCellValue().contains(":")) { String[] splt = cell.getStringCellValue().split(":"); String[] splt2 = splt[1].split(","); for (int l = 0; l < splt2.length; l++) { System.out.println(splt2[l] + "= lab"); } } else { CellReference cr = new CellReference(1, cell.getColumnIndex()); Row row2 = sheet1.getRow(cr.getRow()); Cell c = row2.getCell(cr.getCol()); System.out.print( cell.getStringCellValue() + " Ruang =" + (int) c.getNumericCellValue() + " "); } } if (cell.getCellType() == Cell.CELL_TYPE_BLANK && cell.getRowIndex() > 2) { CellReference cr = new CellReference(cell.getRowIndex() - 1, cell.getColumnIndex()); Row row2 = sheet1.getRow(cr.getRow()); Cell c = row2.getCell(cr.getCol()); CellReference cr2 = new CellReference(1, cell.getColumnIndex()); Row row3 = sheet1.getRow(cr2.getRow()); Cell c2 = row3.getCell(cr2.getCol()); if (c.getStringCellValue().contains(":")) { String[] splt = c.getStringCellValue().split(":"); String[] splt2 = splt[1].split(","); for (int l = 0; l < splt2.length; l++) { System.out.println(splt2[l] + "= lab"); } } else { System.out.print( c.getStringCellValue() + " Ruang = " + (int) c2.getNumericCellValue() + " "); } } } } System.out.println(""); } System.out.println(colIndex); System.out.println(idx); fis.close(); }
From source file:ADP_Streamline.MatrixReader.java
public String check() throws Exception { List<String> ClientRoles = new ArrayList<>(); List<String> PartnerRoles = new ArrayList<>(); List<String> ADPRoles = new ArrayList<>(); List<String> Rights = new ArrayList<>(); String rightscolumn = ""; String rights = ""; String roles = ""; String cellwithx;// w ww .ja va 2 s. c o m int righstrow = 0; int columncount; int rowcount; int roleslenght; int rightslenght = 0; Boolean client = false; Boolean partner = false; Boolean adp; Boolean rightstart = false; Iterator<Row> rowIterator; Iterator<Cell> cellIterator; Row row; Cell cell; OracleJDBC oracle = new OracleJDBC(); try { FileInputStream file = new FileInputStream( new File("C:\\Users\\frodri1\\Documents\\SPM 1.2_RoleMatrix_Demo.xlsx")); //Create Workbook instance holding reference to .xlsx file XSSFWorkbook workbook = new XSSFWorkbook(file); //Get first/desired sheet from the workbook XSSFSheet sheet = workbook.getSheetAt(0); //Iterate through each rows one by one rowIterator = sheet.iterator(); rowcount = 2; columncount = 0; while (rowIterator.hasNext()) { row = rowIterator.next(); //if(adp) {break;} adp = false; //For each row, iterate through all the columns cellIterator = row.cellIterator(); while (cellIterator.hasNext()) { cell = cellIterator.next(); if (cell.getStringCellValue().contentEquals("Right")) { rightscolumn = CellReference.convertNumToColString(cell.getColumnIndex()); righstrow = cell.getRowIndex(); rightstart = true; } if (cell.getStringCellValue().contentEquals("Client")) { client = true; } if (cell.getStringCellValue().contentEquals("Partner")) { partner = true; client = false; } if (cell.getStringCellValue().contentEquals("ADP")) { partner = false; client = false; adp = true; } if (client) { ClientRoles.add( CellIteration(sheet, CellReference.convertNumToColString(cell.getColumnIndex()), righstrow, columncount, 0).trim()); } if (partner) { PartnerRoles.add( CellIteration(sheet, CellReference.convertNumToColString(cell.getColumnIndex()), righstrow, columncount, 0).trim()); } if (adp) { ADPRoles.add( CellIteration(sheet, CellReference.convertNumToColString(cell.getColumnIndex()), righstrow, columncount, 0).trim()); } } if (rightstart) { rights = CellIteration(sheet, rightscolumn, righstrow, columncount, rowcount); if (!"".equals(rights)) { Rights.add(rights.trim()); rightslenght++; rowcount++; } else break; } } roleslenght = ClientRoles.size() + PartnerRoles.size() + ADPRoles.size(); for (int i = 0; i < rightslenght; i++) { for (int l = 0; l < roleslenght; l++) { cellwithx = CellIteration(sheet, rightscolumn, righstrow, l + 1, i + 2); if ("x".equals(cellwithx)) { if (l < ClientRoles.size()) { rights = Rights.get(i); roles = ClientRoles.get(l); oracle.check(rights, roles); } if (l >= ClientRoles.size() && l < (ClientRoles.size() + PartnerRoles.size())) { rights = Rights.get(i); roles = PartnerRoles.get(l - ClientRoles.size()); } if (l >= ClientRoles.size() + PartnerRoles.size()) { rights = Rights.get(i); roles = ADPRoles.get(l - (ClientRoles.size() + PartnerRoles.size())); } } } } } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:android_connector.ExcelReader.java
/** * Gibt eine vernnftige Darstellung einer Zelle als String zurck. * @param cell die Zelle/*w ww. jav a 2 s .c o m*/ * @return z.B. bei Zelle, die eine Gleichung enthlt, deren Ergebnis */ private String differCellType(Cell cell) { String returnValue = ""; switch (cell.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: returnValue = String.valueOf(cell.getBooleanCellValue()); break; case Cell.CELL_TYPE_NUMERIC: returnValue = String.valueOf(cell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: returnValue = cell.getStringCellValue(); break; case Cell.CELL_TYPE_FORMULA: FormulaEvaluator evaluator = this.wb.getCreationHelper().createFormulaEvaluator(); CellValue cellValue = evaluator.evaluate(cell); returnValue = cellValue.getStringValue(); break; case Cell.CELL_TYPE_ERROR: returnValue = String.valueOf(cell.getErrorCellValue()); break; case Cell.CELL_TYPE_BLANK: returnValue = ""; break; default: returnValue = "default value at (" + cell.getRowIndex() + ";" + cell.getColumnIndex() + ") !"; break; } return returnValue; }
From source file:annualleave.PersonelTara.java
static public void Detection(int ilk, int son, String URL) throws FileNotFoundException, IOException { char gun[] = new char[100]; int gunler[] = new int[32]; for (int j = ilk; j <= son; j++) { gunler[j] = j;//from www . j a va 2s.c o m } String oncekiAd; // C:\\Users\\talha\\Documents\\NetBeansProjects\\AnnualLeave\\src\\annualleave\\Mays 23.xlsx String excelFilePath = URL; FileInputStream inputStream = new FileInputStream(new File(excelFilePath)); Workbook workbook = new XSSFWorkbook(inputStream); Sheet firstSheet = workbook.getSheetAt(0); int sonuncuIndex = firstSheet.getLastRowNum(); Iterator<Row> iterator = firstSheet.iterator(); while (iterator.hasNext()) { Row nextRow = iterator.next(); Iterator<Cell> cellIterator = nextRow.cellIterator(); if (cellIterator.hasNext()) { Cell cell = cellIterator.next(); if (cell.getRowIndex() >= 6) { oncekiAd = ad; cell = cellIterator.next(); cell = cellIterator.next(); cell = cellIterator.next(); ad = cell.getStringCellValue(); cell = cellIterator.next(); cell = cellIterator.next(); tarih = cell.getStringCellValue(); if (ad != oncekiAd && i != 0 && !(oncekiAd.equals("Personel Ad Soyad")) && !(oncekiAd.isEmpty()) && !(ad.isEmpty()) && !(ad.equals("Personel Ad Soyad")) || cell.getRowIndex() == sonuncuIndex) { for (int j = ilk; j <= son; j++) { if (gunler[j] != 0) { GETIR[z] = oncekiAd + " " + gunler[j]; z++; test = 1; } if (isBuilt) { int left = tarih.indexOf("."); int right = tarih.lastIndexOf("."); String sub = tarih.substring(left + 1, right); ay = Integer.parseInt(sub); int left2 = tarih.lastIndexOf("."); int right2 = tarih.lastIndexOf(""); String sub2 = tarih.substring(left2 + 1, right2); yil = Integer.parseInt(sub2); } Build(); } if (test == 1) { yeniAd[c] = oncekiAd; for (int j = ilk; j <= son; j++) { if (gunler[j] != 0) { Calendar date = Calendar.getInstance(); date.set(yil, ay - 1, gunler[j]); if (date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || date.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { } else { yeniAd[c] += " " + gunler[j]; } } } c++; test = 0; } for (int j = ilk; j <= son; j++) { gunler[j] = j; } } if (!(cell.getStringCellValue().isEmpty()) && !(ad.equals("Personel Ad Soyad"))) { int left = tarih.indexOf(0); int right = tarih.indexOf("."); String sub = tarih.substring(left + 1, right); gunler[Integer.parseInt(sub)] = 0; i++; } } } } }
From source file:at.mukprojects.exclycore.dao.ExclyCoreReaderTest.java
License:Open Source License
/** * Tests the XLSXReader readStringCellValue function. *///from w w w .ja v a 2 s . c o m @Test public void testXLSXReaderString() throws Exception { log.debug("Start test for testXLSXReaderString."); int counter = 0; ReaderTestImpl reader = new ReaderTestImpl(); while (inputRowIterator.hasNext()) { Row inputRow = inputRowIterator.next(); Iterator<Cell> inputCellInterator = inputRow.cellIterator(); while (inputCellInterator.hasNext()) { Cell inputCell = inputCellInterator.next(); log.debug("RowIndex: " + inputCell.getRowIndex() + " - RowExcel: " + (inputCell.getRowIndex() + 1)); switch (counter) { case 0: log.debug("0 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("0", reader.readStringCellValue(inputCell).getData()); break; case 1: log.debug("1 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("1", reader.readStringCellValue(inputCell).getData()); break; case 2: log.debug("100 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("100", reader.readStringCellValue(inputCell).getData()); break; case 3: log.debug("MuK / " + reader.readStringCellValue(inputCell).getData()); assertEquals("MuK", reader.readStringCellValue(inputCell).getData()); break; case 4: log.debug("1.000,10 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("1.000,10", reader.readStringCellValue(inputCell).getData()); break; case 5: log.debug("2.000 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("2.000", reader.readStringCellValue(inputCell).getData()); break; case 6: log.debug("2 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("2", reader.readStringCellValue(inputCell).getData()); break; case 7: log.debug("1.9 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("1.9", reader.readStringCellValue(inputCell).getData()); break; case 8: log.debug("0,01 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("0,01", reader.readStringCellValue(inputCell).getData()); break; case 9: log.debug("ExclyStringError: ture / " + reader.readStringCellValue(inputCell).isError()); assertTrue("Should be an ExclyStringError.", reader.readStringCellValue(inputCell) instanceof ExclyStringError); break; case 10: log.debug("Tue Oct 20 00:00:00 CEST 2015 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("Tue Oct 20 00:00:00 CEST 2015", reader.readStringCellValue(inputCell).getData()); break; case 11: log.debug("10/10/2015 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("10/10/2015", reader.readStringCellValue(inputCell).getData()); break; case 12: log.debug("- / " + reader.readStringCellValue(inputCell).getData()); assertEquals("-", reader.readStringCellValue(inputCell).getData()); break; case 13: log.debug("42297 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("42297", reader.readStringCellValue(inputCell).getData()); break; case 14: log.debug("500 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("500", reader.readStringCellValue(inputCell).getData()); break; case 15: log.debug("#Text / " + reader.readStringCellValue(inputCell).getData()); assertEquals("#Text", reader.readStringCellValue(inputCell).getData()); break; case 16: log.debug("1,00.01 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("1,00.01", reader.readStringCellValue(inputCell).getData()); break; case 17: log.debug("WAHR / " + reader.readStringCellValue(inputCell).getData()); assertEquals("WAHR", reader.readStringCellValue(inputCell).getData()); break; case 18: log.debug(" / " + reader.readStringCellValue(inputCell).getData()); assertEquals(" ", reader.readStringCellValue(inputCell).getData()); break; case 19: log.debug("Sun Jan 03 00:00:00 CET 2016 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("Sun Jan 03 00:00:00 CET 2016", reader.readStringCellValue(inputCell).getData()); break; case 20: log.debug("20 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("20", reader.readStringCellValue(inputCell).getData()); break; case 21: log.debug("20 / " + reader.readStringCellValue(inputCell).getData()); assertEquals("20", reader.readStringCellValue(inputCell).getData()); break; case 22: log.debug("ABC / " + reader.readStringCellValue(inputCell).getData()); assertEquals("ABC", reader.readStringCellValue(inputCell).getData()); break; } counter++; } } }
From source file:at.mukprojects.exclycore.dao.ExclyCoreReaderTest.java
License:Open Source License
/** * Tests the XLSXReader readDoubleCellValue function. */// ww w . j a v a2 s . c o m @Test public void testXLSXReaderDouble() throws Exception { log.debug("Start test for testXLSXReaderDouble."); int counter = 0; ReaderTestImpl reader = new ReaderTestImpl(); while (inputRowIterator.hasNext()) { Row inputRow = inputRowIterator.next(); Iterator<Cell> inputCellInterator = inputRow.cellIterator(); while (inputCellInterator.hasNext()) { Cell inputCell = inputCellInterator.next(); log.debug("RowIndex: " + inputCell.getRowIndex() + " - RowExcel: " + (inputCell.getRowIndex() + 1)); switch (counter) { case 0: log.debug("0.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(0.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 1: log.debug("1.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(1.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 2: log.debug("100.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(100.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 3: log.debug("ExclyDoubleError: ture / " + reader.readDoubleCellValue(inputCell).isError()); assertTrue("Should be an ExclyDoubleError.", reader.readDoubleCellValue(inputCell) instanceof ExclyDoubleError); break; case 4: log.debug("1000.10 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(1000.10, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 5: log.debug("2000.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(2000.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 6: log.debug("2.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(2.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 7: log.debug("1.9 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(1.9, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 8: log.debug("0.01 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(0.01, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 9: log.debug("ExclyDoubleError: ture / " + reader.readDoubleCellValue(inputCell).isError()); assertTrue("Should be an ExclyDoubleError.", reader.readDoubleCellValue(inputCell) instanceof ExclyDoubleError); break; case 10: log.debug("42297.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(42297.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 11: log.debug("ExclyDoubleError: ture / " + reader.readDoubleCellValue(inputCell).isError()); assertTrue("Should be an ExclyDoubleError.", reader.readDoubleCellValue(inputCell) instanceof ExclyDoubleError); break; case 12: log.debug("ExclyDoubleError: false / " + reader.readDoubleCellValue(inputCell).isError()); assertTrue("Should be no ExclyDoubleError.", reader.readDoubleCellValue(inputCell) instanceof ExclyDoubleBlank); break; case 13: log.debug("42297.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(42297.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 14: log.debug("500.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(500.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 15: log.debug("ExclyDoubleError: ture / " + reader.readDoubleCellValue(inputCell).isError()); assertTrue("Should be an ExclyDoubleError.", reader.readDoubleCellValue(inputCell) instanceof ExclyDoubleError); break; case 16: log.debug("100.01 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(100.01, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 17: log.debug("1.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(1.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 18: log.debug("ExclyDoubleError: false / " + reader.readDoubleCellValue(inputCell).isError()); assertTrue("Should be no ExclyDoubleError.", reader.readDoubleCellValue(inputCell) instanceof ExclyDoubleBlank); break; case 19: log.debug("42372.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(42372.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 20: log.debug("20.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(20.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 21: log.debug("20.0 / " + reader.readDoubleCellValue(inputCell).getData()); assertEquals(20.0, reader.readDoubleCellValue(inputCell).getData(), 0.0001); break; case 22: log.debug("ExclyDoubleError: ture / " + reader.readDoubleCellValue(inputCell).getData()); assertTrue("Should be an ExclyDoubleError.", reader.readDoubleCellValue(inputCell) instanceof ExclyDoubleError); break; } counter++; } } }
From source file:at.mukprojects.exclycore.dao.ExclyCoreReaderTest.java
License:Open Source License
/** * Tests the XLSXReader readIntegerCellValue function. *//*from www . j a v a 2s .co m*/ @Test public void testXLSXReaderInteger() throws Exception { log.debug("Start test for testXLSXReaderInteger."); int counter = 0; ReaderTestImpl reader = new ReaderTestImpl(); while (inputRowIterator.hasNext()) { Row inputRow = inputRowIterator.next(); Iterator<Cell> inputCellInterator = inputRow.cellIterator(); while (inputCellInterator.hasNext()) { Cell inputCell = inputCellInterator.next(); log.debug("RowIndex: " + inputCell.getRowIndex() + " - RowExcel: " + (inputCell.getRowIndex() + 1)); switch (counter) { case 0: log.debug("0 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(0, reader.readIntegerCellValue(inputCell).getData()); break; case 1: log.debug("1 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(1, reader.readIntegerCellValue(inputCell).getData()); break; case 2: log.debug("100 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(100, reader.readIntegerCellValue(inputCell).getData()); break; case 3: log.debug("ExclyIntegerError: ture / " + reader.readIntegerCellValue(inputCell).isError()); assertTrue("Should be an ExclyIntegerError.", reader.readIntegerCellValue(inputCell) instanceof ExclyIntegerError); break; case 4: log.debug("1000 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(1000, reader.readIntegerCellValue(inputCell).getData()); break; case 5: log.debug("2000 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(2000, reader.readIntegerCellValue(inputCell).getData()); break; case 6: log.debug("2 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(2, reader.readIntegerCellValue(inputCell).getData()); break; case 7: log.debug("1 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(1, reader.readIntegerCellValue(inputCell).getData()); break; case 8: log.debug("0 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(0, reader.readIntegerCellValue(inputCell).getData()); break; case 9: log.debug("ExclyIntegerError: ture / " + reader.readIntegerCellValue(inputCell).isError()); assertTrue("Should be an ExclyIntegerError.", reader.readIntegerCellValue(inputCell) instanceof ExclyIntegerError); break; case 10: log.debug("42297 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(42297, reader.readIntegerCellValue(inputCell).getData()); break; case 11: log.debug("ExclyIntegerError: ture / " + reader.readIntegerCellValue(inputCell).isError()); assertTrue("Should be an ExclyIntegerError.", reader.readIntegerCellValue(inputCell) instanceof ExclyIntegerError); break; case 12: log.debug("ExclyIntegerError: false / " + reader.readIntegerCellValue(inputCell).isError()); assertTrue("Should be no ExclyIntegerError.", reader.readIntegerCellValue(inputCell) instanceof ExclyIntegerBlank); break; case 13: log.debug("42297 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(42297, reader.readIntegerCellValue(inputCell).getData()); break; case 14: log.debug("500 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(500, reader.readIntegerCellValue(inputCell).getData()); break; case 15: log.debug("ExclyIntegerError: ture / " + reader.readIntegerCellValue(inputCell).isError()); assertTrue("Should be an ExclyIntegerError.", reader.readIntegerCellValue(inputCell) instanceof ExclyIntegerError); break; case 16: log.debug("100 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(100, reader.readIntegerCellValue(inputCell).getData()); break; case 17: log.debug("1 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(1, reader.readIntegerCellValue(inputCell).getData()); break; case 18: log.debug("ExclyIntegerError: false / " + reader.readIntegerCellValue(inputCell).isError()); assertTrue("Should be no ExclyIntegerError.", reader.readIntegerCellValue(inputCell) instanceof ExclyIntegerBlank); break; case 19: log.debug("42372 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(42372, reader.readIntegerCellValue(inputCell).getData()); break; case 20: log.debug("20 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(20, reader.readIntegerCellValue(inputCell).getData()); break; case 21: log.debug("20 / " + reader.readIntegerCellValue(inputCell).getData()); assertEquals(20, reader.readIntegerCellValue(inputCell).getData()); break; case 22: log.debug("ExclyIntegerError: ture / " + reader.readIntegerCellValue(inputCell).getData()); assertTrue("Should be an ExclyIntegerError.", reader.readIntegerCellValue(inputCell) instanceof ExclyIntegerError); break; } counter++; } } }
From source file:at.mukprojects.exclycore.dao.ExclyCoreReaderTest.java
License:Open Source License
/** * Tests the XLSXReader readLongCellValue function. *//*from ww w . ja va 2 s . co m*/ @Test public void testXLSXReaderLong() throws Exception { log.debug("Start test for testXLSXReaderLong."); int counter = 0; ReaderTestImpl reader = new ReaderTestImpl(); while (inputRowIterator.hasNext()) { Row inputRow = inputRowIterator.next(); Iterator<Cell> inputCellInterator = inputRow.cellIterator(); while (inputCellInterator.hasNext()) { Cell inputCell = inputCellInterator.next(); log.debug("RowIndex: " + inputCell.getRowIndex() + " - RowExcel: " + (inputCell.getRowIndex() + 1)); switch (counter) { case 0: log.debug("0 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(0L, reader.readLongCellValue(inputCell).getData()); break; case 1: log.debug("1 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(1L, reader.readLongCellValue(inputCell).getData()); break; case 2: log.debug("100 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(100L, reader.readLongCellValue(inputCell).getData()); break; case 3: log.debug("ExclyLongError: ture / " + reader.readLongCellValue(inputCell).isError()); assertTrue("Should be an ExclyLongError.", reader.readLongCellValue(inputCell) instanceof ExclyLongError); break; case 4: log.debug("1000 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(1000L, reader.readLongCellValue(inputCell).getData()); break; case 5: log.debug("2000 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(2000L, reader.readLongCellValue(inputCell).getData()); break; case 6: log.debug("2 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(2L, reader.readLongCellValue(inputCell).getData()); break; case 7: log.debug("1 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(1L, reader.readLongCellValue(inputCell).getData()); break; case 8: log.debug("0 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(0L, reader.readLongCellValue(inputCell).getData()); break; case 9: log.debug("ExclyLongError: ture / " + reader.readLongCellValue(inputCell).isError()); assertTrue("Should be an ExclyLongError.", reader.readLongCellValue(inputCell) instanceof ExclyLongError); break; case 10: log.debug("42297 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(42297L, reader.readLongCellValue(inputCell).getData()); break; case 11: log.debug("ExclyLongError: ture / " + reader.readLongCellValue(inputCell).isError()); assertTrue("Should be an ExclyLongError.", reader.readLongCellValue(inputCell) instanceof ExclyLongError); break; case 12: log.debug("ExclyLongError: false / " + reader.readLongCellValue(inputCell).isError()); assertTrue("Should be no ExclyLongError.", reader.readLongCellValue(inputCell) instanceof ExclyLongBlank); break; case 13: log.debug("42297 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(42297L, reader.readLongCellValue(inputCell).getData()); break; case 14: log.debug("500 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(500L, reader.readLongCellValue(inputCell).getData()); break; case 15: log.debug("ExclyLongError: ture / " + reader.readLongCellValue(inputCell).isError()); assertTrue("Should be an ExclyLongError.", reader.readLongCellValue(inputCell) instanceof ExclyLongError); break; case 16: log.debug("100 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(100L, reader.readLongCellValue(inputCell).getData()); break; case 17: log.debug("1 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(1L, reader.readLongCellValue(inputCell).getData()); break; case 18: log.debug("ExclyLongError: false / " + reader.readLongCellValue(inputCell).isError()); assertTrue("Should be no ExclyLongError.", reader.readLongCellValue(inputCell) instanceof ExclyLongBlank); break; case 19: log.debug("42372 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(42372, reader.readLongCellValue(inputCell).getData()); break; case 20: log.debug("20 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(20, reader.readLongCellValue(inputCell).getData()); break; case 21: log.debug("20 / " + reader.readLongCellValue(inputCell).getData()); assertEquals(20, reader.readLongCellValue(inputCell).getData()); break; case 22: log.debug("ExclyLongError: ture / " + reader.readLongCellValue(inputCell).getData()); assertTrue("Should be an ExclyLongError.", reader.readLongCellValue(inputCell) instanceof ExclyLongError); break; } counter++; } } }
From source file:at.mukprojects.exclycore.dao.ExclyCoreReaderTest.java
License:Open Source License
/** * Tests the XLSXReader readDateCellValue function. */// w ww . java2s . c om @Test public void testXLSXReaderDate() throws Exception { log.debug("Start test for testXLSXReaderDate."); int counter = 0; ReaderTestImpl reader = new ReaderTestImpl(); while (inputRowIterator.hasNext()) { Row inputRow = inputRowIterator.next(); Iterator<Cell> inputCellInterator = inputRow.cellIterator(); while (inputCellInterator.hasNext()) { Cell inputCell = inputCellInterator.next(); log.debug("RowIndex: " + inputCell.getRowIndex() + " - RowExcel: " + (inputCell.getRowIndex() + 1)); switch (counter) { case 3: log.debug("true / " + reader.readDateCellValue(inputCell).isError()); assertTrue("Should be an ExclyDateError.", reader.readDateCellValue(inputCell) instanceof ExclyDateError); break; case 10: log.debug("Tue Oct 20 00:00:00 CEST 2015 / " + reader.readDateCellValue(inputCell).getData().toString()); assertTrue("Tue Oct 20 00:00:00 CEST 2015" .equals(reader.readDateCellValue(inputCell).getData().toString())); break; case 11: log.debug("Tue Oct 20 00:00:00 CEST 2015 / " + reader.readDateCellValue(inputCell).getData().toString()); assertTrue("Sat Oct 10 00:00:00 CEST 2015" .equals(reader.readDateCellValue(inputCell).getData().toString())); break; case 13: log.debug("Tue Oct 20 00:00:00 CEST 2015 / " + reader.readDateCellValue(inputCell).getData().toString()); assertTrue("Tue Oct 20 00:00:00 CEST 2015" .equals(reader.readDateCellValue(inputCell).getData().toString())); break; case 19: log.debug("Sun Jan 03 00:00:00 CET 2016 / " + reader.readDateCellValue(inputCell).getData().toString()); assertEquals("Sun Jan 03 00:00:00 CET 2016", reader.readDateCellValue(inputCell).getData().toString()); break; } counter++; } } }