use non-deprecated versions of getCellType
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808741 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e0ee55e75f
commit
51305b6260
@ -144,7 +144,7 @@ public class SVSheetTable extends JTable {
|
|||||||
HSSFCell cell = (HSSFCell) getValueAt(row, col);
|
HSSFCell cell = (HSSFCell) getValueAt(row, col);
|
||||||
String formula = "";
|
String formula = "";
|
||||||
if (cell != null) {
|
if (cell != null) {
|
||||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
if (cell.getCellType() == CellType.FORMULA) {
|
||||||
formula = cell.getCellFormula();
|
formula = cell.getCellFormula();
|
||||||
} else {
|
} else {
|
||||||
formula = cell.toString();
|
formula = cell.toString();
|
||||||
|
@ -166,7 +166,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
|
|||||||
|
|
||||||
|
|
||||||
//Set the value that is rendered for the cell
|
//Set the value that is rendered for the cell
|
||||||
switch (cell.getCellTypeEnum()) {
|
switch (cell.getCellType()) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
editor.setText("");
|
editor.setText("");
|
||||||
break;
|
break;
|
||||||
|
@ -168,7 +168,7 @@ public class SVTableCellRenderer extends JLabel
|
|||||||
isBorderSet=true;
|
isBorderSet=true;
|
||||||
|
|
||||||
//Set the value that is rendered for the cell
|
//Set the value that is rendered for the cell
|
||||||
switch (c.getCellTypeEnum()) {
|
switch (c.getCellType()) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
setValue("");
|
setValue("");
|
||||||
break;
|
break;
|
||||||
|
@ -544,7 +544,7 @@ public class ToCSV {
|
|||||||
csvLine.add("");
|
csvLine.add("");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(cell.getCellTypeEnum() != CellType.FORMULA) {
|
if(cell.getCellType() != CellType.FORMULA) {
|
||||||
csvLine.add(this.formatter.formatCellValue(cell));
|
csvLine.add(this.formatter.formatCellValue(cell));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -102,7 +102,7 @@ public class HSSFHyperlink implements Hyperlink {
|
|||||||
link_type = getType(record);
|
link_type = getType(record);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
link_type = other.getTypeEnum();
|
link_type = other.getType();
|
||||||
record = new HyperlinkRecord();
|
record = new HyperlinkRecord();
|
||||||
setFirstRow(other.getFirstRow());
|
setFirstRow(other.getFirstRow());
|
||||||
setFirstColumn(other.getFirstColumn());
|
setFirstColumn(other.getFirstColumn());
|
||||||
|
@ -62,7 +62,7 @@ final class SheetRefEvaluator {
|
|||||||
public boolean isSubTotal(int rowIndex, int columnIndex){
|
public boolean isSubTotal(int rowIndex, int columnIndex){
|
||||||
boolean subtotal = false;
|
boolean subtotal = false;
|
||||||
EvaluationCell cell = getSheet().getCell(rowIndex, columnIndex);
|
EvaluationCell cell = getSheet().getCell(rowIndex, columnIndex);
|
||||||
if(cell != null && cell.getCellTypeEnum() == CellType.FORMULA){
|
if(cell != null && cell.getCellType() == CellType.FORMULA){
|
||||||
EvaluationWorkbook wb = _bookEvaluator.getWorkbook();
|
EvaluationWorkbook wb = _bookEvaluator.getWorkbook();
|
||||||
for(Ptg ptg : wb.getFormulaTokens(cell)){
|
for(Ptg ptg : wb.getFormulaTokens(cell)){
|
||||||
if(ptg instanceof FuncVarPtg){
|
if(ptg instanceof FuncVarPtg){
|
||||||
|
@ -978,7 +978,7 @@ public class DataFormatter implements Observer {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
CellType cellType = cell.getCellTypeEnum();
|
CellType cellType = cell.getCellType();
|
||||||
if (cellType == CellType.FORMULA) {
|
if (cellType == CellType.FORMULA) {
|
||||||
if (evaluator == null) {
|
if (evaluator == null) {
|
||||||
return cell.getCellFormula();
|
return cell.getCellFormula();
|
||||||
|
@ -42,7 +42,7 @@ public class DataSources {
|
|||||||
return new AbstractCellRangeDataSource<Number>(sheet, cellRangeAddress) {
|
return new AbstractCellRangeDataSource<Number>(sheet, cellRangeAddress) {
|
||||||
public Number getPointAt(int index) {
|
public Number getPointAt(int index) {
|
||||||
CellValue cellValue = getCellValueAt(index);
|
CellValue cellValue = getCellValueAt(index);
|
||||||
if (cellValue != null && cellValue.getCellTypeEnum() == CellType.NUMERIC) {
|
if (cellValue != null && cellValue.getCellType() == CellType.NUMERIC) {
|
||||||
return Double.valueOf(cellValue.getNumberValue());
|
return Double.valueOf(cellValue.getNumberValue());
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -59,7 +59,7 @@ public class DataSources {
|
|||||||
return new AbstractCellRangeDataSource<String>(sheet, cellRangeAddress) {
|
return new AbstractCellRangeDataSource<String>(sheet, cellRangeAddress) {
|
||||||
public String getPointAt(int index) {
|
public String getPointAt(int index) {
|
||||||
CellValue cellValue = getCellValueAt(index);
|
CellValue cellValue = getCellValueAt(index);
|
||||||
if (cellValue != null && cellValue.getCellTypeEnum() == CellType.STRING) {
|
if (cellValue != null && cellValue.getCellType() == CellType.STRING) {
|
||||||
return cellValue.getStringValue();
|
return cellValue.getStringValue();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -392,7 +392,7 @@ public class SXSSFCell implements Cell {
|
|||||||
* For strings we throw an exception. For blank cells we return a null.
|
* For strings we throw an exception. For blank cells we return a null.
|
||||||
* </p>
|
* </p>
|
||||||
* @return the value of the cell as a date
|
* @return the value of the cell as a date
|
||||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING
|
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING
|
||||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||||
* @see org.apache.poi.ss.usermodel.DataFormatter for formatting this date into a string similar to how excel does.
|
* @see org.apache.poi.ss.usermodel.DataFormatter for formatting this date into a string similar to how excel does.
|
||||||
*/
|
*/
|
||||||
@ -512,7 +512,7 @@ public class SXSSFCell implements Cell {
|
|||||||
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
|
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
|
||||||
* </p>
|
* </p>
|
||||||
* @return the value of the cell as a boolean
|
* @return the value of the cell as a boolean
|
||||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
|
* @throws IllegalStateException if the cell type returned by {@link #getCellType()}
|
||||||
* is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULA
|
* is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULA
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -547,7 +547,7 @@ public class SXSSFCell implements Cell {
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return the value of the cell as an error code
|
* @return the value of the cell as an error code
|
||||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't CellType.ERROR
|
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't CellType.ERROR
|
||||||
* @see org.apache.poi.ss.usermodel.FormulaError for error codes
|
* @see org.apache.poi.ss.usermodel.FormulaError for error codes
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -727,7 +727,7 @@ public class SXSSFCell implements Cell {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
switch (getCellTypeEnum()) {
|
switch (getCellType()) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
return "";
|
return "";
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
|
@ -256,7 +256,7 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
|
|||||||
case RETURN_NULL_AND_BLANK:
|
case RETURN_NULL_AND_BLANK:
|
||||||
return cell;
|
return cell;
|
||||||
case RETURN_BLANK_AS_NULL:
|
case RETURN_BLANK_AS_NULL:
|
||||||
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
|
boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
|
||||||
return (isBlank) ? null : cell;
|
return (isBlank) ? null : cell;
|
||||||
case CREATE_NULL_AS_BLANK:
|
case CREATE_NULL_AS_BLANK:
|
||||||
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
||||||
|
@ -75,7 +75,7 @@ public final class XSSFFormulaUtils {
|
|||||||
for (Sheet sh : _wb) {
|
for (Sheet sh : _wb) {
|
||||||
for (Row row : sh) {
|
for (Row row : sh) {
|
||||||
for (Cell cell : row) {
|
for (Cell cell : row) {
|
||||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
if (cell.getCellType() == CellType.FORMULA) {
|
||||||
updateFormula((XSSFCell) cell, oldName, newName);
|
updateFormula((XSSFCell) cell, oldName, newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ public abstract class BaseTestXSSFPivotTable {
|
|||||||
@Test
|
@Test
|
||||||
public void testAddDataColumnWithOffsetData() {
|
public void testAddDataColumnWithOffsetData() {
|
||||||
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
|
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
|
||||||
assertEquals(CellType.NUMERIC, offsetOuterCell.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, offsetOuterCell.getCellType());
|
||||||
|
|
||||||
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0);
|
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0);
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ public final class TestXSSFFormulaParser {
|
|||||||
|
|
||||||
for (Row row : xsheet) {
|
for (Row row : xsheet) {
|
||||||
for (Cell cell : row) {
|
for (Cell cell : row) {
|
||||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
if (cell.getCellType() == CellType.FORMULA) {
|
||||||
try {
|
try {
|
||||||
evaluator.evaluateFormulaCell(cell);
|
evaluator.evaluateFormulaCell(cell);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -158,7 +158,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
doTestHyperlinkContents(sheet);
|
doTestHyperlinkContents(sheet);
|
||||||
|
|
||||||
assertEquals(HyperlinkType.URL,
|
assertEquals(HyperlinkType.URL,
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getTypeEnum());
|
sheet.getRow(17).getCell(2).getHyperlink().getType());
|
||||||
assertEquals("POI SS Link",
|
assertEquals("POI SS Link",
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("http://poi.apache.org/spreadsheet/",
|
assertEquals("http://poi.apache.org/spreadsheet/",
|
||||||
@ -179,7 +179,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
doTestHyperlinkContents(sheet);
|
doTestHyperlinkContents(sheet);
|
||||||
|
|
||||||
assertEquals(HyperlinkType.URL,
|
assertEquals(HyperlinkType.URL,
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getTypeEnum());
|
sheet.getRow(17).getCell(2).getHyperlink().getType());
|
||||||
assertEquals("POI SS Link",
|
assertEquals("POI SS Link",
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("http://poi.apache.org/spreadsheet/",
|
assertEquals("http://poi.apache.org/spreadsheet/",
|
||||||
@ -197,7 +197,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
|
|
||||||
// First is a link to poi
|
// First is a link to poi
|
||||||
assertEquals(HyperlinkType.URL,
|
assertEquals(HyperlinkType.URL,
|
||||||
sheet.getRow(3).getCell(2).getHyperlink().getTypeEnum());
|
sheet.getRow(3).getCell(2).getHyperlink().getType());
|
||||||
assertEquals(null,
|
assertEquals(null,
|
||||||
sheet.getRow(3).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(3).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("http://poi.apache.org/",
|
assertEquals("http://poi.apache.org/",
|
||||||
@ -205,7 +205,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
|
|
||||||
// Next is an internal doc link
|
// Next is an internal doc link
|
||||||
assertEquals(HyperlinkType.DOCUMENT,
|
assertEquals(HyperlinkType.DOCUMENT,
|
||||||
sheet.getRow(14).getCell(2).getHyperlink().getTypeEnum());
|
sheet.getRow(14).getCell(2).getHyperlink().getType());
|
||||||
assertEquals("Internal hyperlink to A2",
|
assertEquals("Internal hyperlink to A2",
|
||||||
sheet.getRow(14).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(14).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("Sheet1!A2",
|
assertEquals("Sheet1!A2",
|
||||||
@ -213,7 +213,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
|
|
||||||
// Next is a file
|
// Next is a file
|
||||||
assertEquals(HyperlinkType.FILE,
|
assertEquals(HyperlinkType.FILE,
|
||||||
sheet.getRow(15).getCell(2).getHyperlink().getTypeEnum());
|
sheet.getRow(15).getCell(2).getHyperlink().getType());
|
||||||
assertEquals(null,
|
assertEquals(null,
|
||||||
sheet.getRow(15).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(15).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("WithVariousData.xlsx",
|
assertEquals("WithVariousData.xlsx",
|
||||||
@ -221,7 +221,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
|
|
||||||
// Last is a mailto
|
// Last is a mailto
|
||||||
assertEquals(HyperlinkType.EMAIL,
|
assertEquals(HyperlinkType.EMAIL,
|
||||||
sheet.getRow(16).getCell(2).getHyperlink().getTypeEnum());
|
sheet.getRow(16).getCell(2).getHyperlink().getType());
|
||||||
assertEquals(null,
|
assertEquals(null,
|
||||||
sheet.getRow(16).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(16).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("mailto:dev@poi.apache.org?subject=XSSF%20Hyperlinks",
|
assertEquals("mailto:dev@poi.apache.org?subject=XSSF%20Hyperlinks",
|
||||||
@ -238,13 +238,13 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
|
|
||||||
assertEquals(sh1.getNumberOfComments(), sh2.getNumberOfComments());
|
assertEquals(sh1.getNumberOfComments(), sh2.getNumberOfComments());
|
||||||
XSSFHyperlink l1 = sh1.getHyperlink(0, 1);
|
XSSFHyperlink l1 = sh1.getHyperlink(0, 1);
|
||||||
assertEquals(HyperlinkType.DOCUMENT, l1.getTypeEnum());
|
assertEquals(HyperlinkType.DOCUMENT, l1.getType());
|
||||||
assertEquals("B1", l1.getCellRef());
|
assertEquals("B1", l1.getCellRef());
|
||||||
assertEquals("Sort on Titel", l1.getTooltip());
|
assertEquals("Sort on Titel", l1.getTooltip());
|
||||||
|
|
||||||
XSSFHyperlink l2 = sh2.getHyperlink(0, 1);
|
XSSFHyperlink l2 = sh2.getHyperlink(0, 1);
|
||||||
assertEquals(l1.getTooltip(), l2.getTooltip());
|
assertEquals(l1.getTooltip(), l2.getTooltip());
|
||||||
assertEquals(HyperlinkType.DOCUMENT, l2.getTypeEnum());
|
assertEquals(HyperlinkType.DOCUMENT, l2.getType());
|
||||||
assertEquals("B1", l2.getCellRef());
|
assertEquals("B1", l2.getCellRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,22 +309,22 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
|||||||
|
|
||||||
XSSFHyperlink link = sh.getHyperlink(A2);
|
XSSFHyperlink link = sh.getHyperlink(A2);
|
||||||
assertEquals("address", "A2", link.getCellRef());
|
assertEquals("address", "A2", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.URL, link.getTypeEnum());
|
assertEquals("link type", HyperlinkType.URL, link.getType());
|
||||||
assertEquals("link target", "http://twitter.com/#!/apacheorg", link.getAddress());
|
assertEquals("link target", "http://twitter.com/#!/apacheorg", link.getAddress());
|
||||||
|
|
||||||
link = sh.getHyperlink(A3);
|
link = sh.getHyperlink(A3);
|
||||||
assertEquals("address", "A3", link.getCellRef());
|
assertEquals("address", "A3", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.URL, link.getTypeEnum());
|
assertEquals("link type", HyperlinkType.URL, link.getType());
|
||||||
assertEquals("link target", "http://www.bailii.org/databases.html#ie", link.getAddress());
|
assertEquals("link target", "http://www.bailii.org/databases.html#ie", link.getAddress());
|
||||||
|
|
||||||
link = sh.getHyperlink(A4);
|
link = sh.getHyperlink(A4);
|
||||||
assertEquals("address", "A4", link.getCellRef());
|
assertEquals("address", "A4", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.URL, link.getTypeEnum());
|
assertEquals("link type", HyperlinkType.URL, link.getType());
|
||||||
assertEquals("link target", "https://en.wikipedia.org/wiki/Apache_POI#See_also", link.getAddress());
|
assertEquals("link target", "https://en.wikipedia.org/wiki/Apache_POI#See_also", link.getAddress());
|
||||||
|
|
||||||
link = sh.getHyperlink(A7);
|
link = sh.getHyperlink(A7);
|
||||||
assertEquals("address", "A7", link.getCellRef());
|
assertEquals("address", "A7", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.DOCUMENT, link.getTypeEnum());
|
assertEquals("link type", HyperlinkType.DOCUMENT, link.getType());
|
||||||
assertEquals("link target", "Sheet1", link.getAddress());
|
assertEquals("link target", "Sheet1", link.getAddress());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
|
@ -1470,44 +1470,44 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
|
|
||||||
// Blank
|
// Blank
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellTypeEnum());
|
assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellType());
|
||||||
|
|
||||||
// Error
|
// Error
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellTypeEnum());
|
assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellType());
|
||||||
final FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
|
final FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
|
||||||
assertEquals("[Error] D7 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
assertEquals("[Error] D7 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
final Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
|
final Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
|
||||||
assertEquals("[Date] E7 cell value", date, cell.getDateCellValue());
|
assertEquals("[Date] E7 cell value", date, cell.getDateCellValue());
|
||||||
|
|
||||||
// Boolean
|
// Boolean
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellTypeEnum());
|
assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellType());
|
||||||
assertEquals("[Boolean] F7 cell value", true, cell.getBooleanCellValue());
|
assertEquals("[Boolean] F7 cell value", true, cell.getBooleanCellValue());
|
||||||
|
|
||||||
// String
|
// String
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellTypeEnum());
|
assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellType());
|
||||||
assertEquals("[String] G7 cell value", "Hello", cell.getStringCellValue());
|
assertEquals("[String] G7 cell value", "Hello", cell.getStringCellValue());
|
||||||
|
|
||||||
// Int
|
// Int
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Int] H7 cell value", 15, (int) cell.getNumericCellValue());
|
assertEquals("[Int] H7 cell value", 15, (int) cell.getNumericCellValue());
|
||||||
|
|
||||||
// Float
|
// Float
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Float] I7 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
assertEquals("[Float] I7 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||||
|
|
||||||
// Cell Formula
|
// Cell Formula
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("J7", new CellReference(cell).formatAsString());
|
assertEquals("J7", new CellReference(cell).formatAsString());
|
||||||
assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula());
|
assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula());
|
||||||
System.out.println("Cell formula evaluation currently unsupported");
|
System.out.println("Cell formula evaluation currently unsupported");
|
||||||
|
|
||||||
@ -1516,21 +1516,21 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("K7", new CellReference(cell).formatAsString());
|
assertEquals("K7", new CellReference(cell).formatAsString());
|
||||||
assertEquals("[Cell Formula with Reference] K7 cell type",
|
assertEquals("[Cell Formula with Reference] K7 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Reference] K7 cell formula",
|
assertEquals("[Cell Formula with Reference] K7 cell formula",
|
||||||
"J7+H$2", cell.getCellFormula());
|
"J7+H$2", cell.getCellFormula());
|
||||||
|
|
||||||
// Cell Formula with Reference spanning multiple rows
|
// Cell Formula with Reference spanning multiple rows
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell type",
|
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell formula",
|
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell formula",
|
||||||
"G7&\" \"&G8", cell.getCellFormula());
|
"G7&\" \"&G8", cell.getCellFormula());
|
||||||
|
|
||||||
// Cell Formula with Reference spanning multiple rows
|
// Cell Formula with Reference spanning multiple rows
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Cell Formula with Area Reference] M7 cell type",
|
assertEquals("[Cell Formula with Area Reference] M7 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Area Reference] M7 cell formula",
|
assertEquals("[Cell Formula with Area Reference] M7 cell formula",
|
||||||
"SUM(H7:I8)", cell.getCellFormula());
|
"SUM(H7:I8)", cell.getCellFormula());
|
||||||
|
|
||||||
@ -1539,13 +1539,13 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
System.out.println("Array formulas currently unsupported");
|
System.out.println("Array formulas currently unsupported");
|
||||||
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
|
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
|
||||||
/*
|
/*
|
||||||
assertEquals("[Array Formula] N7 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals("[Array Formula] N7 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Array Formula] N7 cell formula", "{SUM(H7:J7*{1,2,3})}", cell.getCellFormula());
|
assertEquals("[Array Formula] N7 cell formula", "{SUM(H7:J7*{1,2,3})}", cell.getCellFormula());
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Data Format
|
// Data Format
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
cell = CellUtil.getCell(destRow, col++);
|
||||||
assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Data Format] O7 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
|
assertEquals("[Data Format] O7 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||||
//FIXME: currently fails
|
//FIXME: currently fails
|
||||||
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
|
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
|
||||||
@ -1624,83 +1624,83 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
// Blank
|
// Blank
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellTypeEnum());
|
assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellType());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellTypeEnum());
|
assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellType());
|
||||||
|
|
||||||
// Error
|
// Error
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellTypeEnum());
|
assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellType());
|
||||||
FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
|
FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
|
||||||
assertEquals("[Error] D10 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
assertEquals("[Error] D10 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellTypeEnum());
|
assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellType());
|
||||||
error = FormulaError.forInt(cell.getErrorCellValue());
|
error = FormulaError.forInt(cell.getErrorCellValue());
|
||||||
assertEquals("[Error] D11 cell value", FormulaError.NAME, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
assertEquals("[Error] D11 cell value", FormulaError.NAME, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
|
Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
|
||||||
assertEquals("[Date] E10 cell value", date, cell.getDateCellValue());
|
assertEquals("[Date] E10 cell value", date, cell.getDateCellValue());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 2).getTime();
|
date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 2).getTime();
|
||||||
assertEquals("[Date] E11 cell value", date, cell.getDateCellValue());
|
assertEquals("[Date] E11 cell value", date, cell.getDateCellValue());
|
||||||
|
|
||||||
// Boolean
|
// Boolean
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellTypeEnum());
|
assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellType());
|
||||||
assertEquals("[Boolean] F10 cell value", true, cell.getBooleanCellValue());
|
assertEquals("[Boolean] F10 cell value", true, cell.getBooleanCellValue());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellTypeEnum());
|
assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellType());
|
||||||
assertEquals("[Boolean] F11 cell value", false, cell.getBooleanCellValue());
|
assertEquals("[Boolean] F11 cell value", false, cell.getBooleanCellValue());
|
||||||
|
|
||||||
// String
|
// String
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellTypeEnum());
|
assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellType());
|
||||||
assertEquals("[String] G10 cell value", "Hello", cell.getStringCellValue());
|
assertEquals("[String] G10 cell value", "Hello", cell.getStringCellValue());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellTypeEnum());
|
assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellType());
|
||||||
assertEquals("[String] G11 cell value", "World", cell.getStringCellValue());
|
assertEquals("[String] G11 cell value", "World", cell.getStringCellValue());
|
||||||
|
|
||||||
// Int
|
// Int
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Int] H10 cell value", 15, (int) cell.getNumericCellValue());
|
assertEquals("[Int] H10 cell value", 15, (int) cell.getNumericCellValue());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Int] H11 cell value", 42, (int) cell.getNumericCellValue());
|
assertEquals("[Int] H11 cell value", 42, (int) cell.getNumericCellValue());
|
||||||
|
|
||||||
// Float
|
// Float
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Float] I10 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
assertEquals("[Float] I10 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Float] I11 cell value", 5.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
assertEquals("[Float] I11 cell value", 5.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||||
|
|
||||||
// Cell Formula
|
// Cell Formula
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula] J10 cell formula", "5+2", cell.getCellFormula());
|
assertEquals("[Cell Formula] J10 cell formula", "5+2", cell.getCellFormula());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula] J11 cell formula", "6+18", cell.getCellFormula());
|
assertEquals("[Cell Formula] J11 cell formula", "6+18", cell.getCellFormula());
|
||||||
|
|
||||||
// Cell Formula with Reference
|
// Cell Formula with Reference
|
||||||
@ -1708,25 +1708,25 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
// Formula row references should be adjusted by destRowNum-srcRowNum
|
// Formula row references should be adjusted by destRowNum-srcRowNum
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Cell Formula with Reference] K10 cell type",
|
assertEquals("[Cell Formula with Reference] K10 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Reference] K10 cell formula",
|
assertEquals("[Cell Formula with Reference] K10 cell formula",
|
||||||
"J10+H$2", cell.getCellFormula());
|
"J10+H$2", cell.getCellFormula());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Reference] K11 cell formula", "J11+H$2", cell.getCellFormula());
|
assertEquals("[Cell Formula with Reference] K11 cell formula", "J11+H$2", cell.getCellFormula());
|
||||||
|
|
||||||
// Cell Formula with Reference spanning multiple rows
|
// Cell Formula with Reference spanning multiple rows
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell type",
|
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell formula",
|
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell formula",
|
||||||
"G10&\" \"&G11", cell.getCellFormula());
|
"G10&\" \"&G11", cell.getCellFormula());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell type",
|
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell formula",
|
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell formula",
|
||||||
"G11&\" \"&G12", cell.getCellFormula());
|
"G11&\" \"&G12", cell.getCellFormula());
|
||||||
|
|
||||||
@ -1734,13 +1734,13 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow1, col);
|
cell = CellUtil.getCell(destRow1, col);
|
||||||
assertEquals("[Cell Formula with Area Reference] M10 cell type",
|
assertEquals("[Cell Formula with Area Reference] M10 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Area Reference] M10 cell formula",
|
assertEquals("[Cell Formula with Area Reference] M10 cell formula",
|
||||||
"SUM(H10:I11)", cell.getCellFormula());
|
"SUM(H10:I11)", cell.getCellFormula());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Cell Formula with Area Reference] M11 cell type",
|
assertEquals("[Cell Formula with Area Reference] M11 cell type",
|
||||||
CellType.FORMULA, cell.getCellTypeEnum());
|
CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula with Area Reference] M11 cell formula",
|
assertEquals("[Cell Formula with Area Reference] M11 cell formula",
|
||||||
"SUM($H$3:I10)", cell.getCellFormula()); //Also acceptable: SUM($H10:I$3), but this AreaReference isn't in ascending order
|
"SUM($H$3:I10)", cell.getCellFormula()); //Also acceptable: SUM($H10:I$3), but this AreaReference isn't in ascending order
|
||||||
|
|
||||||
@ -1750,19 +1750,19 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
// System.out.println("Array formulas currently unsupported");
|
// System.out.println("Array formulas currently unsupported");
|
||||||
/*
|
/*
|
||||||
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
|
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
|
||||||
assertEquals("[Array Formula] N10 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals("[Array Formula] N10 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Array Formula] N10 cell formula", "{SUM(H10:J10*{1,2,3})}", cell.getCellFormula());
|
assertEquals("[Array Formula] N10 cell formula", "{SUM(H10:J10*{1,2,3})}", cell.getCellFormula());
|
||||||
|
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
|
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
|
||||||
assertEquals("[Array Formula] N11 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals("[Array Formula] N11 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Array Formula] N11 cell formula", "{SUM(H11:J11*{1,2,3})}", cell.getCellFormula());
|
assertEquals("[Array Formula] N11 cell formula", "{SUM(H11:J11*{1,2,3})}", cell.getCellFormula());
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Data Format
|
// Data Format
|
||||||
col++;
|
col++;
|
||||||
cell = CellUtil.getCell(destRow2, col);
|
cell = CellUtil.getCell(destRow2, col);
|
||||||
assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals("[Data Format] O10 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
|
assertEquals("[Data Format] O10 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||||
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
|
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
|
||||||
assertEquals("[Data Format] O10 cell data format", moneyFormat, cell.getCellStyle().getDataFormatString());
|
assertEquals("[Data Format] O10 cell data format", moneyFormat, cell.getCellStyle().getDataFormatString());
|
||||||
|
@ -113,7 +113,7 @@ public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows {
|
|||||||
}
|
}
|
||||||
Cell readCell = readRow.getCell(0);
|
Cell readCell = readRow.getCell(0);
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
if(readCell.getCellTypeEnum() == CellType.NUMERIC) {
|
if(readCell.getCellType() == CellType.NUMERIC) {
|
||||||
assertEquals(expect, Double.toString(readCell.getNumericCellValue()));
|
assertEquals(expect, Double.toString(readCell.getNumericCellValue()));
|
||||||
} else {
|
} else {
|
||||||
assertEquals(expect, readCell.getStringCellValue());
|
assertEquals(expect, readCell.getStringCellValue());
|
||||||
@ -413,7 +413,7 @@ public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows {
|
|||||||
assertNotNull(row);
|
assertNotNull(row);
|
||||||
Cell cell = row.getCell(cellAddress.getColumn());
|
Cell cell = row.getCell(cellAddress.getColumn());
|
||||||
assertNotNull(cell);
|
assertNotNull(cell);
|
||||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||||
return cell.getCellFormula();
|
return cell.getCellFormula();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,31 +129,31 @@ public final class TestHyperlink {
|
|||||||
hl1 = tb1.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
hl1 = tb1.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
||||||
assertNotNull(hl1);
|
assertNotNull(hl1);
|
||||||
assertEquals("dev@poi.apache.org", hl1.getLabel());
|
assertEquals("dev@poi.apache.org", hl1.getLabel());
|
||||||
assertEquals(HyperlinkType.EMAIL, hl1.getTypeEnum());
|
assertEquals(HyperlinkType.EMAIL, hl1.getType());
|
||||||
|
|
||||||
HSLFTextBox tb2 = (HSLFTextBox)slides.get(1).getShapes().get(0);
|
HSLFTextBox tb2 = (HSLFTextBox)slides.get(1).getShapes().get(0);
|
||||||
hl2 = tb2.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
hl2 = tb2.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
||||||
assertNotNull(hl2);
|
assertNotNull(hl2);
|
||||||
assertEquals(InteractiveInfoAtom.LINK_LastSlide, hl2.getInfo().getInteractiveInfoAtom().getHyperlinkType());
|
assertEquals(InteractiveInfoAtom.LINK_LastSlide, hl2.getInfo().getInteractiveInfoAtom().getHyperlinkType());
|
||||||
assertEquals(HyperlinkType.DOCUMENT, hl2.getTypeEnum());
|
assertEquals(HyperlinkType.DOCUMENT, hl2.getType());
|
||||||
|
|
||||||
HSLFTextBox tb3 = (HSLFTextBox)slides.get(2).getShapes().get(0);
|
HSLFTextBox tb3 = (HSLFTextBox)slides.get(2).getShapes().get(0);
|
||||||
hl3 = tb3.getTextParagraphs().get(0).getTextRuns().get(1).getHyperlink();
|
hl3 = tb3.getTextParagraphs().get(0).getTextRuns().get(1).getHyperlink();
|
||||||
assertNotNull(hl3);
|
assertNotNull(hl3);
|
||||||
assertEquals(ppt2.getSlides().get(0)._getSheetNumber(), Integer.parseInt(hl3.getAddress().split(",")[0]));
|
assertEquals(ppt2.getSlides().get(0)._getSheetNumber(), Integer.parseInt(hl3.getAddress().split(",")[0]));
|
||||||
assertEquals(HyperlinkType.DOCUMENT, hl3.getTypeEnum());
|
assertEquals(HyperlinkType.DOCUMENT, hl3.getType());
|
||||||
|
|
||||||
HSLFTextBox tb4 = (HSLFTextBox)slides.get(3).getShapes().get(0);
|
HSLFTextBox tb4 = (HSLFTextBox)slides.get(3).getShapes().get(0);
|
||||||
hl4 = tb4.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
hl4 = tb4.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
||||||
assertNotNull(hl4);
|
assertNotNull(hl4);
|
||||||
assertEquals("http://poi.apache.org", hl4.getLabel());
|
assertEquals("http://poi.apache.org", hl4.getLabel());
|
||||||
assertEquals(HyperlinkType.URL, hl4.getTypeEnum());
|
assertEquals(HyperlinkType.URL, hl4.getType());
|
||||||
|
|
||||||
tb5 = (HSLFTextBox)slides.get(4).getShapes().get(0);
|
tb5 = (HSLFTextBox)slides.get(4).getShapes().get(0);
|
||||||
hl5 = tb5.getHyperlink();
|
hl5 = tb5.getHyperlink();
|
||||||
assertNotNull(hl5);
|
assertNotNull(hl5);
|
||||||
assertEquals(InteractiveInfoAtom.LINK_FirstSlide, hl5.getInfo().getInteractiveInfoAtom().getHyperlinkType());
|
assertEquals(InteractiveInfoAtom.LINK_FirstSlide, hl5.getInfo().getInteractiveInfoAtom().getHyperlinkType());
|
||||||
assertEquals(HyperlinkType.DOCUMENT, hl5.getTypeEnum());
|
assertEquals(HyperlinkType.DOCUMENT, hl5.getType());
|
||||||
|
|
||||||
ppt2.close();
|
ppt2.close();
|
||||||
}
|
}
|
||||||
|
@ -870,7 +870,7 @@ public final class TestBugs {
|
|||||||
assertEquals(hlRun.getId(), hlShape.getId());
|
assertEquals(hlRun.getId(), hlShape.getId());
|
||||||
assertEquals(hlRun.getAddress(), hlShape.getAddress());
|
assertEquals(hlRun.getAddress(), hlShape.getAddress());
|
||||||
assertEquals(hlRun.getLabel(), hlShape.getLabel());
|
assertEquals(hlRun.getLabel(), hlShape.getLabel());
|
||||||
assertEquals(hlRun.getTypeEnum(), hlShape.getTypeEnum());
|
assertEquals(hlRun.getType(), hlShape.getType());
|
||||||
assertEquals(hlRun.getStartIndex(), hlShape.getStartIndex());
|
assertEquals(hlRun.getStartIndex(), hlShape.getStartIndex());
|
||||||
assertEquals(hlRun.getEndIndex(), hlShape.getEndIndex());
|
assertEquals(hlRun.getEndIndex(), hlShape.getEndIndex());
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public final class TestFormulaParserEval extends TestCase {
|
|||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
assertEquals(CellType.NUMERIC, result.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, result.getCellType());
|
||||||
assertEquals(42.0, result.getNumberValue(), 0.0);
|
assertEquals(42.0, result.getNumberValue(), 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public final class TestRVA {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
HSSFCell cell = row.getCell(0);
|
HSSFCell cell = row.getCell(0);
|
||||||
if (cell == null || cell.getCellTypeEnum() == CellType.BLANK) {
|
if (cell == null || cell.getCellType() == CellType.BLANK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ public final class TestSharedFormulaRecord extends TestCase {
|
|||||||
private static void confirmCellEvaluation(HSSFWorkbook wb, HSSFCell cell, double expectedValue) {
|
private static void confirmCellEvaluation(HSSFWorkbook wb, HSSFCell cell, double expectedValue) {
|
||||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||||
CellValue cv = fe.evaluate(cell);
|
CellValue cv = fe.evaluate(cell);
|
||||||
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, cv.getCellType());
|
||||||
assertEquals(expectedValue, cv.getNumberValue(), 0.0);
|
assertEquals(expectedValue, cv.getNumberValue(), 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public final class TestBug42464 {
|
|||||||
Iterator<Cell> it = row.cellIterator();
|
Iterator<Cell> it = row.cellIterator();
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
HSSFCell cell = (HSSFCell)it.next();
|
HSSFCell cell = (HSSFCell)it.next();
|
||||||
if(cell.getCellTypeEnum() != CellType.FORMULA) {
|
if(cell.getCellType() != CellType.FORMULA) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
|
FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
|
||||||
|
@ -51,7 +51,7 @@ public class TestExternalReferenceChange extends TestCase {
|
|||||||
HSSFSheet lSheet = mainWorkbook.getSheetAt(0);
|
HSSFSheet lSheet = mainWorkbook.getSheetAt(0);
|
||||||
HSSFCell lA1Cell = lSheet.getRow(0).getCell(0);
|
HSSFCell lA1Cell = lSheet.getRow(0).getCell(0);
|
||||||
|
|
||||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||||
|
|
||||||
HSSFFormulaEvaluator lMainWorkbookEvaluator = new HSSFFormulaEvaluator(mainWorkbook);
|
HSSFFormulaEvaluator lMainWorkbookEvaluator = new HSSFFormulaEvaluator(mainWorkbook);
|
||||||
HSSFFormulaEvaluator lSourceEvaluator = new HSSFFormulaEvaluator(sourceWorkbook);
|
HSSFFormulaEvaluator lSourceEvaluator = new HSSFFormulaEvaluator(sourceWorkbook);
|
||||||
|
@ -384,7 +384,7 @@ public final class TestHSSFDataFormatter {
|
|||||||
HSSFRow row = sheet.getRow(0);
|
HSSFRow row = sheet.getRow(0);
|
||||||
HSSFCell cellA1 = row.getCell(0);
|
HSSFCell cellA1 = row.getCell(0);
|
||||||
|
|
||||||
assertEquals(CellType.NUMERIC, cellA1.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, cellA1.getCellType());
|
||||||
assertEquals(2345.0, cellA1.getNumericCellValue(), 0.0001);
|
assertEquals(2345.0, cellA1.getNumericCellValue(), 0.0001);
|
||||||
assertEquals("@", cellA1.getCellStyle().getDataFormatString());
|
assertEquals("@", cellA1.getCellStyle().getDataFormatString());
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ public final class TestWorkbook {
|
|||||||
HSSFSheet s = wb.getSheetAt(0);
|
HSSFSheet s = wb.getSheetAt(0);
|
||||||
HSSFCell c = s.getRow(0).getCell(0);
|
HSSFCell c = s.getRow(0).getCell(0);
|
||||||
|
|
||||||
assertEquals(CellType.NUMERIC, c.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, c.getCellType());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
@ -78,18 +78,18 @@ public class TestIfError extends TestCase {
|
|||||||
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
|
|
||||||
assertEquals("Checks that the cell is numeric",
|
assertEquals("Checks that the cell is numeric",
|
||||||
CellType.NUMERIC, evaluator.evaluate(cell1).getCellTypeEnum());
|
CellType.NUMERIC, evaluator.evaluate(cell1).getCellType());
|
||||||
assertEquals("Divides 210 by 35 and returns 6.0",
|
assertEquals("Divides 210 by 35 and returns 6.0",
|
||||||
6.0, evaluator.evaluate(cell1).getNumberValue(), accuracy);
|
6.0, evaluator.evaluate(cell1).getNumberValue(), accuracy);
|
||||||
|
|
||||||
|
|
||||||
assertEquals("Checks that the cell is numeric",
|
assertEquals("Checks that the cell is numeric",
|
||||||
CellType.STRING, evaluator.evaluate(cell2).getCellTypeEnum());
|
CellType.STRING, evaluator.evaluate(cell2).getCellType());
|
||||||
assertEquals("Rounds -10 to a nearest multiple of -3 (-9)",
|
assertEquals("Rounds -10 to a nearest multiple of -3 (-9)",
|
||||||
"Error in calculation", evaluator.evaluate(cell2).getStringValue());
|
"Error in calculation", evaluator.evaluate(cell2).getStringValue());
|
||||||
|
|
||||||
assertEquals("Check that C1 returns string",
|
assertEquals("Check that C1 returns string",
|
||||||
CellType.STRING, evaluator.evaluate(cell3).getCellTypeEnum());
|
CellType.STRING, evaluator.evaluate(cell3).getCellType());
|
||||||
assertEquals("Check that C1 returns string \"error\"",
|
assertEquals("Check that C1 returns string \"error\"",
|
||||||
"error", evaluator.evaluate(cell3).getStringValue());
|
"error", evaluator.evaluate(cell3).getStringValue());
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public final class TestYearFracCalculatorFromSpreadsheet {
|
|||||||
HSSFRow row = (HSSFRow) rowIterator.next();
|
HSSFRow row = (HSSFRow) rowIterator.next();
|
||||||
|
|
||||||
HSSFCell cell = row.getCell(SS.YEARFRAC_FORMULA_COLUMN);
|
HSSFCell cell = row.getCell(SS.YEARFRAC_FORMULA_COLUMN);
|
||||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
if (cell == null || cell.getCellType() != CellType.FORMULA) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
processRow(row, cell, formulaEvaluator);
|
processRow(row, cell, formulaEvaluator);
|
||||||
|
@ -58,7 +58,7 @@ public final class TestFormulaBugs {
|
|||||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
CellValue cv = fe.evaluate(cell);
|
CellValue cv = fe.evaluate(cell);
|
||||||
|
|
||||||
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, cv.getCellType());
|
||||||
assertEquals(3.0, cv.getNumberValue(), 0.0);
|
assertEquals(3.0, cv.getNumberValue(), 0.0);
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
@ -106,11 +106,11 @@ public final class TestFormulaBugs {
|
|||||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
CellValue cv;
|
CellValue cv;
|
||||||
cv = fe.evaluate(cell);
|
cv = fe.evaluate(cell);
|
||||||
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, cv.getCellType());
|
||||||
assertEquals(1.0, cv.getNumberValue(), 0.0);
|
assertEquals(1.0, cv.getNumberValue(), 0.0);
|
||||||
|
|
||||||
cv = fe.evaluate(row.getCell(1));
|
cv = fe.evaluate(row.getCell(1));
|
||||||
assertEquals(CellType.BOOLEAN, cv.getCellTypeEnum());
|
assertEquals(CellType.BOOLEAN, cv.getCellType());
|
||||||
assertEquals(true, cv.getBooleanValue());
|
assertEquals(true, cv.getBooleanValue());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
@ -160,7 +160,7 @@ public final class TestFormulaBugs {
|
|||||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
CellValue cv = fe.evaluate(cell);
|
CellValue cv = fe.evaluate(cell);
|
||||||
|
|
||||||
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, cv.getCellType());
|
||||||
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
|
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
|
@ -78,7 +78,7 @@ public final class TestPercentEval extends TestCase {
|
|||||||
// else some other unexpected error
|
// else some other unexpected error
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, cv.getCellType());
|
||||||
assertEquals(0.5, cv.getNumberValue(), 0.0);
|
assertEquals(0.5, cv.getNumberValue(), 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public final class TestAddress extends TestCase {
|
|||||||
cell.setCellFormula(formulaText);
|
cell.setCellFormula(formulaText);
|
||||||
fe.notifyUpdateCell(cell);
|
fe.notifyUpdateCell(cell);
|
||||||
CellValue result = fe.evaluate(cell);
|
CellValue result = fe.evaluate(cell);
|
||||||
assertEquals(result.getCellTypeEnum(), CellType.STRING);
|
assertEquals(result.getCellType(), CellType.STRING);
|
||||||
assertEquals(expectedResult, result.getStringValue());
|
assertEquals(expectedResult, result.getStringValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ public final class TestCalendarFieldFunction extends TestCase {
|
|||||||
cell11.setCellFormula(formulaText);
|
cell11.setCellFormula(formulaText);
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
CellValue cv = evaluator.evaluate(cell11);
|
CellValue cv = evaluator.evaluate(cell11);
|
||||||
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
|
if (cv.getCellType() != CellType.NUMERIC) {
|
||||||
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
|
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
|
||||||
}
|
}
|
||||||
double actualValue = cv.getNumberValue();
|
double actualValue = cv.getNumberValue();
|
||||||
|
@ -60,7 +60,7 @@ public final class TestClean extends TestCase {
|
|||||||
cell.setCellFormula(formulaText);
|
cell.setCellFormula(formulaText);
|
||||||
fe.notifyUpdateCell(cell);
|
fe.notifyUpdateCell(cell);
|
||||||
CellValue result = fe.evaluate(cell);
|
CellValue result = fe.evaluate(cell);
|
||||||
assertEquals(result.getCellTypeEnum(), CellType.STRING);
|
assertEquals(result.getCellType(), CellType.STRING);
|
||||||
assertEquals(expectedResult, result.getStringValue());
|
assertEquals(expectedResult, result.getStringValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public final class TestIrr extends TestCase {
|
|||||||
private static void assertFormulaResult(CellValue cv, HSSFCell cell){
|
private static void assertFormulaResult(CellValue cv, HSSFCell cell){
|
||||||
double actualValue = cv.getNumberValue();
|
double actualValue = cv.getNumberValue();
|
||||||
double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
|
double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
|
||||||
assertEquals("Invalid formula result: " + cv, CellType.NUMERIC, cv.getCellTypeEnum());
|
assertEquals("Invalid formula result: " + cv, CellType.NUMERIC, cv.getCellType());
|
||||||
assertEquals(expectedValue, actualValue, 1E-4); // should agree within 0.01%
|
assertEquals(expectedValue, actualValue, 1E-4); // should agree within 0.01%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -750,7 +750,7 @@ public abstract class BaseTestSheetShiftRows {
|
|||||||
private void verifyHyperlink(Cell cell, HyperlinkType linkType, String ref) {
|
private void verifyHyperlink(Cell cell, HyperlinkType linkType, String ref) {
|
||||||
assertTrue(cellHasHyperlink(cell));
|
assertTrue(cellHasHyperlink(cell));
|
||||||
Hyperlink link = cell.getHyperlink();
|
Hyperlink link = cell.getHyperlink();
|
||||||
assertEquals(linkType, link.getTypeEnum());
|
assertEquals(linkType, link.getType());
|
||||||
assertEquals(ref, link.getAddress());
|
assertEquals(ref, link.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user