You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Damaresh Dashora <da...@gmail.com> on 2013/09/24 06:17:49 UTC
Excel Sheet Reading [Fetching Fonts for Perticular cell for complete sheet]
Hi,
I am new to the group of POI-Users.
Please help me for following.
How to read certain text font (for specific subscript, superscript
uppercase lowercase, italic bold etc.) in a perticular cell's.( Not for
complete cell, or not to set that format for complete cell) ?
like for Example : I have a cell in a spreadsheet (Excel sheet), in which
user write some text (string) in uppercase, some of the text is written in
lowercase or some of it in bold, italic or may be different in size or it's
font style(colour) is different. I want to read that cell's text as it is
in same formatting.
text in cell : *LIKE* *user's* Ques *and* *ABOVE.*
After reading complete cell string should look : *LIKE* *user's* Ques *and*
*ABOVE.*
Thanks.
Damaresh Dashora.
Re: Excel Sheet Reading [Fetching Fonts for Perticular cell for
complete sheet]
Posted by Damaresh Dashora <da...@gmail.com>.
Sorry, I forgot to mention, i want to do it for only *"xls"* type Excel
files.
On Tue, Sep 24, 2013 at 9:47 AM, Damaresh Dashora <da...@gmail.com>wrote:
> Hi,
>
> I am new to the group of POI-Users.
> Please help me for following.
>
> How to read certain text font (for specific subscript, superscript
> uppercase lowercase, italic bold etc.) in a perticular cell's.( Not for
> complete cell, or not to set that format for complete cell) ?
>
> like for Example : I have a cell in a spreadsheet (Excel sheet), in which
> user write some text (string) in uppercase, some of the text is written in
> lowercase or some of it in bold, italic or may be different in size or it's
> font style(colour) is different. I want to read that cell's text as it is
> in same formatting.
>
> text in cell : *LIKE* *user's* Ques *and* *ABOVE.*
> After reading complete cell string should look : *LIKE* *user's* Ques *and
> * *ABOVE.*
>
> Thanks.
>
> Damaresh Dashora.
>
Re: Excel Sheet Reading [Fetching Fonts for Perticular cell for
complete sheet]
Posted by Damaresh Dashora <da...@gmail.com>.
Thank You.
On Tue, Sep 24, 2013 at 7:28 PM, Nick Burch <ap...@gagravarr.org> wrote:
> On Tue, 24 Sep 2013, Damaresh Dashora wrote:
>
>> Now, using that HSSFFont Object i'm fetching colour in this way (below
>> mentioned)....
>>
>> int color = hssfFont.getColor(); //hssfFont is the object created
>> String fontColor = HSSFExcelColorMap.getHexCode(**color);
>>
>
> I don't know where "HSSFExcelColorMap" comes from, but I'm not sure it's
> one of ours...
>
> http://poi.apache.org/apidocs/**org/apache/poi/hssf/usermodel/**
> HSSFPalette.html<http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPalette.html>is what you want to use to turn an HSSF color index into an object with
> red/green/blue values
>
>
> Nick
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.**org<us...@poi.apache.org>
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: Excel Sheet Reading [Fetching Fonts for Perticular cell for
complete sheet]
Posted by Nick Burch <ap...@gagravarr.org>.
On Tue, 24 Sep 2013, Damaresh Dashora wrote:
> Now, using that HSSFFont Object i'm fetching colour in this way (below
> mentioned)....
>
> int color = hssfFont.getColor(); //hssfFont is the object created
> String fontColor = HSSFExcelColorMap.getHexCode(color);
I don't know where "HSSFExcelColorMap" comes from, but I'm not sure it's
one of ours...
http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPalette.html
is what you want to use to turn an HSSF color index into an object with
red/green/blue values
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Excel Sheet Reading [Fetching Fonts for Perticular cell for
complete sheet]
Posted by Damaresh Dashora <da...@gmail.com>.
Hi Nick,
I tried to do in the same way (by using RichTextString), but it is giving
errors (different colours) for colours other than declared colours in the
HSSFExcelColorMap.
(there are some standard colors declared here in this class).
Below is the example what i am exactly doing -
I am reading string (RichTextString) character by character, fetching the
substring which have same font-index by using function getFontAtIndex().
and then i am using that font index value, to create an object of HSSFFont
(by passing font index value and HSSFWorkbook in a function that return
HSSFFont object to me).
Now, using that HSSFFont Object i'm fetching colour in this way (below
mentioned)....
int color = hssfFont.getColor(); //hssfFont is the object created
String fontColor = HSSFExcelColorMap.getHexCode(color);
Now using fontColor, i'm fetching that color in hex - value but for some
color there is no value mentioned in the HSSFExcelColorMap class.
For example : for green color, integer value (variable : color) is 50 but
there is no color mentioned in that map for that color value, and atlast it
appears orange in the output, same thing for red (standard blue is the
output for that).
I have also attached a snippet of Excel sheet cell (I take it as a test for
my code). Some of the color in that cell appears right some of them are
changed.
Damaresh.
On Tue, Sep 24, 2013 at 3:58 PM, Nick Burch <ap...@gagravarr.org> wrote:
> On Tue, 24 Sep 2013, Damaresh Dashora wrote:
>
>> How to read certain text font (for specific subscript, superscript
>> uppercase lowercase, italic bold etc.) in a perticular cell's.( Not for
>> complete cell, or not to set that format for complete cell) ?
>>
>
> http://poi.apache.org/apidocs/**org/apache/poi/ss/usermodel/**
> RichTextString.html<http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/RichTextString.html>
> is probably want you want. It lets you nibble your way along the text in a
> single cell, reading off the different formatting that applies to different
> bits of it
>
> Nick
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.**org<us...@poi.apache.org>
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: Excel Sheet Reading [Fetching Fonts for Perticular cell for
complete sheet]
Posted by Nick Burch <ap...@gagravarr.org>.
On Tue, 24 Sep 2013, Damaresh Dashora wrote:
> How to read certain text font (for specific subscript, superscript
> uppercase lowercase, italic bold etc.) in a perticular cell's.( Not for
> complete cell, or not to set that format for complete cell) ?
http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/RichTextString.html
is probably want you want. It lets you nibble your way along the text in a
single cell, reading off the different formatting that applies to
different bits of it
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org