clean up whitespace and indents
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1801969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b0b3ad66ba
commit
2398bb7a60
@ -93,7 +93,7 @@ import org.junit.Test;
|
||||
/**
|
||||
* Testcases for bugs entered in bugzilla
|
||||
* the Test name contains the bugzilla bug id
|
||||
*
|
||||
* <p>
|
||||
* <b>YK: If a bug can be tested in terms of common ss interfaces,
|
||||
* define the test in the base class {@link BaseTestBugzillaIssues}</b>
|
||||
*/
|
||||
@ -116,8 +116,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
return HSSFITestDataProvider.instance.writeOutAndReadBack(original);
|
||||
}
|
||||
|
||||
/** Test reading AND writing a complicated workbook
|
||||
*Test opening resulting sheet in excel*/
|
||||
/**
|
||||
* Test reading AND writing a complicated workbook
|
||||
* Test opening resulting sheet in excel
|
||||
*/
|
||||
@Test
|
||||
public void bug15228() throws Exception {
|
||||
HSSFWorkbook wb = openSample("15228.xls");
|
||||
@ -140,7 +142,8 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
wb.close();
|
||||
}
|
||||
|
||||
/** test reading of a formula with a name and a cell ref in one
|
||||
/**
|
||||
* test reading of a formula with a name and a cell ref in one
|
||||
**/
|
||||
@Test
|
||||
public void bug14460() throws Exception {
|
||||
@ -164,8 +167,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
cell.setCellValue(new HSSFRichTextString(text));
|
||||
}
|
||||
|
||||
/** test rewriting a file with large number of unique strings
|
||||
*open resulting file in Excel to check results!*/
|
||||
/**
|
||||
* test rewriting a file with large number of unique strings
|
||||
* open resulting file in Excel to check results!
|
||||
*/
|
||||
@Test
|
||||
public void bug15375() throws Exception {
|
||||
HSSFWorkbook wb = openSample("15375.xls");
|
||||
@ -191,6 +196,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
writeOutAndReadBack(wb).close();
|
||||
wb.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* test writing a file with large number of unique strings,
|
||||
* open resulting file in Excel to check results!
|
||||
@ -200,55 +206,71 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
bug15375(6000);
|
||||
}
|
||||
|
||||
/**Double byte strings*/
|
||||
/**
|
||||
* Double byte strings
|
||||
*/
|
||||
@Test
|
||||
public void bug15556() throws Exception {
|
||||
HSSFWorkbook wb = openSample("15556.xls");
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
HSSFRow row = sheet.getRow(45);
|
||||
assertNotNull("Read row fine!" , row);
|
||||
assertNotNull("Read row fine!", row);
|
||||
wb.close();
|
||||
}
|
||||
|
||||
/**Double byte strings */
|
||||
/**
|
||||
* Double byte strings
|
||||
*/
|
||||
@Test
|
||||
public void bug22742() {
|
||||
openSample("22742.xls");
|
||||
}
|
||||
|
||||
/**Double byte strings */
|
||||
/**
|
||||
* Double byte strings
|
||||
*/
|
||||
@Test
|
||||
public void bug12561_1() {
|
||||
openSample("12561-1.xls");
|
||||
}
|
||||
|
||||
/** Double byte strings */
|
||||
/**
|
||||
* Double byte strings
|
||||
*/
|
||||
@Test
|
||||
public void bug12561_2() {
|
||||
openSample("12561-2.xls");
|
||||
}
|
||||
|
||||
/** Double byte strings
|
||||
File supplied by jubeson*/
|
||||
/**
|
||||
* Double byte strings
|
||||
* File supplied by jubeson
|
||||
*/
|
||||
@Test
|
||||
public void bug12843_1() {
|
||||
openSample("12843-1.xls");
|
||||
}
|
||||
|
||||
/** Double byte strings
|
||||
File supplied by Paul Chung*/
|
||||
/**
|
||||
* Double byte strings
|
||||
* File supplied by Paul Chung
|
||||
*/
|
||||
@Test
|
||||
public void bug12843_2() {
|
||||
openSample("12843-2.xls");
|
||||
}
|
||||
|
||||
/** Reference to Name*/
|
||||
/**
|
||||
* Reference to Name
|
||||
*/
|
||||
@Test
|
||||
public void bug13224() {
|
||||
openSample("13224.xls");
|
||||
}
|
||||
|
||||
/** Illegal argument exception - cannot store duplicate value in Map*/
|
||||
/**
|
||||
* Illegal argument exception - cannot store duplicate value in Map
|
||||
*/
|
||||
@Test
|
||||
public void bug19599() {
|
||||
openSample("19599-1.xls");
|
||||
@ -259,7 +281,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
public void bug24215() throws Exception {
|
||||
HSSFWorkbook wb = openSample("24215.xls");
|
||||
|
||||
for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets();sheetIndex++) {
|
||||
for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets(); sheetIndex++) {
|
||||
HSSFSheet sheet = wb.getSheetAt(sheetIndex);
|
||||
int rows = sheet.getLastRowNum();
|
||||
|
||||
@ -275,7 +297,8 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
wb.close();
|
||||
}
|
||||
|
||||
/**Tests read and write of Unicode strings in formula results
|
||||
/**
|
||||
* Tests read and write of Unicode strings in formula results
|
||||
* bug and testcase submitted by Sompop Kumnoonsate
|
||||
* The file contains THAI unicode characters.
|
||||
*/
|
||||
@ -352,24 +375,30 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
return sb.toString();
|
||||
}*/
|
||||
|
||||
/** Error in opening wb*/
|
||||
/**
|
||||
* Error in opening wb
|
||||
*/
|
||||
@Test
|
||||
public void bug32822() {
|
||||
openSample("32822.xls");
|
||||
}
|
||||
|
||||
/**fail to read wb with chart */
|
||||
/**
|
||||
* fail to read wb with chart
|
||||
*/
|
||||
@Test
|
||||
public void bug15573() {
|
||||
openSample("15573.xls");
|
||||
}
|
||||
|
||||
/**names and macros */
|
||||
/**
|
||||
* names and macros
|
||||
*/
|
||||
@Test
|
||||
public void bug27852() throws Exception {
|
||||
HSSFWorkbook wb = openSample("27852.xls");
|
||||
|
||||
for(int i = 0 ; i < wb.getNumberOfNames(); i++){
|
||||
for (int i = 0; i < wb.getNumberOfNames(); i++) {
|
||||
HSSFName name = wb.getNameAt(i);
|
||||
name.getNameName();
|
||||
if (name.isFunctionName()) {
|
||||
@ -394,7 +423,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
}
|
||||
|
||||
/** Error when reading then writing ArrayValues in NameRecord's*/
|
||||
/**
|
||||
* Error when reading then writing ArrayValues in NameRecord's
|
||||
*/
|
||||
@Test
|
||||
public void bug37630() throws Exception {
|
||||
HSSFWorkbook wb = openSample("37630.xls");
|
||||
@ -440,9 +471,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
//the first check with blank workbook
|
||||
HSSFWorkbook wb = openSample("Simple.xls");
|
||||
HSSFSheet sheet = wb.createSheet();
|
||||
for(int i = 1; i < 400; i++) {
|
||||
for (int i = 1; i < 400; i++) {
|
||||
HSSFRow row = sheet.getRow(i);
|
||||
if(row != null) {
|
||||
if (row != null) {
|
||||
row.getCell(0);
|
||||
}
|
||||
}
|
||||
@ -471,7 +502,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) {
|
||||
HSSFRow row = sheet.getRow(i);
|
||||
if (row != null) {
|
||||
HSSFCell cell = row .getCell(0);
|
||||
HSSFCell cell = row.getCell(0);
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
count++;
|
||||
}
|
||||
@ -535,7 +566,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
public void bug35564() throws Exception {
|
||||
HSSFWorkbook wb = openSample("35564.xls");
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt( 0 );
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
assertEquals(false, sheet.isGridsPrinted());
|
||||
assertEquals(false, sheet.getProtect());
|
||||
|
||||
@ -551,7 +582,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
public void bug35565() throws Exception {
|
||||
HSSFWorkbook wb = openSample("35565.xls");
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt( 0 );
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
assertNotNull(sheet);
|
||||
writeOutAndReadBack(wb).close();
|
||||
|
||||
@ -575,7 +606,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
public void bug40285() throws Exception {
|
||||
HSSFWorkbook wb = openSample("40285.xls");
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt( 0 );
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
int rownum = 0;
|
||||
for (Iterator<Row> it = sheet.rowIterator(); it.hasNext(); rownum++) {
|
||||
Row row = it.next();
|
||||
@ -591,7 +622,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
/**
|
||||
* Test bug 38266: NPE when adding a row break
|
||||
*
|
||||
* <p>
|
||||
* User's diagnosis:
|
||||
* 1. Manually (i.e., not using POI) create an Excel Workbook, making sure it
|
||||
* contains a sheet that doesn't have any row breaks
|
||||
@ -605,13 +636,13 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
for (String file : files) {
|
||||
HSSFWorkbook wb = openSample(file);
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt( 0 );
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
int[] breaks = sheet.getRowBreaks();
|
||||
assertEquals(0, breaks.length);
|
||||
|
||||
//add 3 row breaks
|
||||
for (int j = 1; j <= 3; j++) {
|
||||
sheet.setRowBreak(j*20);
|
||||
sheet.setRowBreak(j * 20);
|
||||
}
|
||||
wb.close();
|
||||
}
|
||||
@ -725,7 +756,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
// Formula Value
|
||||
HSSFRow r2 = s.getRow(1);
|
||||
HSSFCell c2 = r2.getCell(1);
|
||||
assertEquals(25, (int)c2.getNumericCellValue());
|
||||
assertEquals(25, (int) c2.getNumericCellValue());
|
||||
|
||||
try {
|
||||
assertEquals("CHOOSE(2,A2,A3,A4)", c2.getCellFormula());
|
||||
@ -827,7 +858,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Now check the iterator
|
||||
int rowsSeen = 0;
|
||||
for(Iterator<Row> i = s.rowIterator(); i.hasNext(); ) {
|
||||
for (Iterator<Row> i = s.rowIterator(); i.hasNext(); ) {
|
||||
Row r = i.next();
|
||||
assertNotNull(r);
|
||||
rowsSeen++;
|
||||
@ -863,7 +894,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
/**
|
||||
* Bug 44235: Ms Excel can't open save as excel file
|
||||
*
|
||||
* <p>
|
||||
* Works fine with poi-3.1-beta1.
|
||||
*/
|
||||
@Test
|
||||
@ -897,7 +928,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
* Problems with extracting check boxes from
|
||||
* HSSFObjectData
|
||||
*/
|
||||
@Test(expected=FileNotFoundException.class)
|
||||
@Test(expected = FileNotFoundException.class)
|
||||
public void bug44840() throws Exception {
|
||||
HSSFWorkbook wb = openSample("WithCheckBoxes.xls");
|
||||
|
||||
@ -967,7 +998,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
private void assertNames(HSSFWorkbook wb1, InternalWorkbook w) {
|
||||
for(int i=0; i<w.getNumNames(); i++) {
|
||||
for (int i = 0; i < w.getNumNames(); i++) {
|
||||
NameRecord r = w.getNameRecord(i);
|
||||
assertTrue(r.getSheetNumber() <= wb1.getNumberOfSheets());
|
||||
|
||||
@ -993,33 +1024,33 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
assertEquals(4, wb.getNumberOfFonts());
|
||||
|
||||
HSSFFont f1 = wb.getFontAt((short)0);
|
||||
HSSFFont f1 = wb.getFontAt((short) 0);
|
||||
assertFalse(f1.getBold());
|
||||
|
||||
// Check that asking for the same font
|
||||
// multiple times gives you the same thing.
|
||||
// Otherwise, our tests wouldn't work!
|
||||
assertSame(wb.getFontAt((short)0), wb.getFontAt((short)0));
|
||||
assertSame(wb.getFontAt((short) 0), wb.getFontAt((short) 0));
|
||||
assertEquals(
|
||||
wb.getFontAt((short)0),
|
||||
wb.getFontAt((short)0)
|
||||
wb.getFontAt((short) 0),
|
||||
wb.getFontAt((short) 0)
|
||||
);
|
||||
assertEquals(
|
||||
wb.getFontAt((short)2),
|
||||
wb.getFontAt((short)2)
|
||||
wb.getFontAt((short) 2),
|
||||
wb.getFontAt((short) 2)
|
||||
);
|
||||
assertTrue(
|
||||
wb.getFontAt((short)0)
|
||||
wb.getFontAt((short) 0)
|
||||
!=
|
||||
wb.getFontAt((short)2)
|
||||
wb.getFontAt((short) 2)
|
||||
);
|
||||
|
||||
// Look for a new font we have
|
||||
// yet to add
|
||||
assertNull(
|
||||
wb.findFont(
|
||||
false, (short)123, (short)22,
|
||||
"Thingy", false, true, (short)2, (byte)2
|
||||
false, (short) 123, (short) 22,
|
||||
"Thingy", false, true, (short) 2, (byte) 2
|
||||
)
|
||||
);
|
||||
|
||||
@ -1027,25 +1058,25 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(5, wb.getNumberOfFonts());
|
||||
|
||||
assertEquals(5, nf.getIndex());
|
||||
assertEquals(nf, wb.getFontAt((short)5));
|
||||
assertEquals(nf, wb.getFontAt((short) 5));
|
||||
|
||||
nf.setBold(false);
|
||||
nf.setColor((short)123);
|
||||
nf.setFontHeight((short)22);
|
||||
nf.setColor((short) 123);
|
||||
nf.setFontHeight((short) 22);
|
||||
nf.setFontName("Thingy");
|
||||
nf.setItalic(false);
|
||||
nf.setStrikeout(true);
|
||||
nf.setTypeOffset((short)2);
|
||||
nf.setUnderline((byte)2);
|
||||
nf.setTypeOffset((short) 2);
|
||||
nf.setUnderline((byte) 2);
|
||||
|
||||
assertEquals(5, wb.getNumberOfFonts());
|
||||
assertEquals(nf, wb.getFontAt((short)5));
|
||||
assertEquals(nf, wb.getFontAt((short) 5));
|
||||
|
||||
// Find it now
|
||||
assertNotNull(
|
||||
wb.findFont(
|
||||
false, (short)123, (short)22,
|
||||
"Thingy", false, true, (short)2, (byte)2
|
||||
false, (short) 123, (short) 22,
|
||||
"Thingy", false, true, (short) 2, (byte) 2
|
||||
)
|
||||
);
|
||||
HSSFFont font = wb.findFont(
|
||||
@ -1059,8 +1090,8 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
);
|
||||
assertEquals(nf,
|
||||
wb.findFont(
|
||||
false, (short)123, (short)22,
|
||||
"Thingy", false, true, (short)2, (byte)2
|
||||
false, (short) 123, (short) 22,
|
||||
"Thingy", false, true, (short) 2, (byte) 2
|
||||
)
|
||||
);
|
||||
|
||||
@ -1135,10 +1166,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
int i = 0;
|
||||
for (Iterator<CellValueRecordInterface> it = ns.getSheet().getCellValueIterator(); it.hasNext(); i++) {
|
||||
CellValueRecordInterface cvr = it.next();
|
||||
if(cvr instanceof FormulaRecordAggregate) {
|
||||
FormulaRecordAggregate fr = (FormulaRecordAggregate)cvr;
|
||||
if (cvr instanceof FormulaRecordAggregate) {
|
||||
FormulaRecordAggregate fr = (FormulaRecordAggregate) cvr;
|
||||
|
||||
if(i == 0) {
|
||||
if (i == 0) {
|
||||
assertEquals(70164.0, fr.getFormulaRecord().getValue(), 0.0001);
|
||||
assertNull(fr.getStringRecord());
|
||||
} else if (i == 1) {
|
||||
@ -1161,6 +1192,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(expectedValue, cell.getNumericCellValue(), 0.0);
|
||||
}
|
||||
|
||||
private static void confirmCachedValue(String expectedValue, HSSFCell cell) {
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(CellType.STRING, cell.getCachedFormulaResultTypeEnum());
|
||||
@ -1175,7 +1207,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
* {=sin(B1:B9){9,1)[rownum][0]
|
||||
* In this sample file, the vector column
|
||||
* is C, and the data column is B.
|
||||
*
|
||||
* <p>
|
||||
* Expected ExpPtg to be converted from Shared to Non-Shared...
|
||||
*/
|
||||
@Ignore("For now, blows up with an exception from ExtPtg")
|
||||
@ -1301,7 +1333,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
public void bug45322() throws Exception {
|
||||
HSSFWorkbook wb = openSample("44958.xls");
|
||||
HSSFSheet sh = wb.getSheetAt(0);
|
||||
for(short i=0; i < 30; i++) sh.autoSizeColumn(i);
|
||||
for (short i = 0; i < 30; i++) sh.autoSizeColumn(i);
|
||||
wb.close();
|
||||
}
|
||||
|
||||
@ -1508,17 +1540,16 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
/**
|
||||
* The link formulas which is referring to other books cannot be taken (the bug existed prior to POI-3.2)
|
||||
* Expected:
|
||||
*
|
||||
* <p>
|
||||
* [link_sub.xls]Sheet1!$A$1
|
||||
* [link_sub.xls]Sheet1!$A$2
|
||||
* [link_sub.xls]Sheet1!$A$3
|
||||
*
|
||||
* <p>
|
||||
* POI-3.1 output:
|
||||
*
|
||||
* <p>
|
||||
* Sheet1!$A$1
|
||||
* Sheet1!$A$2
|
||||
* Sheet1!$A$3
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void bug27364() throws Exception {
|
||||
@ -1596,7 +1627,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
HSSFITestDataProvider.instance.openWorkbookStream("46904.xls"));
|
||||
new HSSFWorkbook(fs.getRoot(), false).close();
|
||||
fail("Should catch exception here");
|
||||
} catch(OldExcelFormatException e) {
|
||||
} catch (OldExcelFormatException e) {
|
||||
assertTrue(e.getMessage().startsWith(
|
||||
"The supplied spreadsheet seems to be Excel"
|
||||
));
|
||||
@ -1610,7 +1641,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
} finally {
|
||||
fs.close();
|
||||
}
|
||||
} catch(OldExcelFormatException e) {
|
||||
} catch (OldExcelFormatException e) {
|
||||
assertTrue(e.getMessage().startsWith(
|
||||
"The supplied spreadsheet seems to be Excel"
|
||||
));
|
||||
@ -1751,7 +1782,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
public void bug46664() throws Exception {
|
||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||
HSSFSheet sheet = wb1.createSheet("new_sheet");
|
||||
HSSFRow row = sheet.createRow((short)0);
|
||||
HSSFRow row = sheet.createRow((short) 0);
|
||||
row.createCell(0).setCellValue(new HSSFRichTextString("Column A"));
|
||||
row.createCell(1).setCellValue(new HSSFRichTextString("Column B"));
|
||||
row.createCell(2).setCellValue(new HSSFRichTextString("Column C"));
|
||||
@ -1773,9 +1804,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Ensure the tab index
|
||||
TabIdRecord tr = null;
|
||||
for(Record r : wb2.getWorkbook().getRecords()) {
|
||||
if(r instanceof TabIdRecord) {
|
||||
tr = (TabIdRecord)r;
|
||||
for (Record r : wb2.getWorkbook().getRecords()) {
|
||||
if (r instanceof TabIdRecord) {
|
||||
tr = (TabIdRecord) r;
|
||||
}
|
||||
}
|
||||
assertNotNull(tr);
|
||||
@ -1796,7 +1827,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(1, nr.getNameDefinition().length);
|
||||
assertEquals(
|
||||
"new_sheet!$A$1:$C$1",
|
||||
((Area3DPtg)nr.getNameDefinition()[0]).toFormulaString(HSSFEvaluationWorkbook.create(wb2))
|
||||
((Area3DPtg) nr.getNameDefinition()[0]).toFormulaString(HSSFEvaluationWorkbook.create(wb2))
|
||||
);
|
||||
assertEquals('R', nr.getNameDefinition()[0].getRVAType());
|
||||
wb2.close();
|
||||
@ -1865,7 +1896,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
row = s.getRow(0);
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(),0);
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
row = s.getRow(1);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
@ -1946,7 +1977,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Add a new style, also rotated
|
||||
CellStyle cs = wb1.createCellStyle();
|
||||
cs.setRotation((short)0xff);
|
||||
cs.setRotation((short) 0xff);
|
||||
Cell nc = r.createCell(2);
|
||||
nc.setCellValue("New Rotated Text");
|
||||
nc.setCellStyle(cs);
|
||||
@ -2000,9 +2031,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
wb1.close();
|
||||
|
||||
// Re-check
|
||||
assertEquals("Testing", wb2.getCellStyleAt((short)21).getUserStyleName());
|
||||
assertEquals("Testing 2", wb2.getCellStyleAt((short)22).getUserStyleName());
|
||||
assertEquals("Testing 3", wb2.getCellStyleAt((short)23).getUserStyleName());
|
||||
assertEquals("Testing", wb2.getCellStyleAt((short) 21).getUserStyleName());
|
||||
assertEquals("Testing 2", wb2.getCellStyleAt((short) 22).getUserStyleName());
|
||||
assertEquals("Testing 3", wb2.getCellStyleAt((short) 23).getUserStyleName());
|
||||
|
||||
wb2.close();
|
||||
}
|
||||
@ -2089,13 +2120,13 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet("Bug50416");
|
||||
Row row1 = sheet.createRow(0);
|
||||
Cell cellA_1 = row1.createCell(0,CellType.STRING);
|
||||
Cell cellA_1 = row1.createCell(0, CellType.STRING);
|
||||
cellA_1.setCellValue("Cell A,1");
|
||||
Row row2 = sheet.createRow(1);
|
||||
Cell cellA_2 = row2.createCell(0,CellType.STRING);
|
||||
Cell cellA_2 = row2.createCell(0, CellType.STRING);
|
||||
cellA_2.setCellValue("Cell A,2");
|
||||
Row row3 = sheet.createRow(2);
|
||||
Cell cellA_3 = row3.createCell(0,CellType.STRING);
|
||||
Cell cellA_3 = row3.createCell(0, CellType.STRING);
|
||||
cellA_3.setCellValue("Cell A,3");
|
||||
|
||||
// Test the last Row number it currently correct
|
||||
@ -2284,11 +2315,11 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
HSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
|
||||
assertEquals("HOUR(A1)", s.getRow(5).getCell(0).getCellFormula());
|
||||
assertEquals(11.0+6.0, s.getRow(5).getCell(0).getNumericCellValue(), 0);
|
||||
assertEquals(11.0 + 6.0, s.getRow(5).getCell(0).getNumericCellValue(), 0);
|
||||
assertEquals("MINUTE(A1)", s.getRow(6).getCell(0).getCellFormula());
|
||||
assertEquals(39.0+14.0+1, s.getRow(6).getCell(0).getNumericCellValue(), 0);
|
||||
assertEquals(39.0 + 14.0 + 1, s.getRow(6).getCell(0).getNumericCellValue(), 0);
|
||||
assertEquals("SECOND(A1)", s.getRow(7).getCell(0).getCellFormula());
|
||||
assertEquals(54.0+24.0-60, s.getRow(7).getCell(0).getNumericCellValue(), 0);
|
||||
assertEquals(54.0 + 24.0 - 60, s.getRow(7).getCell(0).getNumericCellValue(), 0);
|
||||
|
||||
wb.close();
|
||||
} finally {
|
||||
@ -2342,7 +2373,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new NPOIFSFileSystem(
|
||||
new ByteArrayInputStream(data)).getRoot(), false);
|
||||
|
||||
for(HSSFWorkbook wb : new HSSFWorkbook[] {wbPOIFS, wbNPOIFS}) {
|
||||
for (HSSFWorkbook wb : new HSSFWorkbook[]{wbPOIFS, wbNPOIFS}) {
|
||||
assertEquals(3, wb.getNumberOfSheets());
|
||||
|
||||
// Check directly
|
||||
@ -2398,7 +2429,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
* Normally encrypted files have BOF then FILEPASS, but
|
||||
* some may squeeze a WRITEPROTECT in the middle
|
||||
*/
|
||||
@Test(expected=EncryptedDocumentException.class)
|
||||
@Test(expected = EncryptedDocumentException.class)
|
||||
public void bug51832() {
|
||||
openSample("51832.xls");
|
||||
}
|
||||
@ -2408,8 +2439,8 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
HSSFWorkbook wb = openSample("49896.xls");
|
||||
HSSFCell cell = wb.getSheetAt(0).getRow(1).getCell(1);
|
||||
String PATH_SEPARATOR = System.getProperty("file.separator");
|
||||
assertEquals("VLOOKUP(A2,'[C:Documents and Settings" + PATH_SEPARATOR+"Yegor"+PATH_SEPARATOR
|
||||
+"My Documents"+PATH_SEPARATOR+"csco.xls]Sheet1'!$A$2:$B$3,2,FALSE)",
|
||||
assertEquals("VLOOKUP(A2,'[C:Documents and Settings" + PATH_SEPARATOR + "Yegor" + PATH_SEPARATOR
|
||||
+ "My Documents" + PATH_SEPARATOR + "csco.xls]Sheet1'!$A$2:$B$3,2,FALSE)",
|
||||
cell.getCellFormula());
|
||||
wb.close();
|
||||
}
|
||||
@ -2468,13 +2499,13 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
list.add(r.getSid());
|
||||
}
|
||||
});
|
||||
assertEquals(UnknownRecord.BITMAP_00E9, list.get(list.size()-1).intValue());
|
||||
assertEquals(UnknownRecord.HEADER_FOOTER_089C, list.get(list.size()-2).intValue());
|
||||
assertEquals(UnknownRecord.BITMAP_00E9, list.get(list.size() - 1).intValue());
|
||||
assertEquals(UnknownRecord.HEADER_FOOTER_089C, list.get(list.size() - 2).intValue());
|
||||
wb.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug52272() throws IOException{
|
||||
public void bug52272() throws IOException {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
HSSFPatriarch p = sh.createDrawingPatriarch();
|
||||
@ -2489,9 +2520,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug53432() throws IOException{
|
||||
public void bug53432() throws IOException {
|
||||
Workbook wb1 = new HSSFWorkbook(); //or new HSSFWorkbook();
|
||||
wb1.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG);
|
||||
wb1.addPicture(new byte[]{123, 22}, Workbook.PICTURE_TYPE_JPEG);
|
||||
assertEquals(wb1.getAllPictures().size(), 1);
|
||||
wb1.close();
|
||||
|
||||
@ -2501,7 +2532,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
Workbook wb2 = writeOutAndReadBack((HSSFWorkbook) wb1);
|
||||
wb1.close();
|
||||
assertEquals(wb2.getAllPictures().size(), 0);
|
||||
wb2.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG);
|
||||
wb2.addPicture(new byte[]{123, 22}, Workbook.PICTURE_TYPE_JPEG);
|
||||
assertEquals(wb2.getAllPictures().size(), 1);
|
||||
|
||||
Workbook wb3 = writeOutAndReadBack((HSSFWorkbook) wb2);
|
||||
@ -2521,7 +2552,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
HSSFTextbox tb = (HSSFTextbox) patriarch.getChildren().get(2);
|
||||
|
||||
tb.setString(new HSSFRichTextString("POI test"));
|
||||
tb.setAnchor(new HSSFClientAnchor(0,0,0,0,(short)0,0,(short)10,10));
|
||||
tb.setAnchor(new HSSFClientAnchor(0, 0, 0, 0, (short) 0, 0, (short) 10, 10));
|
||||
|
||||
writeOutAndReadBack(wb).close();
|
||||
|
||||
@ -2559,7 +2590,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
wb.close();
|
||||
}
|
||||
|
||||
/** Row style information is 12 not 16 bits */
|
||||
/**
|
||||
* Row style information is 12 not 16 bits
|
||||
*/
|
||||
@Test
|
||||
public void bug49237() throws Exception {
|
||||
Workbook wb = openSample("49237.xls");
|
||||
@ -2571,8 +2604,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
wb.close();
|
||||
}
|
||||
|
||||
/** POI doesn't currently support the RC4 CryptoAPI encryption header structure */
|
||||
@Test(expected=EncryptedDocumentException.class)
|
||||
/**
|
||||
* POI doesn't currently support the RC4 CryptoAPI encryption header structure
|
||||
*/
|
||||
@Test(expected = EncryptedDocumentException.class)
|
||||
public void bug35897() throws Exception {
|
||||
// password is abc
|
||||
try {
|
||||
@ -2711,7 +2746,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
// Try to evaluate them
|
||||
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
|
||||
assertEquals("Test A1", eval.evaluate(cRefSName).getStringValue());
|
||||
assertEquals(142, (int)eval.evaluate(cRefWName).getNumberValue());
|
||||
assertEquals(142, (int) eval.evaluate(cRefWName).getNumberValue());
|
||||
|
||||
// Try to evaluate everything
|
||||
eval.evaluateAll();
|
||||
@ -2724,7 +2759,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
*/
|
||||
@Test
|
||||
public void bug54443() throws Exception {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook( );
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFCellStyle style = workbook.createCellStyle();
|
||||
HSSFCellStyle newStyle = workbook.createCellStyle();
|
||||
|
||||
@ -2760,8 +2795,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
if (null == expectedResultOrNull) {
|
||||
assertEquals(CellType.ERROR, intF.getCachedFormulaResultTypeEnum());
|
||||
expectedResultOrNull = "#VALUE!";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultTypeEnum());
|
||||
}
|
||||
|
||||
@ -2776,7 +2810,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
public void bug42016() throws Exception {
|
||||
Workbook wb = openSample("42016.xls");
|
||||
Sheet s = wb.getSheetAt(0);
|
||||
for(int row = 0;row < 7;row++) {
|
||||
for (int row = 0; row < 7; row++) {
|
||||
assertEquals("A$1+B$1", s.getRow(row).getCell(2).getCellFormula());
|
||||
}
|
||||
wb.close();
|
||||
@ -2928,10 +2962,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
||||
|
||||
for(int i = 0;i < wb.getNumberOfSheets();i++) {
|
||||
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
|
||||
Sheet sheet = wb.getSheetAt(i);
|
||||
for(Row row : sheet) {
|
||||
for(Cell cell : row) {
|
||||
for (Row row : sheet) {
|
||||
for (Cell cell : row) {
|
||||
new DataFormatter().formatCellValue(cell);
|
||||
}
|
||||
}
|
||||
@ -2961,7 +2995,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
ByteArrayOutputStream imageBAOS = new ByteArrayOutputStream();
|
||||
ImageIO.write(bimage, "jpeg", imageBAOS);
|
||||
imageBAOS.flush();
|
||||
byte[]imageBytes = imageBAOS.toByteArray();
|
||||
byte[] imageBytes = imageBAOS.toByteArray();
|
||||
imageBAOS.close();
|
||||
|
||||
// Pop structure into Structure HSSFSheet
|
||||
@ -3024,17 +3058,17 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
shape = new HSSFTextbox(null, anchor);
|
||||
shape.setShapeId(1025);
|
||||
cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
|
||||
cmo = (CommonObjectDataSubRecord) shape.getObjRecord().getSubRecords().get(0);
|
||||
assertEquals(1, cmo.getObjectId());
|
||||
|
||||
shape = new HSSFPicture(null, anchor);
|
||||
shape.setShapeId(1026);
|
||||
cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
|
||||
cmo = (CommonObjectDataSubRecord) shape.getObjRecord().getSubRecords().get(0);
|
||||
assertEquals(2, cmo.getObjectId());
|
||||
|
||||
shape = new HSSFComment(null, anchor);
|
||||
shape.setShapeId(1027);
|
||||
cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
|
||||
cmo = (CommonObjectDataSubRecord) shape.getObjRecord().getSubRecords().get(0);
|
||||
assertEquals(1027, cmo.getObjectId());
|
||||
}
|
||||
|
||||
@ -3099,7 +3133,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
@Test
|
||||
public void test61287() throws IOException {
|
||||
final Workbook wb = HSSFTestDataSamples.openSampleWorkbook("61287.xls");
|
||||
ExcelExtractor ex = new ExcelExtractor((HSSFWorkbook)wb);
|
||||
ExcelExtractor ex = new ExcelExtractor((HSSFWorkbook) wb);
|
||||
String text = ex.getText();
|
||||
assertContains(text, "\u8D44\u4EA7\u8D1F\u503A\u8868");
|
||||
wb.close();
|
||||
|
Loading…
Reference in New Issue
Block a user