ASF Bugzilla – Attachment 31538 Details for
Bug 56380
Cannot create more than 1024 cell comments by sheet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Update unit test
CellCommentsTest.java (text/plain), 3.47 KB, created by
Dominik Stadler
on 2014-04-17 12:16:29 UTC
(
hide
)
Description:
Update unit test
Filename:
MIME Type:
Creator:
Dominik Stadler
Created:
2014-04-17 12:16:29 UTC
Size:
3.47 KB
patch
obsolete
>package ro.everlight.catalog.imports; > >import java.io.File; >import java.io.FileInputStream; >import java.io.FileOutputStream; > >import junit.framework.Assert; > >import org.apache.poi.hssf.usermodel.HSSFWorkbook; >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.ss.usermodel.Workbook; >import org.junit.Test; > >/** > * > * @author Elvis Ciocoiu > * > */ >public class CellCommentsTest { > > @Test > public void testBug56380InsertComments() throws Exception { > HSSFWorkbook workbook = new HSSFWorkbook(); > Sheet sheet = workbook.createSheet(); > Drawing drawing = sheet.createDrawingPatriarch(); > int noOfRows = 1025; > 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); > > // 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(); > }*/ > > // assert that the comments are created properly after reading back in > checkComments(sheet, noOfRows, comment); > } > > private void checkComments(Sheet sheet, int noOfRows, String comment) { > for(int i = 0; i < noOfRows; i++) { > assertNotNull(sheet.getRow(i)); > assertNotNull(sheet.getRow(i).getCell(0)); > assertNotNull("Did not get a Cell Comment for row " + i, sheet.getRow(i).getCell(0).getCellComment()); > assertNotNull(sheet.getRow(i).getCell(0).getCellComment().getString()); > assertEquals(comment + i, sheet.getRow(i).getCell(0).getCellComment().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); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 56380
:
31505
| 31538