Firstly, thank you for your reply. Its very informative and helpful.
1) Can I just check to make sure that I am clear about what you want to do,
you wish to enter some HTML and have Excel parse that within a cell to
present, in this case, the phrase 'My String' rendered in bold text?
My Reply: Yes. I want the phrase "My String" to be rendered in bold.
2) MS Excel parses the html and renders the phrase as bold when we paste the
content into a cell.
3) Please see the modified code which i am using for writing to excel.
HSSFCellStyle headerCellStyle;
HSSFWorkbook workBook = null;
HSSFFont headerFont = null;
workBook = new HSSFWorkbook();
headerFont = workBook.createFont();
headerFont.setFontName(headerFont.FONT_ARIAL);
headerFont.setBoldweight(headerFont.BOLDWEIGHT_BOLD);
String value = "<html>< b>My String </html>";
HSSFCell cell = row.createCell(0);
HSSFRichTextString textString = new HSSFRichTextString(value);
headerCellStyle = workBook.createCellStyle();
headerCellStyle.setFont(headerFont);
headerCellStyle.setWrapText(false);
cell.setCellStyle(headerCellStyle);
cell.setCellValue(textString);
4) Your suggestion to parse the html using parser and detect the formatting
and re-create the effect using CellStyle object may work, however, we may
have to handle lots of html tags and map to appropriate CellStyles.
5) Also, I am trying to copy the html string from a excel file and writing
to another column to see if it renders the parsed html. Will post back the
result in the forum once I have the result.
Thanks for your reply.
Me Simple wrote:
>
> Hi,
>
> I am using Apachi POI to create a excel file on runtime. The excel file
> may have variable number columns (number of columns depends on run time).
> The value for One of the column has HTML parsed html string as shown
> below:
>
> Listing 1:
>
> <html>My String</html>
>
> However, when I open the excel file, the HTML column appears as is and
> doesn't appear parsed like this one.
>
> Listing 2:
>
> My String
>
> Is there a way to display the html as shown in listing 2 in run time.
>
>
> thanks.
>
> The code used for creating a the cell is shown below:
>
>
> HSSFCellStyle headerCellStyle;
> HSSFWorkbook workBook = null;
>
> workBook = new HSSFWorkbook();
>
> HSSFCell cell = row.createCell(columnIndex);
> HSSFRichTextString textString = new HSSFRichTextString(value);
> headerCellStyle = workBook.createCellStyle();
> headerCellStyle.setFont(getHeaderFont());
> headerCellStyle.setWrapText(false);
>
> cell.setCellStyle(headerCellStyle);
> cell.setCellValue("<html>My String</html>");
>
--
View this message in context:
http://old.nabble.com/SHow-HTML-text-in-one-of-the-excel-cell-tp29144294p29152517.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]