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? Well, I know
that Excel does support this - if I cut you example test out of the message
and then paste it into an Excel cell, Excel will embolden the String - but I
am not sure how to accomplish this using POI and need to play with some code
today.
One thing I did note - and this is by no way a criticism - you create the
HSSFRichTextString and then never use it. It may be worthwhile - as a test -
refactoring your code to look like this;
HSSFCellStyle headerCellStyle;
HSSFWorkbook workBook = null;
String value = "<html>My String</html>";
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(value);
to see if that has any effect - and I do not know that it will.
Secondly, see what happens when you do not explcitly apply a cell style to
the cell, so;
HSSFWorkbook workBook = null;
String value = "<html>My String</html>";
workBook = new HSSFWorkbook();
HSSFCell cell = row.createCell(columnIndex);
HSSFRichTextString textString = new HSSFRichTextString(value);
cell.setCellValue(value);
as I am wondering if this has any impact on the way Excel parses the file.
If this turns out to be one of the problems, then try applying the style
'treatments' to the cell incrementally to discover which affects the cells
contants detrimentally.
Will post again if I make any progress.
Yours
Mark B
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-tp29144294p29147186.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]