You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "janek.schroeder" <fr...@gmail.com> on 2016/06/02 14:29:49 UTC

How to write normal and subscript text in one excel cell?

Hi,
I want to insert normal text and subscript/superscript (eg. CO2) in one
excel cell. Here is my code which set only subscript:

XSSFCellStyle style = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setTypeOffset(Font.SS_SUB);
style.setFont(font);

My problem is that I can assign only one XSSFCellStyle instance for cell. Is
there any possibility to mix SS_SUB and SS_NONE 



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-write-normal-and-subscript-text-in-one-excel-cell-tp5723194.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


Re: How to write normal and subscript text in one excel cell?

Posted by Javen O'Neal <ja...@gmail.com>.
Nick is right about RichText.

Also check out CellUtil#setCellStyleProperty, which will avoid creating
duplicate styles or unintentionally modifying other calls that share the
same style.
https://poi.apache.org/apidocs/org/apache/poi/ss/util/CellUtil.html#setCellStyleProperty(org.apache.poi.ss.usermodel.Cell,%20java.lang.String,%20java.lang.Object)
On Jun 2, 2016 8:07 AM, "Nick Burch" <ap...@gagravarr.org> wrote:

> On Thu, 2 Jun 2016, janek.schroeder wrote:
>
>> I want to insert normal text and subscript/superscript (eg. CO2) in one
>> excel cell.
>>
>
> You want to use RichTextString functionality. See the docs for more:
> http://poi.apache.org/spreadsheet/quick-guide.html#RichText
> And also some examples, eg
>
> https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: How to write normal and subscript text in one excel cell?

Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 2 Jun 2016, janek.schroeder wrote:
> I want to insert normal text and subscript/superscript (eg. CO2) in one
> excel cell.

You want to use RichTextString functionality. See the docs for more:
http://poi.apache.org/spreadsheet/quick-guide.html#RichText
And also some examples, eg
https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java

Nick

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