I think you assigned bold/italic/underline not to RichTextString but to
CellStyle(See the code below).
File fis = new File("/path/to/Test3.xlsx");
OPCPackage opcPackage = OPCPackage.open(fis.getAbsolutePath());
XSSFWorkbook wookbook = new XSSFWorkbook(opcPackage);
XSSFSheet sheet = wookbook.getSheetAt(0);
CellReference a1 = new CellReference("A1");
XSSFCell a1Cell = sheet.getRow(a1.getRow()).getCell(a1.getCol());
XSSFCellStyle a1Style = a1Cell.getCellStyle();
XSSFFont a1Font = wookbook.getFontAt(a1Style.getFontIndex());
System.out.println(a1Font.getUnderline()); // 1
System.out.println(a1Font.getBold()); // true
System.out.println(a1Font.getItalic()); // true
CellReference b1 = new CellReference("B1");
XSSFRow b1Row = sheet.getRow(b1.getRow());
XSSFCell b1Cell = b1Row.getCell(b1.getCol());
XSSFRichTextString value = b1Cell.getRichStringCellValue();
XSSFFont b1Font = value.getFontAtIndex(6);
System.out.println(b1Font.getBold()); // true
Ryo Yamamoto
-----Original Message-----
From: Aruna [mailto:[email protected]]
Sent: Wednesday, January 15, 2014 1:52 PM
To: [email protected]
Subject: RE: Unable to read the fully formatted text from XSSF
Hi
I have tried the same example given by u. I was using POI 3.8 before. I changed
my jar from 3.8 to 3.9. Still same issue.
Please help me...its urgent
Attached my .xlsx file also. Test6.xlsx
<http://apache-poi.1045710.n5.nabble.com/file/n5714654/Test6.xlsx>
try {
File fis = new File(filePathName);
InputStream in = new FileInputStream(fis);
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
//Hello World is bold and italic
System.out.println(value.getString()); //
Hello, World!
System.out.println(value.getString().charAt(0)); // H
System.out.println(value.getFontAtIndex(0).getBold()); //
throwing null pointer exception
}
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/Unable-to-read-the-fully-formatted-text-from-XSSF-tp5714625p5714654.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]