ExcelFunctions { public static String getCell(String workbookPath, String sheetName, String cellIndex) { ExcelFileLookup excelFileLookup = new ExcelFileLookup(null); File workBookFile = excelFileLookup.lookup(workbookPath); return getCell(workBookFile, sheetName, cellIndex); }  static String getCell(String workbookPath, String sheetName, String cellIndex); static String getCell(File workBookFile, String sheetName, String cellIndex); static void putCell(String workbookPath, String sheetName, String cellIndex, String cellValue, String style); static String getCellValueAsString(Cell cell, FormulaEvaluator evaluator); static int getMaxExcelSize(); static void setConfiguration(Configuration configuration);  }
@Test public void testRead() { Assert.assertEquals("Values",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "Foglio1", "A::1")); }
@Test public void testCellTypes() { Assert.assertEquals("01.01.2016",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B1")); Assert.assertEquals("12:00:00",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B2")); Assert.assertEquals("100",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B3")); Assert.assertEquals("100.1",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B4")); Assert.assertEquals(Boolean.toString(true),ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B5")); Assert.assertEquals("String with\nnew line",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B6")); Assert.assertEquals("0.22",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B7")); Assert.assertEquals("0.016",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B8")); Assert.assertEquals("0.01677777777777",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B9")); Assert.assertEquals("0.01677777777778",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "CellTypes", "B10")); }
@Test public void testErrors() { assertException(()->ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "Errors", "B1"), "Error while evaluating cell B1 from sheet Errors:"); assertException(()->ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "Errors", "B2"), "Error while evaluating cell B2 from sheet Errors:"); }
@Test public void testDates() { Assert.assertEquals("01.01.2000",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "Dates", "A1")); Assert.assertEquals("12:02:00",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "Dates", "A2")); }
@Test public void testTEXT() { Assert.assertEquals("01.01.2016",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "TEXT", "B1")); Assert.assertEquals("01/01/2016",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "TEXT", "B2")); Assert.assertEquals("2016-01-01",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "TEXT", "B3")); Assert.assertEquals("20160101",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "TEXT", "B4")); Assert.assertEquals("01/01/2016",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "TEXT", "B5")); Assert.assertEquals("8 Februar 2016",ExcelFunctions.getCell(getResourceFile("Excel1.xlsx"), "TEXT", "B6")); }