git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1629653 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_11_BETA3
CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord) getObjRecord().getSubRecords().get(0); | CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord) getObjRecord().getSubRecords().get(0); | ||||
cod.setObjectId((short) (shapeId % 1024)); | cod.setObjectId((short) (shapeId % 1024)); | ||||
_note.setShapeId(shapeId % 1024); | _note.setShapeId(shapeId % 1024); | ||||
/* This breaks TestCloneSheets! | |||||
* cod.setObjectId(shapeId); | |||||
_note.setShapeId(shapeId); */ | |||||
} | } | ||||
/** | /** |
package org.apache.poi.xssf.streaming; | package org.apache.poi.xssf.streaming; | ||||
import static org.junit.Assert.*; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertFalse; | |||||
import static org.junit.Assert.assertNotNull; | |||||
import static org.junit.Assert.assertTrue; | |||||
import static org.junit.Assert.fail; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
assertEquals("value?", cell.getStringCellValue()); | assertEquals("value?", cell.getStringCellValue()); | ||||
assertTrue(wb.dispose()); | assertTrue(wb.dispose()); | ||||
} | } | ||||
@Test | @Test | ||||
} | } | ||||
@Test | @Test | ||||
public void workbookDispose() throws IOException | |||||
public void workbookDispose() | |||||
{ | { | ||||
SXSSFWorkbook wb = new SXSSFWorkbook(); | SXSSFWorkbook wb = new SXSSFWorkbook(); | ||||
// the underlying writer is SheetDataWriter | // the underlying writer is SheetDataWriter | ||||
assertWorkbookDispose(wb); | assertWorkbookDispose(wb); | ||||
wb.close(); | |||||
wb = new SXSSFWorkbook(); | wb = new SXSSFWorkbook(); | ||||
wb.setCompressTempFiles(true); | wb.setCompressTempFiles(true); | ||||
// the underlying writer is GZIPSheetDataWriter | // the underlying writer is GZIPSheetDataWriter | ||||
assertWorkbookDispose(wb); | assertWorkbookDispose(wb); | ||||
wb.close(); | |||||
} | } | ||||
Workbook wb = new SXSSFWorkbook(10); | Workbook wb = new SXSSFWorkbook(10); | ||||
populateWorkbook(wb); | populateWorkbook(wb); | ||||
saveTwice(wb); | saveTwice(wb); | ||||
wb.close(); | |||||
wb = new XSSFWorkbook(); | wb = new XSSFWorkbook(); | ||||
populateWorkbook(wb); | populateWorkbook(wb); | ||||
saveTwice(wb); | saveTwice(wb); | ||||
wb.close(); | |||||
} | } | ||||
// Crashes the JVM because of documented JVM behavior with concurrent writing/reading of zip-files | // Crashes the JVM because of documented JVM behavior with concurrent writing/reading of zip-files | ||||
} finally { | } finally { | ||||
assertTrue(wb.dispose()); | assertTrue(wb.dispose()); | ||||
} | } | ||||
wb.close(); | |||||
} | } | ||||
out.delete(); | out.delete(); | ||||
} | } | ||||
private static class NullOutputStream extends OutputStream { | private static class NullOutputStream extends OutputStream { | ||||
@Override | @Override | ||||
public void write(int b) throws IOException { | public void write(int b) throws IOException { | ||||
// nothing to do here | |||||
} | } | ||||
} | } | ||||
@Test | |||||
public void testBug54523() throws IOException { | |||||
SXSSFWorkbook wb = new SXSSFWorkbook(100); | |||||
Sheet sh = wb.createSheet(); | |||||
for (int i = 0; i < 81000; i++) { | |||||
Row row = sh.createRow(i); | |||||
for (int j = 0; j < 1000; j++) { | |||||
Cell cell = row.createCell(j); | |||||
cell.setCellValue("dddd"); | |||||
} | |||||
if (i % 100 == 0){ | |||||
System.out.println("x - " + i); | |||||
} | |||||
} | |||||
FileOutputStream out = new FileOutputStream("C:\\temp\\54523_large.xlsx"); | |||||
wb.write(out); | |||||
out.close(); | |||||
wb.dispose(); | |||||
wb.close(); | |||||
} | |||||
} | } |
package org.apache.poi.xssf.usermodel; | package org.apache.poi.xssf.usermodel; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import org.apache.poi.ss.SpreadsheetVersion; | import org.apache.poi.ss.SpreadsheetVersion; | ||||
import org.apache.poi.ss.usermodel.BaseTestRow; | import org.apache.poi.ss.usermodel.BaseTestRow; | ||||
import org.apache.poi.ss.usermodel.Cell; | |||||
import org.apache.poi.ss.usermodel.Row; | |||||
import org.apache.poi.xssf.XSSFITestDataProvider; | import org.apache.poi.xssf.XSSFITestDataProvider; | ||||
import org.apache.poi.xssf.XSSFTestDataSamples; | |||||
/** | /** | ||||
* Tests for XSSFRow | * Tests for XSSFRow | ||||
public void testCellBounds() { | public void testCellBounds() { | ||||
baseTestCellBounds(SpreadsheetVersion.EXCEL2007.getLastColumnIndex()); | baseTestCellBounds(SpreadsheetVersion.EXCEL2007.getLastColumnIndex()); | ||||
} | } | ||||
public void test56490() { | |||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56490.xlsx"); | |||||
XSSFSheet sheet = wb.getSheetAt(0); | |||||
String columnWanted = "Link"; | |||||
Integer columnNo = null; | |||||
List<Cell> cells = new ArrayList<Cell>(); | |||||
// TODO: change this!! | |||||
assertEquals(-1, sheet.getFirstRowNum()); | |||||
assertEquals(-1, sheet.getLastRowNum()); | |||||
Row firstRow = sheet.getRow(-1); | |||||
assertNotNull(firstRow); | |||||
assertNotNull(firstRow.iterator()); | |||||
for(Row row : sheet) { | |||||
for(Cell cell : row) { | |||||
System.out.println("Cell in Row: " + row.getRowNum() + ": " + cell.toString()); | |||||
} | |||||
} | |||||
for (Cell cell : firstRow) { | |||||
if (cell.getStringCellValue().equals(columnWanted)) { | |||||
columnNo = cell.getColumnIndex(); | |||||
} | |||||
} | |||||
if (columnNo != null) { | |||||
for (Row row : sheet) { | |||||
Cell c = row.getCell(columnNo); | |||||
if (c == null || c.getCellType() == Cell.CELL_TYPE_BLANK) { | |||||
} else { | |||||
cells.add(c); | |||||
} | |||||
} | |||||
} else { | |||||
System.out.println("could not find column" + columnWanted | |||||
+ "in first row"); | |||||
} | |||||
} | |||||
} | } |
package org.apache.poi.xssf.usermodel; | package org.apache.poi.xssf.usermodel; | ||||
import static org.junit.Assert.*; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertFalse; | |||||
import static org.junit.Assert.assertNotNull; | |||||
import static org.junit.Assert.assertNull; | |||||
import static org.junit.Assert.assertSame; | |||||
import static org.junit.Assert.assertTrue; | |||||
import static org.junit.Assert.fail; | |||||
import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
import java.io.File; | import java.io.File; | ||||
import org.apache.poi.openxml4j.opc.PackagingURIHelper; | import org.apache.poi.openxml4j.opc.PackagingURIHelper; | ||||
import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart; | import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart; | ||||
import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart; | import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart; | ||||
import org.apache.poi.ss.usermodel.*; | |||||
import org.apache.poi.ss.usermodel.BaseTestWorkbook; | |||||
import org.apache.poi.ss.usermodel.Cell; | |||||
import org.apache.poi.ss.usermodel.CellStyle; | |||||
import org.apache.poi.ss.usermodel.Font; | |||||
import org.apache.poi.ss.usermodel.IndexedColors; | |||||
import org.apache.poi.ss.usermodel.RichTextString; | |||||
import org.apache.poi.ss.usermodel.Row; | |||||
import org.apache.poi.ss.usermodel.Sheet; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.apache.poi.ss.usermodel.WorkbookFactory; | |||||
import org.apache.poi.ss.util.AreaReference; | import org.apache.poi.ss.util.AreaReference; | ||||
import org.apache.poi.ss.util.CellReference; | import org.apache.poi.ss.util.CellReference; | ||||
import org.apache.poi.util.IOUtils; | import org.apache.poi.util.IOUtils; | ||||
setPivotData(wb2); | setPivotData(wb2); | ||||
assertTrue(wb2.getPivotTables().size() == 2); | assertTrue(wb2.getPivotTables().size() == 2); | ||||
} | } | ||||
@Test | |||||
public void testBug55644() throws IOException { | |||||
XSSFWorkbook wb = new XSSFWorkbook(); | |||||
XSSFSheet sheet = wb.createSheet("students"); | |||||
XSSFRow row = sheet.createRow(1); | |||||
XSSFCell cell = row.createCell(1); | |||||
cell.setCellValue("sandeepzzzzzzzzzzzzzzzzzzzzzzzzz"); | |||||
sheet.autoSizeColumn(1); | |||||
FileOutputStream fileOut = new FileOutputStream("C:\\temp\\55644.xlsx"); | |||||
wb.write(fileOut); | |||||
fileOut.close(); | |||||
wb.close(); | |||||
} | |||||
} | } |
_sampleDataIsAvaliableOnClassPath = true; | _sampleDataIsAvaliableOnClassPath = true; | ||||
return; | return; | ||||
} | } | ||||
dataDirName = "test-data"; | |||||
/*throw new RuntimeException("Must set system property '" + | |||||
TEST_PROPERTY + "' before running tests");*/ | |||||
throw new RuntimeException("Must set system property '" + | |||||
TEST_PROPERTY + "' before running tests"); | |||||
} | } | ||||
File dataDir = new File(dataDirName, _moduleDir); | File dataDir = new File(dataDirName, _moduleDir); | ||||
if (!dataDir.exists()) { | if (!dataDir.exists()) { |
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
import org.apache.poi.hssf.HSSFTestDataSamples; | import org.apache.poi.hssf.HSSFTestDataSamples; | ||||
import org.apache.poi.hssf.dev.BiffViewer; | |||||
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.CellStyle; | import org.apache.poi.ss.usermodel.CellStyle; | ||||
import org.apache.poi.ss.usermodel.Row; | import org.apache.poi.ss.usermodel.Row; | ||||
assertEquals("LAST ROW ", 0, s.getLastRowNum()); | assertEquals("LAST ROW ", 0, s.getLastRowNum()); | ||||
assertEquals("FIRST ROW ", 0, s.getFirstRowNum()); | assertEquals("FIRST ROW ", 0, s.getFirstRowNum()); | ||||
} | } | ||||
public void testHashEquals() { | public void testHashEquals() { | ||||
HSSFWorkbook wb = new HSSFWorkbook(); | HSSFWorkbook wb = new HSSFWorkbook(); | ||||
HSSFSheet s = wb.createSheet(); | HSSFSheet s = wb.createSheet(); | ||||
HSSFRow row = s.createRow(0); | HSSFRow row = s.createRow(0); | ||||
HSSFCell cell1 = row.createCell(1); | HSSFCell cell1 = row.createCell(1); | ||||
HSSFCell cell2 = row.createCell(2); | HSSFCell cell2 = row.createCell(2); | ||||
cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy")); | cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy")); | ||||
cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy")); | cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy")); | ||||
cell1.setCellStyle(cs1); | cell1.setCellStyle(cs1); | ||||
cell1.setCellValue(new Date()); | cell1.setCellValue(new Date()); | ||||
cell2.setCellStyle(cs2); | cell2.setCellStyle(cs2); | ||||
cell2.setCellValue(new Date()); | cell2.setCellValue(new Date()); | ||||
assertEquals(cs1.hashCode(), cs1.hashCode()); | assertEquals(cs1.hashCode(), cs1.hashCode()); | ||||
assertEquals(cs2.hashCode(), cs2.hashCode()); | assertEquals(cs2.hashCode(), cs2.hashCode()); | ||||
assertTrue(cs1.equals(cs1)); | assertTrue(cs1.equals(cs1)); | ||||
assertTrue(cs2.equals(cs2)); | assertTrue(cs2.equals(cs2)); | ||||
// Change cs1, hash will alter | // Change cs1, hash will alter | ||||
int hash1 = cs1.hashCode(); | int hash1 = cs1.hashCode(); | ||||
cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy")); | cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy")); | ||||
assertEquals("LAST ROW == 99", 99, s.getLastRowNum()); | assertEquals("LAST ROW == 99", 99, s.getLastRowNum()); | ||||
assertEquals("FIRST ROW == 0", 0, s.getFirstRowNum()); | assertEquals("FIRST ROW == 0", 0, s.getFirstRowNum()); | ||||
} | } | ||||
/** | /** | ||||
* Cloning one HSSFCellStyle onto Another, same | * Cloning one HSSFCellStyle onto Another, same | ||||
* HSSFWorkbook | * HSSFWorkbook | ||||
HSSFFont fnt = wb.createFont(); | HSSFFont fnt = wb.createFont(); | ||||
fnt.setFontName("TestingFont"); | fnt.setFontName("TestingFont"); | ||||
assertEquals(5, wb.getNumberOfFonts()); | assertEquals(5, wb.getNumberOfFonts()); | ||||
HSSFCellStyle orig = wb.createCellStyle(); | HSSFCellStyle orig = wb.createCellStyle(); | ||||
orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT); | orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT); | ||||
orig.setFont(fnt); | orig.setFont(fnt); | ||||
orig.setDataFormat((short)18); | orig.setDataFormat((short)18); | ||||
assertTrue(HSSFCellStyle.ALIGN_RIGHT == orig.getAlignment()); | assertTrue(HSSFCellStyle.ALIGN_RIGHT == orig.getAlignment()); | ||||
assertTrue(fnt == orig.getFont(wb)); | assertTrue(fnt == orig.getFont(wb)); | ||||
assertTrue(18 == orig.getDataFormat()); | assertTrue(18 == orig.getDataFormat()); | ||||
HSSFCellStyle clone = wb.createCellStyle(); | HSSFCellStyle clone = wb.createCellStyle(); | ||||
assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | ||||
assertFalse(fnt == clone.getFont(wb)); | assertFalse(fnt == clone.getFont(wb)); | ||||
assertFalse(18 == clone.getDataFormat()); | assertFalse(18 == clone.getDataFormat()); | ||||
clone.cloneStyleFrom(orig); | clone.cloneStyleFrom(orig); | ||||
assertTrue(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | assertTrue(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | ||||
assertTrue(fnt == clone.getFont(wb)); | assertTrue(fnt == clone.getFont(wb)); | ||||
assertTrue(18 == clone.getDataFormat()); | assertTrue(18 == clone.getDataFormat()); | ||||
assertEquals(5, wb.getNumberOfFonts()); | assertEquals(5, wb.getNumberOfFonts()); | ||||
} | } | ||||
/** | /** | ||||
* Cloning one HSSFCellStyle onto Another, across | * Cloning one HSSFCellStyle onto Another, across | ||||
* two different HSSFWorkbooks | * two different HSSFWorkbooks | ||||
*/ | */ | ||||
public void testCloneStyleDiffWB() { | public void testCloneStyleDiffWB() { | ||||
HSSFWorkbook wbOrig = new HSSFWorkbook(); | HSSFWorkbook wbOrig = new HSSFWorkbook(); | ||||
HSSFFont fnt = wbOrig.createFont(); | HSSFFont fnt = wbOrig.createFont(); | ||||
fnt.setFontName("TestingFont"); | fnt.setFontName("TestingFont"); | ||||
assertEquals(5, wbOrig.getNumberOfFonts()); | assertEquals(5, wbOrig.getNumberOfFonts()); | ||||
HSSFDataFormat fmt = wbOrig.createDataFormat(); | HSSFDataFormat fmt = wbOrig.createDataFormat(); | ||||
fmt.getFormat("MadeUpOne"); | fmt.getFormat("MadeUpOne"); | ||||
fmt.getFormat("MadeUpTwo"); | fmt.getFormat("MadeUpTwo"); | ||||
HSSFCellStyle orig = wbOrig.createCellStyle(); | HSSFCellStyle orig = wbOrig.createCellStyle(); | ||||
orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT); | orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT); | ||||
orig.setFont(fnt); | orig.setFont(fnt); | ||||
orig.setDataFormat(fmt.getFormat("Test##")); | orig.setDataFormat(fmt.getFormat("Test##")); | ||||
assertTrue(HSSFCellStyle.ALIGN_RIGHT == orig.getAlignment()); | assertTrue(HSSFCellStyle.ALIGN_RIGHT == orig.getAlignment()); | ||||
assertTrue(fnt == orig.getFont(wbOrig)); | assertTrue(fnt == orig.getFont(wbOrig)); | ||||
assertTrue(fmt.getFormat("Test##") == orig.getDataFormat()); | assertTrue(fmt.getFormat("Test##") == orig.getDataFormat()); | ||||
// Now a style on another workbook | // Now a style on another workbook | ||||
HSSFWorkbook wbClone = new HSSFWorkbook(); | HSSFWorkbook wbClone = new HSSFWorkbook(); | ||||
assertEquals(4, wbClone.getNumberOfFonts()); | assertEquals(4, wbClone.getNumberOfFonts()); | ||||
HSSFDataFormat fmtClone = wbClone.createDataFormat(); | HSSFDataFormat fmtClone = wbClone.createDataFormat(); | ||||
HSSFCellStyle clone = wbClone.createCellStyle(); | HSSFCellStyle clone = wbClone.createCellStyle(); | ||||
assertEquals(4, wbClone.getNumberOfFonts()); | assertEquals(4, wbClone.getNumberOfFonts()); | ||||
assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | ||||
assertFalse("TestingFont" == clone.getFont(wbClone).getFontName()); | assertFalse("TestingFont" == clone.getFont(wbClone).getFontName()); | ||||
clone.cloneStyleFrom(orig); | clone.cloneStyleFrom(orig); | ||||
assertTrue(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | assertTrue(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment()); | ||||
assertTrue("TestingFont" == clone.getFont(wbClone).getFontName()); | assertTrue("TestingFont" == clone.getFont(wbClone).getFontName()); | ||||
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##")); | assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##")); | ||||
assertEquals(5, wbClone.getNumberOfFonts()); | assertEquals(5, wbClone.getNumberOfFonts()); | ||||
} | } | ||||
public void testStyleNames() { | public void testStyleNames() { | ||||
HSSFWorkbook wb = openSample("WithExtendedStyles.xls"); | HSSFWorkbook wb = openSample("WithExtendedStyles.xls"); | ||||
HSSFSheet s = wb.getSheetAt(0); | HSSFSheet s = wb.getSheetAt(0); | ||||
HSSFCell c1 = s.getRow(0).getCell(0); | HSSFCell c1 = s.getRow(0).getCell(0); | ||||
HSSFCell c2 = s.getRow(1).getCell(0); | HSSFCell c2 = s.getRow(1).getCell(0); | ||||
HSSFCell c3 = s.getRow(2).getCell(0); | HSSFCell c3 = s.getRow(2).getCell(0); | ||||
HSSFCellStyle cs1 = c1.getCellStyle(); | HSSFCellStyle cs1 = c1.getCellStyle(); | ||||
HSSFCellStyle cs2 = c2.getCellStyle(); | HSSFCellStyle cs2 = c2.getCellStyle(); | ||||
HSSFCellStyle cs3 = c3.getCellStyle(); | HSSFCellStyle cs3 = c3.getCellStyle(); | ||||
assertNotNull(cs1); | assertNotNull(cs1); | ||||
assertNotNull(cs2); | assertNotNull(cs2); | ||||
assertNotNull(cs3); | assertNotNull(cs3); | ||||
// Check we got the styles we'd expect | // Check we got the styles we'd expect | ||||
assertEquals(10, cs1.getFont(wb).getFontHeightInPoints()); | assertEquals(10, cs1.getFont(wb).getFontHeightInPoints()); | ||||
assertEquals(9, cs2.getFont(wb).getFontHeightInPoints()); | assertEquals(9, cs2.getFont(wb).getFontHeightInPoints()); | ||||
assertEquals(12, cs3.getFont(wb).getFontHeightInPoints()); | assertEquals(12, cs3.getFont(wb).getFontHeightInPoints()); | ||||
assertEquals(15, cs1.getIndex()); | assertEquals(15, cs1.getIndex()); | ||||
assertEquals(23, cs2.getIndex()); | assertEquals(23, cs2.getIndex()); | ||||
assertEquals(24, cs3.getIndex()); | assertEquals(24, cs3.getIndex()); | ||||
assertNull(cs1.getParentStyle()); | assertNull(cs1.getParentStyle()); | ||||
assertNotNull(cs2.getParentStyle()); | assertNotNull(cs2.getParentStyle()); | ||||
assertNotNull(cs3.getParentStyle()); | assertNotNull(cs3.getParentStyle()); | ||||
assertEquals(21, cs2.getParentStyle().getIndex()); | assertEquals(21, cs2.getParentStyle().getIndex()); | ||||
assertEquals(22, cs3.getParentStyle().getIndex()); | assertEquals(22, cs3.getParentStyle().getIndex()); | ||||
// Now check we can get style records for | |||||
// Now check we can get style records for | |||||
// the parent ones | // the parent ones | ||||
assertNull(wb.getWorkbook().getStyleRecord(15)); | assertNull(wb.getWorkbook().getStyleRecord(15)); | ||||
assertNull(wb.getWorkbook().getStyleRecord(23)); | assertNull(wb.getWorkbook().getStyleRecord(23)); | ||||
assertNull(wb.getWorkbook().getStyleRecord(24)); | assertNull(wb.getWorkbook().getStyleRecord(24)); | ||||
assertNotNull(wb.getWorkbook().getStyleRecord(21)); | assertNotNull(wb.getWorkbook().getStyleRecord(21)); | ||||
assertNotNull(wb.getWorkbook().getStyleRecord(22)); | assertNotNull(wb.getWorkbook().getStyleRecord(22)); | ||||
// Now check the style names | // Now check the style names | ||||
assertEquals(null, cs1.getUserStyleName()); | assertEquals(null, cs1.getUserStyleName()); | ||||
assertEquals(null, cs2.getUserStyleName()); | assertEquals(null, cs2.getUserStyleName()); | ||||
c4.setCellStyle(cs2); | c4.setCellStyle(cs2); | ||||
assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName()); | assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName()); | ||||
} | } | ||||
public void testGetSetBorderHair() { | public void testGetSetBorderHair() { | ||||
HSSFWorkbook wb = openSample("55341_CellStyleBorder.xls"); | HSSFWorkbook wb = openSample("55341_CellStyleBorder.xls"); | ||||
HSSFSheet s = wb.getSheetAt(0); | HSSFSheet s = wb.getSheetAt(0); | ||||
HSSFCellStyle cs; | HSSFCellStyle cs; | ||||
cs = s.getRow(0).getCell(0).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight()); | |||||
cs = s.getRow(0).getCell(0).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight()); | |||||
cs = s.getRow(1).getCell(1).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight()); | |||||
cs = s.getRow(1).getCell(1).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight()); | |||||
cs = s.getRow(2).getCell(2).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(2).getCell(2).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(3).getCell(3).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight()); | |||||
cs = s.getRow(3).getCell(3).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight()); | |||||
cs = s.getRow(4).getCell(4).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight()); | |||||
cs = s.getRow(4).getCell(4).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight()); | |||||
cs = s.getRow(5).getCell(5).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(5).getCell(5).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(6).getCell(6).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(6).getCell(6).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(7).getCell(7).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(7).getCell(7).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight()); | |||||
cs = s.getRow(8).getCell(8).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight()); | |||||
cs = s.getRow(8).getCell(8).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight()); | |||||
cs = s.getRow(9).getCell(9).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight()); | |||||
cs = s.getRow(9).getCell(9).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight()); | |||||
cs = s.getRow(10).getCell(10).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight()); | |||||
cs = s.getRow(10).getCell(10).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight()); | |||||
cs = s.getRow(11).getCell(11).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight()); | |||||
} | |||||
public void testBug54894() throws IOException { | |||||
HSSFWorkbook wb = new HSSFWorkbook(); | |||||
HSSFSheet sheet = wb.createSheet("new sheet"); | |||||
// Create a row and put some cells in it. Rows are 0 based. | |||||
HSSFRow row = sheet.createRow(1); | |||||
// Create a cell and put a value in it. | |||||
HSSFCell cell = row.createCell(1); | |||||
cell.setCellValue(4); | |||||
CellStyle def = cell.getCellStyle(); | |||||
String filenameB = "C:\\temp\\54894B.xls"; | |||||
FileOutputStream fileOut = new FileOutputStream(filenameB); | |||||
try { | |||||
wb.write(fileOut); | |||||
} finally { | |||||
fileOut.close(); | |||||
} | |||||
// Style the cell with borders all around. | |||||
HSSFCellStyle style = wb.createCellStyle(); | |||||
style.cloneStyleFrom(def); | |||||
String filenameM = "C:\\temp\\54894M.xls"; | |||||
fileOut = new FileOutputStream(filenameM); | |||||
try { | |||||
wb.write(fileOut); | |||||
} finally { | |||||
fileOut.close(); | |||||
} | |||||
style.setBorderBottom(HSSFCellStyle.BORDER_THIN); | |||||
cell.setCellStyle(style); | |||||
String filenameM1 = "C:\\temp\\54894M1.xls"; | |||||
fileOut = new FileOutputStream(filenameM1); | |||||
try { | |||||
wb.write(fileOut); | |||||
} finally { | |||||
fileOut.close(); | |||||
} | |||||
// Write the output to a file | |||||
String filename = "C:\\temp\\54894.xls"; | |||||
fileOut = new FileOutputStream(filename); | |||||
try { | |||||
wb.write(fileOut); | |||||
} finally { | |||||
fileOut.close(); | |||||
} | |||||
/*Runtime.getRuntime().exec(new String[] {"cmd", "/c", "start", filenameB}); | |||||
Runtime.getRuntime().exec(new String[] {"cmd", "/c", "start", filenameM}); | |||||
Runtime.getRuntime().exec(new String[] {"cmd", "/c", "start", filenameM1}); | |||||
Runtime.getRuntime().exec(new String[] {"cmd", "/c", "start", filename});*/ | |||||
System.out.println("testfile M"); | |||||
BiffViewer.main(new String[] {filenameM}); | |||||
System.out.println("testfile M1"); | |||||
BiffViewer.main(new String[] {filenameM1}); | |||||
cs = s.getRow(11).getCell(11).getCellStyle(); | |||||
assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight()); | |||||
} | } | ||||
public void testShrinkToFit() { | public void testShrinkToFit() { | ||||
public Throwable getException() { | public Throwable getException() { | ||||
return exception; | return exception; | ||||
} | } | ||||
} | |||||
}; | |||||
public void test56563() throws Throwable { | public void test56563() throws Throwable { | ||||
CellFormatBugExample threadA = new CellFormatBugExample("56563a.xls"); | CellFormatBugExample threadA = new CellFormatBugExample("56563a.xls"); |
package org.apache.poi.hssf.usermodel; | package org.apache.poi.hssf.usermodel; | ||||
import static org.junit.Assert.assertArrayEquals; | |||||
import java.io.File; | |||||
import java.io.FileOutputStream; | |||||
import java.io.IOException; | |||||
import java.util.Arrays; | |||||
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
import org.apache.poi.ddf.EscherSpRecord; | |||||
import org.apache.poi.hssf.HSSFTestDataSamples; | import org.apache.poi.hssf.HSSFTestDataSamples; | ||||
import org.apache.poi.hssf.model.CommentShape; | import org.apache.poi.hssf.model.CommentShape; | ||||
import org.apache.poi.hssf.model.HSSFTestModelHelper; | import org.apache.poi.hssf.model.HSSFTestModelHelper; | ||||
import org.apache.poi.hssf.record.CommonObjectDataSubRecord; | |||||
import org.apache.poi.hssf.record.EscherAggregate; | |||||
import org.apache.poi.hssf.record.NoteRecord; | |||||
import org.apache.poi.hssf.record.ObjRecord; | |||||
import org.apache.poi.hssf.record.TextObjectRecord; | |||||
import org.apache.poi.ss.usermodel.Cell; | |||||
import org.apache.poi.ss.usermodel.ClientAnchor; | |||||
import org.apache.poi.ss.usermodel.Comment; | |||||
import org.apache.poi.ss.usermodel.CreationHelper; | |||||
import org.apache.poi.ss.usermodel.Drawing; | |||||
import org.apache.poi.ss.usermodel.RichTextString; | |||||
import org.apache.poi.ss.usermodel.Row; | |||||
import org.apache.poi.ss.usermodel.Sheet; | |||||
import org.apache.poi.hssf.record.*; | |||||
import java.io.*; | |||||
import java.util.Arrays; | |||||
/** | /** | ||||
* @author Evgeniy Berlog | * @author Evgeniy Berlog | ||||
* @date 26.06.12 | * @date 26.06.12 | ||||
*/ | */ | ||||
@SuppressWarnings("deprecation") | |||||
public class TestComment extends TestCase { | public class TestComment extends TestCase { | ||||
public void testResultEqualsToAbstractShape() { | public void testResultEqualsToAbstractShape() { | ||||
byte[] actual = comment.getEscherContainer().getChild(0).serialize(); | byte[] actual = comment.getEscherContainer().getChild(0).serialize(); | ||||
assertEquals(expected.length, actual.length); | assertEquals(expected.length, actual.length); | ||||
assertArrayEquals(expected, actual); | |||||
assertTrue(Arrays.equals(expected, actual)); | |||||
expected = commentShape.getSpContainer().getChild(2).serialize(); | expected = commentShape.getSpContainer().getChild(2).serialize(); | ||||
actual = comment.getEscherContainer().getChild(2).serialize(); | actual = comment.getEscherContainer().getChild(2).serialize(); | ||||
assertEquals(expected.length, actual.length); | assertEquals(expected.length, actual.length); | ||||
assertArrayEquals(expected, actual); | |||||
assertTrue(Arrays.equals(expected, actual)); | |||||
expected = commentShape.getSpContainer().getChild(3).serialize(); | expected = commentShape.getSpContainer().getChild(3).serialize(); | ||||
actual = comment.getEscherContainer().getChild(3).serialize(); | actual = comment.getEscherContainer().getChild(3).serialize(); | ||||
assertEquals(expected.length, actual.length); | assertEquals(expected.length, actual.length); | ||||
assertArrayEquals(expected, actual); | |||||
assertTrue(Arrays.equals(expected, actual)); | |||||
expected = commentShape.getSpContainer().getChild(4).serialize(); | expected = commentShape.getSpContainer().getChild(4).serialize(); | ||||
actual = comment.getEscherContainer().getChild(4).serialize(); | actual = comment.getEscherContainer().getChild(4).serialize(); | ||||
assertEquals(expected.length, actual.length); | assertEquals(expected.length, actual.length); | ||||
assertArrayEquals(expected, actual); | |||||
assertTrue(Arrays.equals(expected, actual)); | |||||
ObjRecord obj = comment.getObjRecord(); | ObjRecord obj = comment.getObjRecord(); | ||||
ObjRecord objShape = commentShape.getObjRecord(); | ObjRecord objShape = commentShape.getObjRecord(); | ||||
actual = torShape.serialize(); | actual = torShape.serialize(); | ||||
assertEquals(expected.length, actual.length); | assertEquals(expected.length, actual.length); | ||||
assertArrayEquals(expected, actual); | |||||
assertTrue(Arrays.equals(expected, actual)); | |||||
NoteRecord note = comment.getNoteRecord(); | NoteRecord note = comment.getNoteRecord(); | ||||
NoteRecord noteShape = commentShape.getNoteRecord(); | NoteRecord noteShape = commentShape.getNoteRecord(); | ||||
actual = noteShape.serialize(); | actual = noteShape.serialize(); | ||||
assertEquals(expected.length, actual.length); | assertEquals(expected.length, actual.length); | ||||
assertTrue( | |||||
"\nHad: " + Arrays.toString(actual) + | |||||
"\n Expected: " + Arrays.toString(expected), | |||||
Arrays.equals(expected, actual)); | |||||
assertTrue(Arrays.equals(expected, actual)); | |||||
} | } | ||||
public void testAddToExistingFile() { | public void testAddToExistingFile() { | ||||
assertEquals(agg.getTailRecords().size(), 1); | assertEquals(agg.getTailRecords().size(), 1); | ||||
HSSFSimpleShape shape = patriarch.createSimpleShape(new HSSFClientAnchor()); | HSSFSimpleShape shape = patriarch.createSimpleShape(new HSSFClientAnchor()); | ||||
assertNotNull(shape); | |||||
assertEquals(comment.getOptRecord().getEscherProperties().size(), 10); | assertEquals(comment.getOptRecord().getEscherProperties().size(), 10); | ||||
} | } | ||||
assertEquals(comment.getShapeId(), 2024); | assertEquals(comment.getShapeId(), 2024); | ||||
/*CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord) comment.getObjRecord().getSubRecords().get(0); | |||||
assertEquals(2024, cod.getObjectId()); | |||||
CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord) comment.getObjRecord().getSubRecords().get(0); | |||||
assertEquals(cod.getObjectId(), 1000); | |||||
EscherSpRecord spRecord = (EscherSpRecord) comment.getEscherContainer().getChild(0); | EscherSpRecord spRecord = (EscherSpRecord) comment.getEscherContainer().getChild(0); | ||||
assertEquals(spRecord.getShapeId(), 2024); | assertEquals(spRecord.getShapeId(), 2024); | ||||
assertEquals(comment.getShapeId(), 2024); | assertEquals(comment.getShapeId(), 2024); | ||||
assertEquals(2024, comment.getNoteRecord().getShapeId());*/ | |||||
assertEquals(comment.getNoteRecord().getShapeId(), 1000); | |||||
} | } | ||||
public void testAttemptToSave2CommentsWithSameCoordinates(){ | public void testAttemptToSave2CommentsWithSameCoordinates(){ | ||||
} | } | ||||
assertNotNull(err); | assertNotNull(err); | ||||
} | } | ||||
public void testBug56380InsertComments() throws Exception { | |||||
HSSFWorkbook workbook = new HSSFWorkbook(); | |||||
HSSFSheet sheet = workbook.createSheet(); | |||||
Drawing drawing = sheet.createDrawingPatriarch(); | |||||
int noOfRows = 3000; | |||||
String comment = "c"; | |||||
for(int i = 0; i < noOfRows; i++) { | |||||
Row row = sheet.createRow(i); | |||||
Cell cell = row.createCell(0); | |||||
insertComment(drawing, cell, comment + i); | |||||
} | |||||
// assert that the comments are created properly before writing | |||||
checkComments(sheet, noOfRows, comment); | |||||
System.out.println("Listing comments before write"); | |||||
listComments(sheet.getDrawingPatriarch()); | |||||
assertEquals(noOfRows, sheet.getDrawingPatriarch().getChildren().size()); | |||||
// store in temp-file | |||||
File file = new File(System.getProperty("java.io.tmpdir") + File.separatorChar + "test_comments.xls"); | |||||
FileOutputStream fs = new FileOutputStream(file); | |||||
try { | |||||
sheet.getWorkbook().write(fs); | |||||
} finally { | |||||
fs.close(); | |||||
} | |||||
// save and recreate the workbook from the saved file | |||||
workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook); | |||||
sheet = workbook.getSheetAt(0); | |||||
// recreate the workbook from the saved file | |||||
/*FileInputStream fi = new FileInputStream(file); | |||||
try { | |||||
sheet = new HSSFWorkbook(fi).getSheetAt(0); | |||||
} finally { | |||||
fi.close(); | |||||
}*/ | |||||
System.out.println("Listing comments after read"); | |||||
listComments(sheet.getDrawingPatriarch()); | |||||
assertEquals(noOfRows, sheet.getDrawingPatriarch().getChildren().size()); | |||||
// store file after | |||||
file = new File(System.getProperty("java.io.tmpdir") + File.separatorChar + "test_comments_after.xls"); | |||||
fs = new FileOutputStream(file); | |||||
try { | |||||
sheet.getWorkbook().write(fs); | |||||
} finally { | |||||
fs.close(); | |||||
} | |||||
// assert that the comments are created properly after reading back in | |||||
//checkComments(sheet, noOfRows, comment); | |||||
} | |||||
private void listComments(HSSFShapeContainer container) { | |||||
for (Object object : container.getChildren()) { | |||||
HSSFShape shape = (HSSFShape) object; | |||||
if (shape instanceof HSSFShapeGroup) { | |||||
listComments((HSSFShapeContainer) shape); | |||||
continue; | |||||
} | |||||
if (shape instanceof HSSFComment) { | |||||
HSSFComment comment = (HSSFComment) shape; | |||||
System.out.println("Comment " + comment.getString().getString() + " at " + comment.getColumn() + "/" + comment.getRow()); | |||||
} | |||||
} | |||||
} | |||||
private void checkComments(Sheet sheet, int noOfRows, String commentStr) { | |||||
for(int i = 0; i < noOfRows; i++) { | |||||
assertNotNull(sheet.getRow(i)); | |||||
Cell cell = sheet.getRow(i).getCell(0); | |||||
assertNotNull(cell); | |||||
Comment comment = cell.getCellComment(); | |||||
assertNotNull("Did not get a Cell Comment for row " + i, comment); | |||||
assertNotNull(comment.getString()); | |||||
assertEquals(i, comment.getRow()); | |||||
assertEquals(0,comment.getColumn()); | |||||
assertEquals(commentStr + i, comment.getString().getString()); | |||||
} | |||||
} | |||||
private void insertComment(Drawing drawing, Cell cell, String message) { | |||||
CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper(); | |||||
ClientAnchor anchor = factory.createClientAnchor(); | |||||
anchor.setCol1(cell.getColumnIndex()); | |||||
anchor.setCol2(cell.getColumnIndex() + 1); | |||||
anchor.setRow1(cell.getRowIndex()); | |||||
anchor.setRow2(cell.getRowIndex() + 1); | |||||
anchor.setDx1(100); | |||||
anchor.setDx2(100); | |||||
anchor.setDy1(100); | |||||
anchor.setDy2(100); | |||||
Comment comment = drawing.createCellComment(anchor); | |||||
RichTextString str = factory.createRichTextString(message); | |||||
comment.setString(str); | |||||
comment.setAuthor("fanfy"); | |||||
cell.setCellComment(comment); | |||||
} | |||||
} | } |
package org.apache.poi.hssf.usermodel; | package org.apache.poi.hssf.usermodel; | ||||
import static org.junit.Assert.*; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertFalse; | |||||
import static org.junit.Assert.assertNotNull; | |||||
import static org.junit.Assert.assertNull; | |||||
import static org.junit.Assert.assertTrue; | |||||
import static org.junit.Assert.fail; | |||||
import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem; | import org.apache.poi.poifs.filesystem.POIFSFileSystem; | ||||
import org.apache.poi.ss.formula.ptg.Area3DPtg; | import org.apache.poi.ss.formula.ptg.Area3DPtg; | ||||
import org.apache.poi.ss.usermodel.BaseTestWorkbook; | import org.apache.poi.ss.usermodel.BaseTestWorkbook; | ||||
import org.apache.poi.ss.usermodel.Cell; | |||||
import org.apache.poi.ss.usermodel.FormulaEvaluator; | |||||
import org.apache.poi.ss.usermodel.Name; | import org.apache.poi.ss.usermodel.Name; | ||||
import org.apache.poi.ss.usermodel.Row; | |||||
import org.apache.poi.ss.usermodel.Sheet; | |||||
import org.apache.poi.ss.util.CellRangeAddress; | import org.apache.poi.ss.util.CellRangeAddress; | ||||
import org.apache.poi.ss.util.CellUtil; | |||||
import org.apache.poi.util.LittleEndian; | import org.apache.poi.util.LittleEndian; | ||||
import org.apache.poi.util.TempFile; | import org.apache.poi.util.TempFile; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
private void expectName(HSSFWorkbook wb, String name, String expect) { | private void expectName(HSSFWorkbook wb, String name, String expect) { | ||||
assertEquals(expect, wb.getName(name).getRefersToFormula()); | assertEquals(expect, wb.getName(name).getRefersToFormula()); | ||||
} | } | ||||
@Test | |||||
public void test55747() throws IOException { | |||||
HSSFWorkbook wb = new HSSFWorkbook(); | |||||
Sheet sheet =wb.createSheet("Test1"); | |||||
Row row =sheet.createRow(0); | |||||
CellUtil.createCell(row, 0, "Hello world."); | |||||
row = sheet.createRow(1); | |||||
Cell cell = row.createCell(0); | |||||
cell.setCellType(Cell.CELL_TYPE_FORMULA); | |||||
cell.setCellFormula("IF(ISBLANK(A1),\" not blank a1\",CONCATENATE(A1,\" - %%s.\"))"); | |||||
Cell cell2 = row.createCell(1); | |||||
cell2.setCellType(Cell.CELL_TYPE_FORMULA); | |||||
cell2.setCellFormula("CONCATENATE(A1,\" - %%s.\")"); | |||||
Cell cell3 = row.createCell(2); | |||||
cell3.setCellType(Cell.CELL_TYPE_FORMULA); | |||||
cell3.setCellFormula("ISBLANK(A1)"); | |||||
wb.setForceFormulaRecalculation(true); | |||||
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); | |||||
for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) { | |||||
sheet = wb.getSheetAt(sheetNum); | |||||
for(Row r : sheet) { | |||||
for(Cell c : r) { | |||||
if(c.getCellType() == Cell.CELL_TYPE_FORMULA) { | |||||
evaluator.evaluateFormulaCell(c); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
cell = row.getCell(0); | |||||
assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType()); | |||||
assertEquals("IF(ISBLANK(A1),\" not blank a1\",CONCATENATE(A1,\" - %%s.\"))", cell.getCellFormula()); | |||||
assertEquals("Hello world. - %%s.", cell.getStringCellValue()); | |||||
cell2 = row.getCell(1); | |||||
assertEquals(Cell.CELL_TYPE_FORMULA, cell2.getCellType()); | |||||
assertEquals("CONCATENATE(A1,\" - %%s.\")", cell2.getCellFormula()); | |||||
assertEquals("Hello world. - %%s.", cell2.getStringCellValue()); | |||||
FileOutputStream stream = new FileOutputStream( "C:/temp/55747.xls"); | |||||
try { | |||||
wb.write(stream); | |||||
} finally { | |||||
stream.close(); | |||||
} | |||||
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb); | |||||
Sheet sheetBack = wb.getSheetAt(0); | |||||
Row rowBack = sheetBack.getRow(1); | |||||
cell = rowBack.getCell(0); | |||||
assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType()); | |||||
assertEquals("IF(ISBLANK(A1),\" not blank a1\",CONCATENATE(A1,\" - %%s.\"))", cell.getCellFormula()); | |||||
assertEquals("Hello world. - %%s.", cell.getStringCellValue()); | |||||
cell2 = rowBack.getCell(1); | |||||
assertEquals(Cell.CELL_TYPE_FORMULA, cell2.getCellType()); | |||||
assertEquals("CONCATENATE(A1,\" - %%s.\")", cell2.getCellFormula()); | |||||
assertEquals("Hello world. - %%s.", cell2.getStringCellValue()); | |||||
wbBack.close(); | |||||
wb.close(); | |||||
} | |||||
} | } |