Replace deprecated CellReference class and some other warnings fixed
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1809714 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
43717f6936
commit
af1b1d619c
@ -19,7 +19,7 @@ package org.apache.poi.hssf.record;
|
|||||||
|
|
||||||
import org.apache.poi.ss.formula.ptg.TblPtg;
|
import org.apache.poi.ss.formula.ptg.TblPtg;
|
||||||
import org.apache.poi.hssf.util.CellRangeAddress8Bit;
|
import org.apache.poi.hssf.util.CellRangeAddress8Bit;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
import org.apache.poi.util.BitFieldFactory;
|
import org.apache.poi.util.BitFieldFactory;
|
||||||
import org.apache.poi.util.HexDump;
|
import org.apache.poi.util.HexDump;
|
||||||
@ -156,7 +156,7 @@ public final class TableRecord extends SharedValueRecordBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("[TABLE]\n");
|
buffer.append("[TABLE]\n");
|
||||||
buffer.append(" .range = ").append(getRange()).append("\n");
|
buffer.append(" .range = ").append(getRange()).append("\n");
|
||||||
buffer.append(" .flags = ") .append(HexDump.byteToHex(field_5_flags)).append("\n");
|
buffer.append(" .flags = ") .append(HexDump.byteToHex(field_5_flags)).append("\n");
|
||||||
|
@ -42,7 +42,7 @@ import org.apache.poi.hssf.record.FtCfSubRecord;
|
|||||||
import org.apache.poi.hssf.record.FtPioGrbitSubRecord;
|
import org.apache.poi.hssf.record.FtPioGrbitSubRecord;
|
||||||
import org.apache.poi.hssf.record.NoteRecord;
|
import org.apache.poi.hssf.record.NoteRecord;
|
||||||
import org.apache.poi.hssf.record.ObjRecord;
|
import org.apache.poi.hssf.record.ObjRecord;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||||
import org.apache.poi.ss.usermodel.Chart;
|
import org.apache.poi.ss.usermodel.Chart;
|
||||||
@ -119,7 +119,7 @@ public final class HSSFPatriarch implements HSSFShapeContainer, Drawing<HSSFShap
|
|||||||
*/
|
*/
|
||||||
protected void preSerialize(){
|
protected void preSerialize(){
|
||||||
Map<Integer, NoteRecord> tailRecords = _boundAggregate.getTailRecords();
|
Map<Integer, NoteRecord> tailRecords = _boundAggregate.getTailRecords();
|
||||||
/**
|
/*
|
||||||
* contains coordinates of comments we iterate over
|
* contains coordinates of comments we iterate over
|
||||||
*/
|
*/
|
||||||
Set<String> coordinates = new HashSet<>(tailRecords.size());
|
Set<String> coordinates = new HashSet<>(tailRecords.size());
|
||||||
@ -392,8 +392,7 @@ public final class HSSFPatriarch implements HSSFShapeContainer, Drawing<HSSFShap
|
|||||||
*/
|
*/
|
||||||
public int countOfAllChildren() {
|
public int countOfAllChildren() {
|
||||||
int count = _shapes.size();
|
int count = _shapes.size();
|
||||||
for (Iterator<HSSFShape> iterator = _shapes.iterator(); iterator.hasNext(); ) {
|
for (HSSFShape shape : _shapes) {
|
||||||
HSSFShape shape = iterator.next();
|
|
||||||
count += shape.countOfAllChildren();
|
count += shape.countOfAllChildren();
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
@ -450,8 +449,7 @@ public final class HSSFPatriarch implements HSSFShapeContainer, Drawing<HSSFShap
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<EscherProperty> it = optRecord.getEscherProperties().iterator(); it.hasNext(); ) {
|
for (EscherProperty prop : optRecord.getEscherProperties()) {
|
||||||
EscherProperty prop = it.next();
|
|
||||||
if (prop.getPropertyNumber() == 896 && prop.isComplex()) {
|
if (prop.getPropertyNumber() == 896 && prop.isComplex()) {
|
||||||
EscherComplexProperty cp = (EscherComplexProperty) prop;
|
EscherComplexProperty cp = (EscherComplexProperty) prop;
|
||||||
String str = StringUtil.getFromUnicodeLE(cp.getComplexData());
|
String str = StringUtil.getFromUnicodeLE(cp.getComplexData());
|
||||||
|
@ -82,7 +82,6 @@ import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
|
|||||||
import org.apache.poi.hssf.record.common.UnicodeString;
|
import org.apache.poi.hssf.record.common.UnicodeString;
|
||||||
import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream;
|
import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream;
|
||||||
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
|
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
|
||||||
import org.apache.poi.poifs.crypt.ChunkedCipherOutputStream;
|
import org.apache.poi.poifs.crypt.ChunkedCipherOutputStream;
|
||||||
import org.apache.poi.poifs.crypt.Decryptor;
|
import org.apache.poi.poifs.crypt.Decryptor;
|
||||||
import org.apache.poi.poifs.crypt.EncryptionInfo;
|
import org.apache.poi.poifs.crypt.EncryptionInfo;
|
||||||
@ -110,6 +109,7 @@ import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
|
|||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.SheetVisibility;
|
import org.apache.poi.ss.usermodel.SheetVisibility;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.util.Configurator;
|
import org.apache.poi.util.Configurator;
|
||||||
import org.apache.poi.util.HexDump;
|
import org.apache.poi.util.HexDump;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
@ -1367,12 +1367,9 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void write(File newFile) throws IOException {
|
public void write(File newFile) throws IOException {
|
||||||
POIFSFileSystem fs = POIFSFileSystem.create(newFile);
|
try (POIFSFileSystem fs = POIFSFileSystem.create(newFile)) {
|
||||||
try {
|
|
||||||
write(fs);
|
write(fs);
|
||||||
fs.writeFilesystem();
|
fs.writeFilesystem();
|
||||||
} finally {
|
|
||||||
fs.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1393,12 +1390,9 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void write(OutputStream stream) throws IOException {
|
public void write(OutputStream stream) throws IOException {
|
||||||
NPOIFSFileSystem fs = new NPOIFSFileSystem();
|
try (NPOIFSFileSystem fs = new NPOIFSFileSystem()) {
|
||||||
try {
|
|
||||||
write(fs);
|
write(fs);
|
||||||
fs.writeFilesystem(stream);
|
fs.writeFilesystem(stream);
|
||||||
} finally {
|
|
||||||
fs.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@ import java.util.Iterator;
|
|||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.record.FormulaRecord;
|
import org.apache.poi.hssf.record.FormulaRecord;
|
||||||
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
|
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.ss.formula.ptg.Ptg;
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
import org.apache.poi.ss.usermodel.CellValue;
|
import org.apache.poi.ss.usermodel.CellValue;
|
||||||
@ -73,9 +72,9 @@ public final class TestBug42464 {
|
|||||||
}
|
}
|
||||||
FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
|
FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
|
||||||
FormulaRecord r = record.getFormulaRecord();
|
FormulaRecord r = record.getFormulaRecord();
|
||||||
Ptg[] ptgs = r.getParsedExpression();
|
/*Ptg[] ptgs =*/ r.getParsedExpression();
|
||||||
|
|
||||||
String cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex(), false, false).formatAsString();
|
/*String cellRef =*/ new CellReference(row.getRowNum(), cell.getColumnIndex(), false, false).formatAsString();
|
||||||
// if(false && cellRef.equals("BP24")) { // TODO - replace System.out.println()s with asserts
|
// if(false && cellRef.equals("BP24")) { // TODO - replace System.out.println()s with asserts
|
||||||
// System.out.print(cellRef);
|
// System.out.print(cellRef);
|
||||||
// System.out.println(" - has " + ptgs.length + " ptgs:");
|
// System.out.println(" - has " + ptgs.length + " ptgs:");
|
||||||
|
@ -28,7 +28,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.ss.formula.FormulaType;
|
import org.apache.poi.ss.formula.FormulaType;
|
||||||
import org.apache.poi.ss.formula.ptg.NamePtg;
|
import org.apache.poi.ss.formula.ptg.NamePtg;
|
||||||
import org.apache.poi.ss.formula.ptg.Ptg;
|
import org.apache.poi.ss.formula.ptg.Ptg;
|
||||||
@ -52,8 +52,8 @@ public final class TestFormulas {
|
|||||||
|
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
//get our minimum values
|
//get our minimum values
|
||||||
r = s.createRow(1);
|
r = s.createRow(1);
|
||||||
@ -165,8 +165,8 @@ public final class TestFormulas {
|
|||||||
private static void floatTest(String operator) throws IOException {
|
private static void floatTest(String operator) throws IOException {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
//get our minimum values
|
//get our minimum values
|
||||||
|
|
||||||
@ -240,8 +240,8 @@ public final class TestFormulas {
|
|||||||
private static void operationRefTest(String operator) throws IOException {
|
private static void operationRefTest(String operator) throws IOException {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
//get our minimum values
|
//get our minimum values
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
@ -253,12 +253,12 @@ public final class TestFormulas {
|
|||||||
|
|
||||||
for (int y = 1; y < 256 && y > 0; y++) {
|
for (int y = 1; y < 256 && y > 0; y++) {
|
||||||
|
|
||||||
String ref=null;
|
String ref;
|
||||||
String ref2=null;
|
String ref2;
|
||||||
short refx1=0;
|
short refx1;
|
||||||
short refy1=0;
|
short refy1;
|
||||||
short refx2=0;
|
short refx2;
|
||||||
short refy2=0;
|
short refy2;
|
||||||
if (x +50 < Short.MAX_VALUE) {
|
if (x +50 < Short.MAX_VALUE) {
|
||||||
refx1=(short)(x+50);
|
refx1=(short)(x+50);
|
||||||
refx2=(short)(x+46);
|
refx2=(short)(x+46);
|
||||||
@ -309,8 +309,8 @@ public final class TestFormulas {
|
|||||||
private static void operationalRefVerify(String operator, HSSFWorkbook wb) {
|
private static void operationalRefVerify(String operator, HSSFWorkbook wb) {
|
||||||
|
|
||||||
HSSFSheet s = wb.getSheetAt(0);
|
HSSFSheet s = wb.getSheetAt(0);
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
//get our minimum values
|
//get our minimum values
|
||||||
r = s.getRow(0);
|
r = s.getRow(0);
|
||||||
@ -376,8 +376,8 @@ public final class TestFormulas {
|
|||||||
private static void orderTest(String formula) throws IOException {
|
private static void orderTest(String formula) throws IOException {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
//get our minimum values
|
//get our minimum values
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
@ -403,8 +403,8 @@ public final class TestFormulas {
|
|||||||
private static void binomialOperator(String operator) throws IOException {
|
private static void binomialOperator(String operator) throws IOException {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
//get our minimum values
|
//get our minimum values
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
@ -440,8 +440,8 @@ public final class TestFormulas {
|
|||||||
*/
|
*/
|
||||||
private static void binomialVerify(String operator, HSSFWorkbook wb) {
|
private static void binomialVerify(String operator, HSSFWorkbook wb) {
|
||||||
HSSFSheet s = wb.getSheetAt(0);
|
HSSFSheet s = wb.getSheetAt(0);
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
//get our minimum values
|
//get our minimum values
|
||||||
r = s.getRow(0);
|
r = s.getRow(0);
|
||||||
@ -481,8 +481,8 @@ public final class TestFormulas {
|
|||||||
|
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
|
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
@ -509,8 +509,8 @@ public final class TestFormulas {
|
|||||||
|
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
|
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
@ -539,8 +539,8 @@ public final class TestFormulas {
|
|||||||
|
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
|
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
@ -608,8 +608,8 @@ public final class TestFormulas {
|
|||||||
public void testSheetFunctions() throws IOException {
|
public void testSheetFunctions() throws IOException {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet("A");
|
HSSFSheet s = wb1.createSheet("A");
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
c = r.createCell(0);c.setCellValue(1);
|
c = r.createCell(0);c.setCellValue(1);
|
||||||
c = r.createCell(1);c.setCellValue(2);
|
c = r.createCell(1);c.setCellValue(2);
|
||||||
@ -638,8 +638,8 @@ public final class TestFormulas {
|
|||||||
FileOutputStream out = new FileOutputStream(file);
|
FileOutputStream out = new FileOutputStream(file);
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb.createSheet();
|
HSSFSheet s = wb.createSheet();
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
|
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
@ -676,8 +676,8 @@ public final class TestFormulas {
|
|||||||
public void testStringFormulas() throws IOException {
|
public void testStringFormulas() throws IOException {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb.createSheet("A");
|
HSSFSheet s = wb.createSheet("A");
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
c=r.createCell(1); c.setCellFormula("UPPER(\"abc\")");
|
c=r.createCell(1); c.setCellFormula("UPPER(\"abc\")");
|
||||||
c=r.createCell(2); c.setCellFormula("LOWER(\"ABC\")");
|
c=r.createCell(2); c.setCellFormula("LOWER(\"ABC\")");
|
||||||
@ -699,8 +699,8 @@ public final class TestFormulas {
|
|||||||
|
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet("A");
|
HSSFSheet s = wb1.createSheet("A");
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
c=r.createCell(1); c.setCellFormula("IF(A1<A2,B1,B2)");
|
c=r.createCell(1); c.setCellFormula("IF(A1<A2,B1,B2)");
|
||||||
|
|
||||||
@ -717,8 +717,8 @@ public final class TestFormulas {
|
|||||||
public void testDateFormulas() throws IOException {
|
public void testDateFormulas() throws IOException {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb.createSheet("testSheet1");
|
HSSFSheet s = wb.createSheet("testSheet1");
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
|
|
||||||
r = s.createRow(0 );
|
r = s.createRow(0 );
|
||||||
c = r.createCell(0 );
|
c = r.createCell(0 );
|
||||||
@ -746,8 +746,8 @@ public final class TestFormulas {
|
|||||||
public void testIfFormulas() throws IOException {
|
public void testIfFormulas() throws IOException {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet("testSheet1");
|
HSSFSheet s = wb1.createSheet("testSheet1");
|
||||||
HSSFRow r = null;
|
HSSFRow r;
|
||||||
HSSFCell c = null;
|
HSSFCell c;
|
||||||
r = s.createRow(0);
|
r = s.createRow(0);
|
||||||
c=r.createCell(1); c.setCellValue(1);
|
c=r.createCell(1); c.setCellValue(1);
|
||||||
c=r.createCell(2); c.setCellValue(2);
|
c=r.createCell(2); c.setCellValue(2);
|
||||||
@ -906,22 +906,16 @@ public final class TestFormulas {
|
|||||||
/** test for bug 34021*/
|
/** test for bug 34021*/
|
||||||
@Test
|
@Test
|
||||||
public void testComplexSheetRefs () throws IOException {
|
public void testComplexSheetRefs () throws IOException {
|
||||||
HSSFWorkbook sb = new HSSFWorkbook();
|
try (HSSFWorkbook sb = new HSSFWorkbook()) {
|
||||||
try {
|
HSSFSheet s1 = sb.createSheet("Sheet a.1");
|
||||||
HSSFSheet s1 = sb.createSheet("Sheet a.1");
|
HSSFSheet s2 = sb.createSheet("Sheet.A");
|
||||||
HSSFSheet s2 = sb.createSheet("Sheet.A");
|
s2.createRow(1).createCell(2).setCellFormula("'Sheet a.1'!A1");
|
||||||
s2.createRow(1).createCell(2).setCellFormula("'Sheet a.1'!A1");
|
s1.createRow(1).createCell(2).setCellFormula("'Sheet.A'!A1");
|
||||||
s1.createRow(1).createCell(2).setCellFormula("'Sheet.A'!A1");
|
File file = TempFile.createTempFile("testComplexSheetRefs", ".xls");
|
||||||
File file = TempFile.createTempFile("testComplexSheetRefs",".xls");
|
try (FileOutputStream stream = new FileOutputStream(file)) {
|
||||||
FileOutputStream stream = new FileOutputStream(file);
|
sb.write(stream);
|
||||||
try {
|
}
|
||||||
sb.write(stream);
|
}
|
||||||
} finally {
|
|
||||||
stream.close();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
sb.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Unknown Ptg 3C*/
|
/** Unknown Ptg 3C*/
|
||||||
@ -931,25 +925,20 @@ public final class TestFormulas {
|
|||||||
wb.getSheetAt(0);
|
wb.getSheetAt(0);
|
||||||
assertEquals("Reference for named range ", "Compliance!#REF!",wb.getNameAt(0).getRefersToFormula());
|
assertEquals("Reference for named range ", "Compliance!#REF!",wb.getNameAt(0).getRefersToFormula());
|
||||||
File outF = TempFile.createTempFile("bug27272_1",".xls");
|
File outF = TempFile.createTempFile("bug27272_1",".xls");
|
||||||
FileOutputStream stream = new FileOutputStream(outF);
|
try (FileOutputStream stream = new FileOutputStream(outF)) {
|
||||||
try {
|
|
||||||
wb.write(stream);
|
wb.write(stream);
|
||||||
} finally {
|
|
||||||
stream.close();
|
|
||||||
}
|
}
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Unknown Ptg 3D*/
|
/** Unknown Ptg 3D*/
|
||||||
@Test
|
@Test
|
||||||
public void test27272_2() throws IOException {
|
public void test27272_2() throws IOException {
|
||||||
HSSFWorkbook wb = openSample("27272_2.xls");
|
HSSFWorkbook wb = openSample("27272_2.xls");
|
||||||
assertEquals("Reference for named range ", "LOAD.POD_HISTORIES!#REF!",wb.getNameAt(0).getRefersToFormula());
|
assertEquals("Reference for named range ", "LOAD.POD_HISTORIES!#REF!",wb.getNameAt(0).getRefersToFormula());
|
||||||
File outF = TempFile.createTempFile("bug27272_2",".xls");
|
File outF = TempFile.createTempFile("bug27272_2",".xls");
|
||||||
FileOutputStream stream = new FileOutputStream(outF);
|
try (FileOutputStream stream = new FileOutputStream(outF)) {
|
||||||
try {
|
|
||||||
wb.write(stream);
|
wb.write(stream);
|
||||||
} finally {
|
|
||||||
stream.close();
|
|
||||||
}
|
}
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
@ -957,12 +946,9 @@ public final class TestFormulas {
|
|||||||
/** MissingArgPtg */
|
/** MissingArgPtg */
|
||||||
@Test
|
@Test
|
||||||
public void testMissingArgPtg() throws IOException {
|
public void testMissingArgPtg() throws IOException {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||||
try {
|
|
||||||
HSSFCell cell = wb.createSheet("Sheet1").createRow(4).createCell(0);
|
HSSFCell cell = wb.createSheet("Sheet1").createRow(4).createCell(0);
|
||||||
cell.setCellFormula("IF(A1=\"A\",1,)");
|
cell.setCellFormula("IF(A1=\"A\",1,)");
|
||||||
} finally {
|
|
||||||
wb.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1032,22 +1018,19 @@ public final class TestFormulas {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFormulasWithUnderscore() throws IOException{
|
public void testFormulasWithUnderscore() throws IOException{
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||||
try {
|
|
||||||
Name nm1 = wb.createName();
|
Name nm1 = wb.createName();
|
||||||
nm1.setNameName("_score1");
|
nm1.setNameName("_score1");
|
||||||
nm1.setRefersToFormula("A1");
|
nm1.setRefersToFormula("A1");
|
||||||
|
|
||||||
Name nm2 = wb.createName();
|
Name nm2 = wb.createName();
|
||||||
nm2.setNameName("_score2");
|
nm2.setNameName("_score2");
|
||||||
nm2.setRefersToFormula("A2");
|
nm2.setRefersToFormula("A2");
|
||||||
|
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
Cell cell = sheet.createRow(0).createCell(2);
|
Cell cell = sheet.createRow(0).createCell(2);
|
||||||
cell.setCellFormula("_score1*SUM(_score1+_score2)");
|
cell.setCellFormula("_score1*SUM(_score1+_score2)");
|
||||||
assertEquals("_score1*SUM(_score1+_score2)", cell.getCellFormula());
|
assertEquals("_score1*SUM(_score1+_score2)", cell.getCellFormula());
|
||||||
} finally {
|
|
||||||
wb.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
|
|||||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.ss.formula.IEvaluationListener.ICacheEntry;
|
import org.apache.poi.ss.formula.IEvaluationListener.ICacheEntry;
|
||||||
import org.apache.poi.ss.formula.PlainCellCache.Loc;
|
import org.apache.poi.ss.formula.PlainCellCache.Loc;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
@ -162,7 +162,7 @@ public class TestEvaluationCache extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void log(String tag, int rowIndex, int columnIndex, Object value) {
|
private void log(String tag, int rowIndex, int columnIndex, Object value) {
|
||||||
StringBuffer sb = new StringBuffer(64);
|
StringBuilder sb = new StringBuilder(64);
|
||||||
sb.append(tag).append(' ');
|
sb.append(tag).append(' ');
|
||||||
sb.append(new CellReference(rowIndex, columnIndex, false, false).formatAsString());
|
sb.append(new CellReference(rowIndex, columnIndex, false, false).formatAsString());
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
@ -208,9 +208,8 @@ public class TestEvaluationCache extends TestCase {
|
|||||||
* Wrapper class to manage repetitive tasks from this test,
|
* Wrapper class to manage repetitive tasks from this test,
|
||||||
*
|
*
|
||||||
* Note - this class does a little bit more than just plain set-up of data. The method
|
* Note - this class does a little bit more than just plain set-up of data. The method
|
||||||
* {@link WorkbookEvaluator#clearCachedResultValue(HSSFSheet, int, int)} is called whenever a
|
* {@link WorkbookEvaluator#notifyUpdateCell(EvaluationCell)} is called whenever a
|
||||||
* cell value is changed.
|
* cell value is changed.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private static final class MySheet {
|
private static final class MySheet {
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
|
|||||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.ss.formula.eval.ErrorEval;
|
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
import org.apache.poi.ss.usermodel.CellValue;
|
import org.apache.poi.ss.usermodel.CellValue;
|
||||||
@ -50,8 +50,6 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
* This class defines constants for navigating around the test data spreadsheet used for these tests.
|
* This class defines constants for navigating around the test data spreadsheet used for these tests.
|
||||||
*/
|
*/
|
||||||
interface SS {
|
interface SS {
|
||||||
/** Name of the test spreadsheet (found in the standard test data folder) */
|
|
||||||
|
|
||||||
/** Name of the first sheet in the spreadsheet (contains comments) */
|
/** Name of the first sheet in the spreadsheet (contains comments) */
|
||||||
String README_SHEET_NAME = "Read Me";
|
String README_SHEET_NAME = "Read Me";
|
||||||
|
|
||||||
@ -70,7 +68,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(value = 0)
|
@Parameter()
|
||||||
public String testName;
|
public String testName;
|
||||||
@Parameter(value = 1)
|
@Parameter(value = 1)
|
||||||
public String filename;
|
public String filename;
|
||||||
@ -92,7 +90,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
int nSheets = workbook.getNumberOfSheets();
|
int nSheets = workbook.getNumberOfSheets();
|
||||||
for(int sheetIdx=1; sheetIdx< nSheets; sheetIdx++) {
|
for(int sheetIdx=1; sheetIdx< nSheets; sheetIdx++) {
|
||||||
HSSFSheet sheet = workbook.getSheetAt(sheetIdx);
|
HSSFSheet sheet = workbook.getSheetAt(sheetIdx);
|
||||||
processFunctionGroup(data, sheet, SS.START_TEST_CASES_ROW_INDEX, null, filename);
|
processFunctionGroup(data, sheet, SS.START_TEST_CASES_ROW_INDEX, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
workbook.close();
|
workbook.close();
|
||||||
@ -100,7 +98,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processFunctionGroup(List<Object[]> data, HSSFSheet sheet, final int startRowIndex, String testFocusFunctionName, String filename) {
|
private static void processFunctionGroup(List<Object[]> data, HSSFSheet sheet, final int startRowIndex, String filename) {
|
||||||
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet.getWorkbook());
|
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet.getWorkbook());
|
||||||
|
|
||||||
String currentGroupComment = "";
|
String currentGroupComment = "";
|
||||||
@ -224,13 +222,13 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatValue(HSSFCell expecedCell) {
|
private static String formatValue(HSSFCell expectedCell) {
|
||||||
switch (expecedCell.getCellType()) {
|
switch (expectedCell.getCellType()) {
|
||||||
case BLANK: return "<blank>";
|
case BLANK: return "<blank>";
|
||||||
case BOOLEAN: return Boolean.toString(expecedCell.getBooleanCellValue());
|
case BOOLEAN: return Boolean.toString(expectedCell.getBooleanCellValue());
|
||||||
case NUMERIC: return Double.toString(expecedCell.getNumericCellValue());
|
case NUMERIC: return Double.toString(expectedCell.getNumericCellValue());
|
||||||
case STRING: return expecedCell.getRichStringCellValue().getString();
|
case STRING: return expectedCell.getRichStringCellValue().getString();
|
||||||
default: fail("Unexpected cell type of expected value (" + expecedCell.getCellType() + ")");
|
default: fail("Unexpected cell type of expected value (" + expectedCell.getCellType() + ")");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
|
|||||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
|
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.hssf.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
/**
|
/**
|
||||||
* Tests for proper calculation of named ranges from external workbooks.
|
* Tests for proper calculation of named ranges from external workbooks.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user