I also tried to read from an xlsx file, but the result looks fine.
try (InputStream in =
Files.newInputStream(Paths.get("/path/to/RichText.xlsx"))) {
XSSFWorkbook workbook = new XSSFWorkbook(in);
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
XSSFCell cell = row.getCell(0);
XSSFRichTextString value = cell.getRichStringCellValue(); // value is not
null
System.out.println(value.getString()); // Hello, World!
System.out.println(value.getString().charAt(0)); // H
System.out.println(value.getFontAtIndex(0).getBold()); // true
System.out.println(value.getFontAtIndex(0).getItalic()); // true
System.out.println(value.getFontAtIndex(0).getUnderline()); // 1
System.out.println(value.getString().charAt(1)); // e
System.out.println(value.getFontAtIndex(1).getBold()); // false
System.out.println(value.getFontAtIndex(1).getItalic()); // false
System.out.println(value.getFontAtIndex(1).getUnderline()); // 0
}
Well, could you give me the file that fails to read?
Ryo Yamamoto
-----Original Message-----
From: Aruna [mailto:[email protected]]
Sent: Tuesday, January 14, 2014 4:12 PM
To: [email protected]
Subject: RE: Unable to read the fully formatted text from XSSF
Hi,
Thanks for your reply. The example given by you is working correctly. But, when
I am trying to fetch the cell data, if the cell data is "Hello World"
and "H" is not aligned with bold/italic/underline, i am able to get the rich
text string. But when "H" is bold/italic/underline, its returning null.
System.out.println(cell.getRichStringCellValue().getFontAtIndex(0));
the issue only when the cell is read from the .xlsx file.
Please help me to resolve this issue.
Thanks,
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/Unable-to-read-the-fully-formatted-text-from-XSSF-tp5714625p5714631.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional
commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]