Reformat code somewhat
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1795962 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7881d05743
commit
8564aa7bb6
@ -287,7 +287,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
* NameXPtgs.
|
||||
* Blows up on:
|
||||
* IF(B6= (ROUNDUP(B6,0) + ROUNDDOWN(B6,0))/2, MROUND(B6,2),ROUND(B6,0))
|
||||
*
|
||||
* <p>
|
||||
* TODO: delete this test case when MROUND and VAR are implemented
|
||||
*/
|
||||
@Test
|
||||
@ -299,14 +299,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Try each cell individually
|
||||
XSSFFormulaEvaluator eval = new XSSFFormulaEvaluator(wb);
|
||||
for(int i=0; i<wb.getNumberOfSheets(); i++) {
|
||||
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
|
||||
Sheet s = wb.getSheetAt(i);
|
||||
for(Row r : s) {
|
||||
for(Cell c : r) {
|
||||
if(c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
for (Row r : s) {
|
||||
for (Cell c : r) {
|
||||
if (c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
CellValue cv = eval.evaluate(c);
|
||||
|
||||
if(cv.getCellTypeEnum() == CellType.NUMERIC) {
|
||||
if (cv.getCellTypeEnum() == CellType.NUMERIC) {
|
||||
// assert that the calculated value agrees with
|
||||
// the cached formula result calculated by Excel
|
||||
String formula = c.getCellFormula();
|
||||
@ -406,7 +406,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
* output as an .xlsx file) that have two issues:
|
||||
* 1. The Content Type part name is lower-case: [content_types].xml
|
||||
* 2. The file appears to use backslashes as path separators
|
||||
*
|
||||
* <p>
|
||||
* The OPC spec tolerates both of these peculiarities, so does POI
|
||||
*/
|
||||
@Test
|
||||
@ -544,7 +544,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
wb.write(b2);
|
||||
wb.write(b3);
|
||||
|
||||
for(byte[] data : new byte[][] {
|
||||
for (byte[] data : new byte[][]{
|
||||
b1.toByteArray(), b2.toByteArray(), b3.toByteArray()
|
||||
}) {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||
@ -631,9 +631,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
private void validateCells(XSSFSheet sheet) {
|
||||
for(Row row : sheet) {
|
||||
for (Row row : sheet) {
|
||||
// trigger handling
|
||||
((XSSFRow)row).onDocumentWrite();
|
||||
((XSSFRow) row).onDocumentWrite();
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,9 +643,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
for(Row row : sheet){
|
||||
for(Cell cell : row){
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA){
|
||||
for (Row row : sheet) {
|
||||
for (Cell cell : row) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
formulaEvaluator.evaluateInCell(cell); // caused NPE on some cells
|
||||
}
|
||||
}
|
||||
@ -750,12 +750,12 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
|
||||
|
||||
// Check all the colours
|
||||
for(int sn=0; sn<wb.getNumberOfSheets(); sn++) {
|
||||
for (int sn = 0; sn < wb.getNumberOfSheets(); sn++) {
|
||||
Sheet s = wb.getSheetAt(sn);
|
||||
for(Row r : s) {
|
||||
for(Cell c : r) {
|
||||
for (Row r : s) {
|
||||
for (Cell c : r) {
|
||||
CellStyle cs = c.getCellStyle();
|
||||
if(cs != null) {
|
||||
if (cs != null) {
|
||||
cs.getFillForegroundColor();
|
||||
}
|
||||
}
|
||||
@ -838,22 +838,22 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Column 1 has a font with regular colours
|
||||
XSSFCell cr = r.getCell(1);
|
||||
XSSFFont fr = wb.getFontAt( cr.getCellStyle().getFontIndex() );
|
||||
XSSFFont fr = wb.getFontAt(cr.getCellStyle().getFontIndex());
|
||||
XSSFColor colr = fr.getXSSFColor();
|
||||
// No theme, has colours
|
||||
assertEquals(0, colr.getTheme());
|
||||
assertNotNull( colr.getRGB() );
|
||||
assertNotNull(colr.getRGB());
|
||||
|
||||
// Column 0 has a font with colours from a theme
|
||||
XSSFCell ct = r.getCell(0);
|
||||
XSSFFont ft = wb.getFontAt( ct.getCellStyle().getFontIndex() );
|
||||
XSSFFont ft = wb.getFontAt(ct.getCellStyle().getFontIndex());
|
||||
XSSFColor colt = ft.getXSSFColor();
|
||||
// Has a theme, which has the colours on it
|
||||
assertEquals(9, colt.getTheme());
|
||||
XSSFColor themeC = wb.getTheme().getThemeColor(colt.getTheme());
|
||||
assertNotNull( themeC.getRGB() );
|
||||
assertNotNull( colt.getRGB() );
|
||||
assertEquals( themeC.getARGBHex(), colt.getARGBHex() ); // The same colour
|
||||
assertNotNull(themeC.getRGB());
|
||||
assertNotNull(colt.getRGB());
|
||||
assertEquals(themeC.getARGBHex(), colt.getARGBHex()); // The same colour
|
||||
wb.close();
|
||||
}
|
||||
|
||||
@ -873,7 +873,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
font1.setColor((short) 20);
|
||||
Font font2 = wb1.createFont();
|
||||
font2.setColor(Font.COLOR_RED);
|
||||
Font font3 = wb1.getFontAt((short)0);
|
||||
Font font3 = wb1.getFontAt((short) 0);
|
||||
|
||||
XSSFRow row = sheet.createRow(2);
|
||||
XSSFCell cell = row.createCell(2);
|
||||
@ -907,14 +907,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Now add a 2nd, and check again
|
||||
int fontAt = text.indexOf("\n", 6);
|
||||
cell.getRichStringCellValue().applyFont(10, fontAt+1, font2);
|
||||
cell.getRichStringCellValue().applyFont(10, fontAt + 1, font2);
|
||||
assertEquals(text, cell.getStringCellValue());
|
||||
|
||||
assertEquals(4, cell.getRichStringCellValue().numFormattingRuns());
|
||||
assertEquals("Use", cell.getRichStringCellValue().getCTRst().getRArray(0).getT());
|
||||
|
||||
String r3 = cell.getRichStringCellValue().getCTRst().getRArray(2).getT();
|
||||
assertEquals("line.\n", r3.substring(r3.length()-6));
|
||||
assertEquals("line.\n", r3.substring(r3.length() - 6));
|
||||
|
||||
// Save and re-check
|
||||
XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
|
||||
@ -1106,7 +1106,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet s = wb.createSheet();
|
||||
|
||||
CellStyle defaultStyle = wb.getCellStyleAt((short)0);
|
||||
CellStyle defaultStyle = wb.getCellStyleAt((short) 0);
|
||||
assertEquals(0, defaultStyle.getIndex());
|
||||
|
||||
CellStyle blueStyle = wb.createCellStyle();
|
||||
@ -1390,7 +1390,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
public void bug51710() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51710.xlsx");
|
||||
|
||||
final String[] columns = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N"};
|
||||
final String[] columns = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"};
|
||||
final int rowMax = 500; // bug triggers on row index 59
|
||||
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
@ -1442,7 +1442,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
@Test
|
||||
public void bug54436() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("54436.xlsx");
|
||||
if(!WorkbookEvaluator.getSupportedFunctionNames().contains("GETPIVOTDATA")){
|
||||
if (!WorkbookEvaluator.getSupportedFunctionNames().contains("GETPIVOTDATA")) {
|
||||
Function func = new Function() {
|
||||
@Override
|
||||
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
|
||||
@ -1460,7 +1460,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
* Password Protected .xlsx files should give a helpful
|
||||
* error message when called via WorkbookFactory with no password
|
||||
*/
|
||||
@Test(expected=EncryptedDocumentException.class)
|
||||
@Test(expected = EncryptedDocumentException.class)
|
||||
public void bug55692_poifs() throws IOException {
|
||||
// Via a POIFSFileSystem
|
||||
POIFSFileSystem fsP = new POIFSFileSystem(
|
||||
@ -1545,8 +1545,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
// dates stored.
|
||||
// We try to do a loop until the current second changes in order to avoid problems with some date information that is written to the ZIP and thus
|
||||
// causes differences
|
||||
long start = System.currentTimeMillis()/1000;
|
||||
while(System.currentTimeMillis()/1000 == start) {
|
||||
long start = System.currentTimeMillis() / 1000;
|
||||
while (System.currentTimeMillis() / 1000 == start) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
|
||||
@ -1669,7 +1669,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
saveAndReloadReport(wb, xlsOutput);
|
||||
|
||||
newCell.setCellValue("new Cell in row "+newRow.getRowNum());
|
||||
newCell.setCellValue("new Cell in row " + newRow.getRowNum());
|
||||
|
||||
saveAndReloadReport(wb, xlsOutput);
|
||||
|
||||
@ -1744,7 +1744,7 @@ public final class TestXSSFBugs 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();
|
||||
@ -1755,9 +1755,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
// run some method on the font to verify if it is "disconnected" already
|
||||
//for(short i = 0;i < 256;i++)
|
||||
{
|
||||
Font font = wb.getFontAt((short)0);
|
||||
if(font instanceof XSSFFont) {
|
||||
XSSFFont xfont = (XSSFFont) wb.getFontAt((short)0);
|
||||
Font font = wb.getFontAt((short) 0);
|
||||
if (font instanceof XSSFFont) {
|
||||
XSSFFont xfont = (XSSFFont) wb.getFontAt((short) 0);
|
||||
CTFontImpl ctFont = (CTFontImpl) xfont.getCTFont();
|
||||
assertEquals(0, ctFont.sizeOfBArray());
|
||||
}
|
||||
@ -1774,11 +1774,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
try {
|
||||
Workbook newWB = null;
|
||||
try {
|
||||
if(wb instanceof XSSFWorkbook) {
|
||||
if (wb instanceof XSSFWorkbook) {
|
||||
newWB = new XSSFWorkbook(is);
|
||||
} else if(wb instanceof HSSFWorkbook) {
|
||||
} else if (wb instanceof HSSFWorkbook) {
|
||||
newWB = new HSSFWorkbook(is);
|
||||
} else if(wb instanceof SXSSFWorkbook) {
|
||||
} else if (wb instanceof SXSSFWorkbook) {
|
||||
newWB = new SXSSFWorkbook(new XSSFWorkbook(is));
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown workbook: " + wb);
|
||||
@ -1903,7 +1903,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
try {
|
||||
new XSSFWorkbook(pkg).close();
|
||||
fail("Should fail as too much expansion occurs");
|
||||
} catch(POIXMLException e) {
|
||||
} catch (POIXMLException e) {
|
||||
// Expected
|
||||
}
|
||||
pkg.close();
|
||||
@ -1912,7 +1912,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
try {
|
||||
XSSFTestDataSamples.openSamplePackage("54764-2.xlsx").close();
|
||||
fail("Should fail as too much expansion occurs");
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
@ -1990,7 +1990,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
public void testBug57196() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57196.xlsx");
|
||||
Sheet sheet = wb.getSheet("Feuil1");
|
||||
Row mod=sheet.getRow(1);
|
||||
Row mod = sheet.getRow(1);
|
||||
mod.getCell(1).setCellValue(3);
|
||||
HSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
|
||||
// FileOutputStream fileOutput = new FileOutputStream("/tmp/57196.xlsx");
|
||||
@ -2099,7 +2099,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
wb.close();
|
||||
} finally {
|
||||
if(previousLogger == null) {
|
||||
if (previousLogger == null) {
|
||||
System.clearProperty("org.apache.poi.util.POILogger");
|
||||
} else {
|
||||
System.setProperty("org.apache.poi.util.POILogger", previousLogger);
|
||||
@ -2115,7 +2115,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
public void bug57482() throws IOException, InvalidFormatException {
|
||||
for (PackageAccess access : new PackageAccess[] {
|
||||
for (PackageAccess access : new PackageAccess[]{
|
||||
PackageAccess.READ_WRITE, PackageAccess.READ
|
||||
}) {
|
||||
File file = HSSFTestDataSamples.getSampleFile("57482-OnlyNumeric.xlsx");
|
||||
@ -2226,13 +2226,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeAllSheetsBut(int sheetIndex, Workbook wb)
|
||||
{
|
||||
private static void removeAllSheetsBut(int sheetIndex, Workbook wb) {
|
||||
int sheetNb = wb.getNumberOfSheets();
|
||||
// Move this sheet at the first position
|
||||
wb.setSheetOrder(wb.getSheetName(sheetIndex), 0);
|
||||
for (int sn = sheetNb - 1; sn > 0; sn--)
|
||||
{
|
||||
for (int sn = sheetNb - 1; sn > 0; sn--) {
|
||||
wb.removeSheetAt(sn);
|
||||
}
|
||||
}
|
||||
@ -2255,7 +2253,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
/**
|
||||
* Expected:
|
||||
|
||||
* <p>
|
||||
* [ 0][ 2][ 4]
|
||||
*/
|
||||
@Test
|
||||
@ -2283,7 +2281,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
/**
|
||||
* Expected:
|
||||
|
||||
* <p>
|
||||
* [ 0] <- number
|
||||
* [ 2] <- formula
|
||||
* [ 4] <- formula
|
||||
@ -2417,7 +2415,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(1, shapes.size());
|
||||
assertTrue(shapes.get(0) instanceof XSSFSimpleShape);
|
||||
|
||||
XSSFSimpleShape shape = (XSSFSimpleShape)shapes.get(0);
|
||||
XSSFSimpleShape shape = (XSSFSimpleShape) shapes.get(0);
|
||||
|
||||
// Used to throw a NPE
|
||||
String text = shape.getText();
|
||||
@ -2470,7 +2468,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
public void bug57880() throws IOException {
|
||||
int numStyles = 33000;
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
for (int i=1; i<numStyles; i++) {
|
||||
for (int i = 1; i < numStyles; i++) {
|
||||
// Create a style and use it
|
||||
XSSFCellStyle style = wb.createCellStyle();
|
||||
assertEquals(i, style.getUIndex());
|
||||
@ -2493,7 +2491,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
//If XSSFWorkbooks ever implicitly optimize/consolidate cell styles (such as when the workbook is written to disk)
|
||||
//then this unit test should be updated
|
||||
assertEquals(numStyles, wb.getNumCellStyles());
|
||||
for (int i=1; i<numStyles; i++) {
|
||||
for (int i = 1; i < numStyles; i++) {
|
||||
XSSFCellStyle style = wb.getCellStyleAt(i);
|
||||
assertNotNull(style);
|
||||
assertEquals(i, style.getUIndex());
|
||||
@ -2516,16 +2514,16 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
Map<String, Object[]> data;
|
||||
data = new TreeMap<String, Object[]>();
|
||||
data.put("1", new Object[] {"ID", "NAME", "LASTNAME"});
|
||||
data.put("2", new Object[] {2, "Amit", "Shukla"});
|
||||
data.put("3", new Object[] {1, "Lokesh", "Gupta"});
|
||||
data.put("4", new Object[] {4, "John", "Adwards"});
|
||||
data.put("5", new Object[] {2, "Brian", "Schultz"});
|
||||
data.put("1", new Object[]{"ID", "NAME", "LASTNAME"});
|
||||
data.put("2", new Object[]{2, "Amit", "Shukla"});
|
||||
data.put("3", new Object[]{1, "Lokesh", "Gupta"});
|
||||
data.put("4", new Object[]{4, "John", "Adwards"});
|
||||
data.put("5", new Object[]{2, "Brian", "Schultz"});
|
||||
|
||||
int rownum = 1;
|
||||
for (Map.Entry<String,Object[]> me : data.entrySet()) {
|
||||
for (Map.Entry<String, Object[]> me : data.entrySet()) {
|
||||
final Row row;
|
||||
if(createRow) {
|
||||
if (createRow) {
|
||||
row = sheet.createRow(rownum++);
|
||||
} else {
|
||||
row = sheet.getRow(rownum++);
|
||||
@ -2535,18 +2533,18 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
int cellnum = 0;
|
||||
for (Object obj : me.getValue()) {
|
||||
Cell cell = row.getCell(cellnum);
|
||||
if(cell == null){
|
||||
if (cell == null) {
|
||||
cell = row.createCell(cellnum);
|
||||
} else {
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
cell.setCellFormula(null);
|
||||
cell.getCellStyle().setDataFormat((short) 0);
|
||||
}
|
||||
}
|
||||
if(obj instanceof String) {
|
||||
cell.setCellValue((String)obj);
|
||||
} else if(obj instanceof Integer) {
|
||||
cell.setCellValue((Integer)obj);
|
||||
if (obj instanceof String) {
|
||||
cell.setCellValue((String) obj);
|
||||
} else if (obj instanceof Integer) {
|
||||
cell.setCellValue((Integer) obj);
|
||||
}
|
||||
cellnum++;
|
||||
}
|
||||
@ -2555,8 +2553,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
XSSFFormulaEvaluator.evaluateAllFormulaCells((XSSFWorkbook) wb);
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
||||
|
||||
CalculationChain chain = ((XSSFWorkbook)wb).getCalculationChain();
|
||||
for(CTCalcCell calc : chain.getCTCalcChain().getCList()) {
|
||||
CalculationChain chain = ((XSSFWorkbook) wb).getCalculationChain();
|
||||
for (CTCalcCell calc : chain.getCTCalcChain().getCList()) {
|
||||
// A2 to A6 should be gone
|
||||
assertFalse(calc.getR().equals("A2"));
|
||||
assertFalse(calc.getR().equals("A3"));
|
||||
@ -2569,8 +2567,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
Sheet sheetBack = wbBack.getSheet("Func");
|
||||
assertNotNull(sheetBack);
|
||||
|
||||
chain = ((XSSFWorkbook)wbBack).getCalculationChain();
|
||||
for(CTCalcCell calc : chain.getCTCalcChain().getCList()) {
|
||||
chain = ((XSSFWorkbook) wbBack).getCalculationChain();
|
||||
for (CTCalcCell calc : chain.getCTCalcChain().getCList()) {
|
||||
// A2 to A6 should be gone
|
||||
assertFalse(calc.getR().equals("A2"));
|
||||
assertFalse(calc.getR().equals("A3"));
|
||||
@ -2608,8 +2606,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
if (null == expectedResultOrNull) {
|
||||
assertEquals(CellType.ERROR, intF.getCachedFormulaResultTypeEnum());
|
||||
expectedResultOrNull = "#VALUE!";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultTypeEnum());
|
||||
}
|
||||
|
||||
@ -2632,7 +2629,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// color index
|
||||
assertEquals(64, style.getFillBackgroundColor());
|
||||
XSSFColor color = ((XSSFCellStyle)style).getFillBackgroundXSSFColor();
|
||||
XSSFColor color = ((XSSFCellStyle) style).getFillBackgroundXSSFColor();
|
||||
assertNotNull(color);
|
||||
|
||||
// indexed color
|
||||
@ -2649,9 +2646,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
public void test50755_workday_formula_example() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50755_workday_formula_example.xlsx");
|
||||
Sheet sheet = wb.getSheet("Sheet1");
|
||||
for(Row aRow : sheet) {
|
||||
for (Row aRow : sheet) {
|
||||
Cell cell = aRow.getCell(1);
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
String formula = cell.getCellFormula();
|
||||
//System.out.println("formula: " + formula);
|
||||
assertNotNull(formula);
|
||||
@ -2752,9 +2749,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
Cell cellA2 = sheet.getRow(1).getCell(0);
|
||||
|
||||
assertEquals(0, cellA1.getCellStyle().getFillForegroundColor());
|
||||
assertEquals("FFFDFDFD", ((XSSFColor)cellA1.getCellStyle().getFillForegroundColorColor()).getARGBHex());
|
||||
assertEquals("FFFDFDFD", ((XSSFColor) cellA1.getCellStyle().getFillForegroundColorColor()).getARGBHex());
|
||||
assertEquals(0, cellA2.getCellStyle().getFillForegroundColor());
|
||||
assertEquals("FFFDFDFD", ((XSSFColor)cellA2.getCellStyle().getFillForegroundColorColor()).getARGBHex());
|
||||
assertEquals("FFFDFDFD", ((XSSFColor) cellA2.getCellStyle().getFillForegroundColorColor()).getARGBHex());
|
||||
|
||||
SheetConditionalFormatting cond = sheet.getSheetConditionalFormatting();
|
||||
assertEquals(2, cond.getNumConditionalFormattings());
|
||||
@ -2762,12 +2759,12 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(1, cond.getConditionalFormattingAt(0).getNumberOfRules());
|
||||
assertEquals(64, cond.getConditionalFormattingAt(0).getRule(0).getPatternFormatting().getFillForegroundColor());
|
||||
assertEquals("ISEVEN(ROW())", cond.getConditionalFormattingAt(0).getRule(0).getFormula1());
|
||||
assertNull(((XSSFColor)cond.getConditionalFormattingAt(0).getRule(0).getPatternFormatting().getFillForegroundColorColor()).getARGBHex());
|
||||
assertNull(((XSSFColor) cond.getConditionalFormattingAt(0).getRule(0).getPatternFormatting().getFillForegroundColorColor()).getARGBHex());
|
||||
|
||||
assertEquals(1, cond.getConditionalFormattingAt(1).getNumberOfRules());
|
||||
assertEquals(64, cond.getConditionalFormattingAt(1).getRule(0).getPatternFormatting().getFillForegroundColor());
|
||||
assertEquals("ISEVEN(ROW())", cond.getConditionalFormattingAt(1).getRule(0).getFormula1());
|
||||
assertNull(((XSSFColor)cond.getConditionalFormattingAt(1).getRule(0).getPatternFormatting().getFillForegroundColorColor()).getARGBHex());
|
||||
assertNull(((XSSFColor) cond.getConditionalFormattingAt(1).getRule(0).getPatternFormatting().getFillForegroundColorColor()).getARGBHex());
|
||||
|
||||
wb.close();
|
||||
}
|
||||
@ -2778,13 +2775,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
Set<String> sheetNames = new HashSet<String>();
|
||||
|
||||
for (int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++)
|
||||
{
|
||||
for (int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
|
||||
sheetNames.add(wb.getSheetName(sheetNum));
|
||||
}
|
||||
|
||||
for (String sheetName : sheetNames)
|
||||
{
|
||||
for (String sheetName : sheetNames) {
|
||||
int sheetIndex = wb.getSheetIndex(sheetName);
|
||||
|
||||
wb.removeSheetAt(sheetIndex);
|
||||
@ -2872,11 +2867,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
DataFormatter formatter = new DataFormatter(true);
|
||||
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57236.xlsx");
|
||||
for(int sheetNum = 0;sheetNum < wb.getNumberOfSheets();sheetNum++) {
|
||||
for (int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
|
||||
Sheet sheet = wb.getSheetAt(sheetNum);
|
||||
for(int rowNum = sheet.getFirstRowNum();rowNum < sheet.getLastRowNum();rowNum++) {
|
||||
for (int rowNum = sheet.getFirstRowNum(); rowNum < sheet.getLastRowNum(); rowNum++) {
|
||||
Row row = sheet.getRow(rowNum);
|
||||
for(int cellNum = row.getFirstCellNum();cellNum < row.getLastCellNum();cellNum++) {
|
||||
for (int cellNum = row.getFirstCellNum(); cellNum < row.getLastCellNum(); cellNum++) {
|
||||
Cell cell = row.getCell(cellNum);
|
||||
String fmtCellValue = formatter.formatCellValue(cell);
|
||||
|
||||
@ -2890,8 +2885,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
wb.close();
|
||||
}
|
||||
|
||||
private void createXls() throws IOException
|
||||
{
|
||||
private void createXls() throws IOException {
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
FileOutputStream fileOut = new FileOutputStream("/tmp/rotated.xls");
|
||||
Sheet sheet1 = workbook.createSheet();
|
||||
@ -2947,7 +2941,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
Row row = worksheet.getRow(2);
|
||||
Cell cell = row.getCell(1);
|
||||
|
||||
cell.setCellValue((String)null);
|
||||
cell.setCellValue((String) null);
|
||||
|
||||
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
|
||||
|
||||
@ -3066,7 +3060,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
public void noRowNumbers59746() {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("59746_NoRowNums.xlsx");
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
assertTrue("Last row num: "+sheet.getLastRowNum(), sheet.getLastRowNum()>20);
|
||||
assertTrue("Last row num: " + sheet.getLastRowNum(), sheet.getLastRowNum() > 20);
|
||||
assertEquals("Checked", sheet.getRow(0).getCell(0).getStringCellValue());
|
||||
assertEquals("Checked", sheet.getRow(9).getCell(2).getStringCellValue());
|
||||
assertEquals(false, sheet.getRow(70).getCell(8).getBooleanCellValue());
|
||||
@ -3089,7 +3083,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
// This bug is currently open. When this bug is fixed, it should not throw an AssertionError
|
||||
@Test(expected=AssertionError.class)
|
||||
@Test(expected = AssertionError.class)
|
||||
public void test55076_collapseColumnGroups() throws Exception {
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
@ -3114,7 +3108,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// none of the columns should be hidden
|
||||
// column group collapsing is a different concept
|
||||
for (int c=0; c<5; c++) {
|
||||
for (int c = 0; c < 5; c++) {
|
||||
assertFalse("Column " + c, sheet.isColumnHidden(c));
|
||||
}
|
||||
|
||||
@ -3190,7 +3184,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
str.close();
|
||||
}
|
||||
|
||||
assertEquals("B2:I5", ((XSSFSheet)sheet).getCTWorksheet().getDimension().getRef());
|
||||
assertEquals("B2:I5", ((XSSFSheet) sheet).getCTWorksheet().getDimension().getRef());
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user