package org.apache.poi.xssf.usermodel;
+import java.io.InputStream;
import java.io.PrintStream;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.formula.eval.TestFormulasFromSpreadsheet;
import org.apache.poi.hssf.record.formula.functions.TestMathX;
import org.apache.poi.ss.usermodel.Cell;
throw new AssertionFailedError(msg + " - actual value was null");
}
- if (expected.getCellType() == Cell.CELL_TYPE_STRING) {
- String value = expected.getRichStringCellValue().getString();
- if (value.startsWith("#")) {
- // TODO - this code never called
- expected.setCellType(Cell.CELL_TYPE_ERROR);
- // expected.setCellErrorValue(...?);
- }
- }
-
switch (expected.getCellType()) {
case Cell.CELL_TYPE_BLANK:
assertEquals(msg, Cell.CELL_TYPE_BLANK, actual.getCellType());
break;
case Cell.CELL_TYPE_STRING:
assertEquals(msg, Cell.CELL_TYPE_STRING, actual.getCellType());
- assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getRichTextStringValue().getString());
+ assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getStringValue());
break;
}
}
protected void setUp() throws Exception {
if (workbook == null) {
- String filePath = System.getProperty("HSSF.testdata.path")+ "/" + SS.FILENAME;
- Package pkg = Package.open(filePath);
+ InputStream is = HSSFTestDataSamples.openSampleFileStream(SS.FILENAME);
+ Package pkg = Package.open(is);
workbook = new XSSFWorkbook( pkg );
sheet = workbook.getSheetAt( 0 );
}
*/
private void processFunctionGroup(int startRowIndex, String testFocusFunctionName) {
- FormulaEvaluator evaluator = new FormulaEvaluator(sheet, workbook);
+ FormulaEvaluator evaluator = new FormulaEvaluator(workbook);
int rowIndex = startRowIndex;
while (true) {
int result = Result.NO_EVALUATIONS_FOUND; // so far
short endcolnum = formulasRow.getLastCellNum();
- evaluator.setCurrentRow(formulasRow);
// iterate across the row for all the evaluation cases
for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
for(int i=startIx; i<endIx; i++) {
ps.println("\tat " + stes[i].toString());
}
-
}
/**
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
-public class TestColumnHelper extends TestCase {
+/**
+ * Tests for {@link ColumnHelper}
+ *
+ */
+public final class TestColumnHelper extends TestCase {
public void testCleanColumns() {
CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
col9.setMax(27);
helper.addCleanColIntoCols(cols1, col9);
- System.err.println(cols1);
+ if (false) {
+ System.err.println(cols1);
+ }
+ // TODO - assert something interesting
+ CTCol[] colArray = cols1.getColArray();
+ assertEquals(12, colArray.length);
+ assertEquals(1, colArray[0].getMin());
+ assertEquals(16750, colArray[11].getMax());
}
public void testGetColumn() {
public void testGetOrCreateColumn() {
XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+ XSSFSheet sheet = workbook.createSheet("Sheet 1");
ColumnHelper columnHelper = sheet.getColumnHelper();
// Check POI 0 based, OOXML 1 based
}
public void testGetSetColDefaultStyle() {
- XSSFWorkbook workbook = new XSSFWorkbook();
- CTSheet ctSheet = CTSheet.Factory.newInstance();
- CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
- XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ CTSheet ctSheet = CTSheet.Factory.newInstance();
+ CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
+ XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook);
ColumnHelper columnHelper = sheet.getColumnHelper();
// POI column 3, OOXML column 4
assertEquals(1, columnHelper.getColDefaultStyle(10));
}
- private int countColumns(CTWorksheet worksheet) {
+ private static int countColumns(CTWorksheet worksheet) {
int count;
count = 0;
for (int i = 0; i < worksheet.sizeOfColsArray(); i++) {
}
return count;
}
-
}