try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("VLookupFullColumn.xlsx")) {
FormulaEvaluator feval = wb.getCreationHelper().createFormulaEvaluator();
feval.evaluateAll();
- assertEquals("Value1", feval.evaluate(wb.getSheetAt(0).getRow(3).getCell(1)).getStringValue(),
- "Wrong lookup value");
+
+ Cell cell = wb.getSheetAt(0).getRow(3).getCell(1);
+ assertEquals("Value1", feval.evaluate(cell).getStringValue(),
+ "Wrong lookup value for cell " + cell);
assertEquals(CellType.ERROR, feval.evaluate(wb.getSheetAt(0).getRow(4).getCell(1)).getCellType(),
"Lookup should return #N/A");
}
targetPresentationSlide.importContent(sourceSlide);
XSLFSlide targetSlide = targetPresentation.getSlides().get(0);
+ assertNotNull(targetSlide);
assertEquals(2, targetPresentation.getPictureData().size());
targetPresentation.write(NullOutputStream.NULL_OUTPUT_STREAM);
try (XMLSlideShow slideShowModel = openSampleDocument("bug65673.pptx")) {
final XSLFSlide modelSlide = slideShowModel.getSlides().get(0);
try (XMLSlideShow newSlideShow = new XMLSlideShow()) {
- newSlideShow.createSlide().importContent(modelSlide);
+ XSLFSlide slide = newSlideShow.createSlide().importContent(modelSlide);
+ assertNotNull(slide);
}
}
}
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.Arrays;
private static Ptg[] parse(FormulaParsingWorkbook fpb, String fmla) {
return FormulaParser.parse(fmla, fpb, FormulaType.CELL, -1);
}
+
private static Ptg[] parse(FormulaParsingWorkbook fpb, String fmla, int rowIndex) {
return FormulaParser.parse(fmla, fpb, FormulaType.CELL, -1, rowIndex);
}
Sheet sheet = wb.getSheet("my-sheet");
Cell cell = sheet.getRow(1).getCell(4);
+ assertEquals(CellType.FORMULA, cell.getCellType(),
+ "Had: " + cell);
+ assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType(),
+ "Had: " + cell + " and " + cell.getCachedFormulaResultType());
+
assertEquals(5d, cell.getNumericCellValue(), 0d);
wb.close();
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.TempFile;
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
- final String column = testValue;
-
// Set the values for the table
- XSSFRow row;
- XSSFCell cell;
for (int i = 0; i < 3; i++) {
// Create row
- row = sheet.createRow(i);
+ Row row = sheet.createRow(i);
for (int j = 0; j < 3; j++) {
// Create cell
- cell = row.createCell(j);
+ Cell cell = row.createCell(j);
if (i == 0) {
- final String columnName = column + (j + 1);
+ final String columnName = testValue + (j + 1);
cell.setCellValue(columnName);
} else {
if (j != 2) {
table.setName("Table1");
table.setDisplayName("Table1");
for (int i = 1; i < 3; i++) {
- cell = sheet.getRow(i).getCell(2);
- cell.setCellFormula("Table1[[#This Row],[" + column + "1]]");
+ Cell cell = sheet.getRow(i).getCell(2);
+ assertNotNull(cell);
+ cell.setCellFormula("Table1[[#This Row],[" + testValue + "1]]");
}
}
}
import org.apache.poi.sl.usermodel.PlaceholderDetails;
import org.apache.poi.util.LocaleUtil;
import org.junit.jupiter.api.Test;
-import org.opentest4j.AssertionFailedError;
/**
* Tests for TextRuns
shape2.setText("Text 2");
slide.addShape(shape2);
- runs = slide.getTextParagraphs();
assertEquals(2, runs.size());
assertSame(run1, runs.get(0));
assertTrue(runs.stream().map(HSLFTextRun::getFontFamily).allMatch("Arial"::equals));
int[] exp = {36, 24, 12, 32, 12, 12};
+ //noinspection ConstantConditions
int[] act = runs.stream().map(HSLFTextRun::getFontSize).mapToInt(Double::intValue).toArray();
assertArrayEquals(exp, act);
}
for (Map.Entry<Locale,String[]> me : formats.entrySet()) {
LocaleUtil.setUserLocale(me.getKey());
- try {
- // refresh internal members
- phs.forEach(PlaceholderDetails::getPlaceholder);
+ // refresh internal members
+ phs.forEach(PlaceholderDetails::getPlaceholder);
- String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new);
- assertArrayEquals(me.getValue(), actDate);
- } catch (AssertionFailedError e) {
- throw new AssertionFailedError("While handling local " + me.getKey());
- }
+ String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new);
+ assertArrayEquals(me.getValue(), actDate,
+ "While handling local " + me.getKey());
}
} finally {
LocaleUtil.resetUserLocale();