You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by bhavya <bh...@gmail.com> on 2014/01/15 17:52:20 UTC
appending text to XSSFRichTextString
Hi,
I am reading text from cell of an .xlsx file.
OS is UBUNTU, POI version: 3.10
Now I want to append a string to the rich text read from the cell without
loosing the fonts applied to the text in cell [either cell level or the
string level]. Please help.
Below is the code snippet I have tried:
File fis = new File(filePathName);
XSSFWorkbook workbook = new XSSFWorkbook(fis.getAbsolutePath());
XSSFSheet sheet = workbook.getSheetAt(0);
OPCPackage opcPackage = OPCPackage.open(fis.getAbsolutePath());
XSSFWorkbook wb = new XSSFWorkbook(opcPackage);
CellReference cellReference = new CellReference(cellName);
XSSFRow row = sheet.getRow(cellReference.getRow());
XSSFCell cell = row.getCell(cellReference.getCol());
XSSFRichTextString cellText = cell.getRichStringCellValue();
System.out.println(cell.getRichStringCellValue().getFontAtIndex(0).getBold());
// true
XSSFRichTextString cellText1 = new XSSFRichTextString("a");
XSSFRichTextString s3 = new XSSFRichTextString(cellText.getString()
+ cellText1.getString());
cell.setCellValue(s3);
XSSFRichTextString cellText2 = cell.getRichStringCellValue();
System.out.println(cellText2.getFontAtIndex(0).getItalic()); //
throwing null pointer exception
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/appending-text-to-XSSFRichTextString-tp5714670.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org