You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Becky Cartine <bs...@yahoo.com> on 2012/02/10 14:56:02 UTC

Mixed Font Styles in one Cell

Is there a way to determine font style and other text formatting at the
character level within a given Cell?  For example, if part of the text in a Cell is bold. 

This is how I get the Font for a Cell:

            short fontIndex = cellStyle.getFontIndex();
            Font font = workbook.getFontAt(fontIndex);

In the Excel workbook I am working with, the text in the Cell has a trailing footnote symbol in superscript, however font.getTypeOffSet() returns a value of 0.





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Mixed Font Styles in one Cell

Posted by Yegor Kozlov <ye...@dinom.ru>.
In your cell the style of the footnote text overrides the cell style.
To get formatting of individual characters you need to iterate over
rich text:

        HSSFRichTextString rt = cell.getRichStringCellValue();
String text = rt.getString();                for(int i = 0; i <
text.length(); i++){            char c = text.charAt(i);
short fontIndex = rt.getFontAtIndex(i);            HSSFFont font =
workbook.getFontAt(fontIndex);                     }
Yegor
On Fri, Feb 10, 2012 at 5:56 PM, Becky Cartine <bs...@yahoo.com> wrote:
> Is there a way to determine font style and other text formatting at the
> character level within a given Cell?  For example, if part of the text in a Cell is bold.
>
> This is how I get the Font for a Cell:
>
>            short fontIndex = cellStyle.getFontIndex();
>            Font font = workbook.getFontAt(fontIndex);
>
> In the Excel workbook I am working with, the text in the Cell has a trailing footnote symbol in superscript, however font.getTypeOffSet() returns a value of 0.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org