ASF Bugzilla – Attachment 24470 Details for
Bug 48106
Cell Comments not visible using XSSF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Simple main() that writes/reads a cell comment to/from workbook
PoiTest2.java (text/plain), 1.76 KB, created by
Tom
on 2009-11-03 17:15:45 UTC
(
hide
)
Description:
Simple main() that writes/reads a cell comment to/from workbook
Filename:
MIME Type:
Creator:
Tom
Created:
2009-11-03 17:15:45 UTC
Size:
1.76 KB
patch
obsolete
>package org.gnf.tom.test; > >import java.io.FileOutputStream; > >import org.apache.poi.ss.usermodel.Cell; >import org.apache.poi.ss.usermodel.Comment; >import org.apache.poi.ss.usermodel.CreationHelper; >import org.apache.poi.xssf.usermodel.XSSFRichTextString; >import org.apache.poi.xssf.usermodel.XSSFSheet; >import org.apache.poi.xssf.usermodel.XSSFWorkbook; > >public class PoiTest2 { > > public static final String FILENAME = "poi_comment.xlsx"; > public static final String SHEET_NAME = "Sheet1"; > public static final String COMMENTS = "Cell Comments"; > public static final String COMMENTS_AUTHOR = "Comments Author"; > public static final String CELL_CONTENTS = "You should see comments in this cell"; > > public static void main(String[] args) throws Exception { > XSSFWorkbook wb = new XSSFWorkbook(); > XSSFSheet sheet = wb.createSheet(SHEET_NAME); > CreationHelper createHelper = wb.getCreationHelper(); > > // Create a cell in 0,0 > Cell cell = sheet.createRow(0).createCell((short) 0); > cell.setCellValue(new XSSFRichTextString(CELL_CONTENTS)); > > // Add comments to cell > Comment comment = sheet.createComment(); > comment.setString(createHelper.createRichTextString(COMMENTS)); > comment.setAuthor(COMMENTS_AUTHOR); > cell.setCellComment(comment); > > // Write out file > FileOutputStream out = new FileOutputStream(FILENAME); > wb.write(out); > out.close(); > > // Read the workbook back into POI > wb = new XSSFWorkbook(FILENAME); > sheet = wb.getSheet(SHEET_NAME); > comment = sheet.getCellComment(0, 0); > if(comment.getString().toString().equals(COMMENTS)){ > System.out.println("Comments readable from POI"); > } > > if(comment.getAuthor().equals(COMMENTS_AUTHOR)){ > System.out.println("Comment's author readable from POI"); > } > > } > >}
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 48106
:
24462
| 24470 |
24473
|
24474