[prev in list] [next in list] [prev in thread] [next in thread] 

List:       poi-user
Subject:    appending text to XSSFRichTextString
From:       bhavya <bhavyapillilli.5 () gmail ! com>
Date:       2014-01-15 16:52:20
Message-ID: 1389804740320-5714670.post () n5 ! nabble ! com
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic