incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devin Han <simple...@gmail.com>
Subject FW: Bug 362 - BackgroundColor property doesn't work
Date Fri, 06 Jan 2012 03:51:33 GMT
http://odftoolkit.org/bugzilla/show_bug.cgi?id=362.

Forward this issue from ODF Toolkit Union mail list here. In case, it maybe
useful for someone else.
Thank  Vassilis <Vassilis@odftoolkit.org>!

------------------------------------------------------------------------------------------------------------------------------
Vassilis@odftoolkit.org 2011-12-31 23:52:08 UTC

I try to make a routine to make cutom styles for a spreadsheet. I ue the
following code:

    public static OdfStyle createStyle(String font, int size, String foreColor,
String backColor, String weight, String styleName, String styleFamily) {
        OdfStyle style;
        style = new OdfStyle(stylesDom);
        style.setProperty(StyleTextPropertiesElement.FontFamily, font);
        style.setProperty(StyleTextPropertiesElement.FontSize,
Integer.toString(size));
        style.setProperty(StyleTextPropertiesElement.Color, foreColor);
style.setProperty(OdfStyleTableCellProperties.BackgroundColor,backColor);
        style.setProperty(StyleTextPropertiesElement.FontWeight, weight);
        style.setStyleNameAttribute(styleName); //name cell style
        style.setStyleFamilyAttribute(styleFamily); //cell style
        style.setStyleParentStyleNameAttribute("Default"); //link to default
style
        styleDoc.appendChild(style);
        return style;
    }

Unfortunately the property for the background color does not work. All the
other properties work just fine.
Can you please check for a bug ?

[reply <http://odftoolkit.org/bugzilla/show_bug.cgi?id=362#add_comment>]
[-]<http://odftoolkit.org/bugzilla/show_bug.cgi?id=362#>
 Comment 1 <http://odftoolkit.org/bugzilla/show_bug.cgi?id=362#c1>
Vassilis@odftoolkit.org 2012-01-01 01:41:21 UTC

I found a workaround to solve the problem.

Actually the line

style.setProperty(OdfStyleTableCellProperties.BackgroundColor,backColor);

doesn't work. Instead I put the following and it works just fine.

style.newStyleTableCellPropertiesElement().setFoBackgroundColorAttribute(backColor);

[reply <http://odftoolkit.org/bugzilla/show_bug.cgi?id=362#add_comment>]
[-]<http://odftoolkit.org/bugzilla/show_bug.cgi?id=362#>
 Comment 2 <http://odftoolkit.org/bugzilla/show_bug.cgi?id=362#c2>
Devin@odftoolkit.org 2012-01-06 03:43:56 UTC

(In reply to comment #1 <http://odftoolkit.org/bugzilla/show_bug.cgi?id=362#c1>)
> I found a workaround to solve the problem.
>
> Actually the line
>
> style.setProperty(OdfStyleTableCellProperties.BackgroundColor,backColor);
>
> doesn't work. Instead I put the following and it works just fine.
>
> style.newStyleTableCellPropertiesElement().setFoBackgroundColorAttribute(backColor);

Hi,

Thank you for share your experience with us!

For your scenario, to avoid the similar issue, I suggest you use Simple ODF's
Table API directly. With the help of this API, you can set the style(color,
background color, alignment...) of cell directly.
See the cookbook:http://incubator.apache.org/odftoolkit/simple/document/cookbook/Cell.html
You can have a try following the Getting Start
Guide:http://incubator.apache.org/odftoolkit/simple/gettingstartguide.html.
For more information, please
reference:http://incubator.apache.org/odftoolkit/simple/index.html

Sorry for the delay response, as this mail list has not been maintaned. We have
migrated to Apache Incubator.
This is the new website: http://incubator.apache.org/odftoolkit/index.html
The new Mailing list for dev is    odf-dev@incubator.apache.org and for users
is odf-users@incubator.apache.org.
If you want to report bug, please submit
here:https://issues.apache.org/jira/browse/ODFTOOLKIT

Devin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message