You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Francisco2626 <fa...@isaltda.com.uy> on 2011/04/06 14:53:04 UTC
[HWPF] Paragraph & Table colors
How can I get the paragraph, text highlight and table cell background color?
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/HWPF-Paragraph-Table-colors-tp4286210p4286210.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: [HWPF] Paragraph & Table colors
Posted by Mark Beardsley <ma...@tiscali.co.uk>.
The background colour of the paragraph, now I do not know if that is
acessible. The best place to start looking would be with the paragraph
style. Having said that, here goes, from the Paragraph object, you can get
the style index by calling the getStyleIndex() method. From the HWPFDocument
object, it should be possible to get the StyleSheet by calling the
getStyleSheet() method of that object. On the StyleSheet object, you can
call the getParagraphStyle(int) method and pass the value returned from the
original call to the getStyleIndex() method. That will return to you an
instance of the ParagarphProperties class that you can then interrogate. It
contains methods that will give you information about the Paragraph itself
but I am not so certain that will give you the background colour of the
paragraph - even though it does contain a method called getShading() and I
am not at all sure what that does.
There is also a CharacterProperties class. Again, it is accessible from the
StyleSheet object and it does contain methods called isHighlighted() and
even setHighlighted(). Sadly though I cannot see any method that allows you
to get at the colour of the highlight if the text is highlighted. There is a
getColor() method but I suspect that all that does is return the index of
the colour for the character(s) rather than the background. Many of these
same methods are accessible from the CharacterRun class and I would expect
that HWPF will create CharacterRun objects for the un-highlighted and
highlighted portions of the paragraph of text.
All the best because I have never done anything like this myself and the
above is all conjecture based on working through the javadocs - and let us
know if you make any progress. HWPF is an immature api that is need of good
developers - hint - and if you intend to do a lot of work with it, perhaps
you could consider becoming involved in pushing the project forward.
Yours
Mark B
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/HWPF-Paragraph-Table-colors-tp4286210p4286795.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: [HWPF] Paragraph & Table colors
Posted by Francisco2626 <fa...@isaltda.com.uy>.
Sorry. I'm talking about paragraph background color and highlight text color.
And example here:
http://apache-poi.1045710.n5.nabble.com/file/n4286728/Dibujo.jpg
See the paragraph background color is brown and text highlight is green.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/HWPF-Paragraph-Table-colors-tp4286210p4286728.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: [HWPF] Paragraph & Table colors
Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Forgive me please because I am not at all clear what you are asking. When you
say 'get the paragraph' what exactly does this mean? Are you asking how to
get at the contents of a table cell - that will usually be encapsulated in a
Paragraph object? What do you mean by the text highlight? Are you asking how
to tell if the text is underlined, emboldened, italicised, drawn in a
different font or colour?
One question I can answer is that it currently not possible - using HWPF -
to get at the background colour of the table cell. If you would be willing
to look into enhnacing the api to add this feature, then I am certain there
would be a number of users who would appreciate your efforts. If you do want
to get involved, take a look here - http://poi.apache.org/guidelines.html
Yours
Mark B
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/HWPF-Paragraph-Table-colors-tp4286210p4286622.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: [HWPF] Paragraph & Table colors
Posted by Ben <dj...@hotmail.com>.
Francisco2626 <falvarez <at> isaltda.com.uy> writes:
>
> How can I get the paragraph, text highlight and table cell background color?
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/HWPF-
Paragraph-Table-colors-tp4286210p4286210.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
Ok, i'm pretty new to this so it might not be the best solution but in a first
look that what i cam out with to find the background color
CharacterProperties cpp= par.getCharacterRun(j).cloneProperties();
short bgcolor=cpp.getHighlight();
from some reason i don't find a way to do it straight from the character run,
and that what make me think that this is not the best solution, but it does
the job, any way now you'll need to figure the colors, which should be the
easy part, hope this helps.
Ben.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org