cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Monkan <>
Subject Odd Behavior with HSSFSerializer
Date Wed, 25 Jun 2008 15:21:17 GMT

I produced a simple Excel document by querying my database and using the
HSSFSerializer. It's a simple document; the spreadsheet just formats the
data into the same grid layout you would see on a database GUI upon
submitting the query.

Anyway, I realized that no matter the numerical data that goes into the
HSSFSerializer, Excel defaults to outputting them with the trailing 0's cut
off. (22.90 becomes 22.9.)

I downloaded Gnumeric, formatted numbers to show 2 decimal places, saved the
document to Gnumeric XML, and opened it to see what XML was needed to format
the decimal properly. (I want all my numbers rounded to two decimal places.)

Here is the XML I currently use in my stylesheet:

          <xsl:when test="/page/title='MOU Alert'">
            <gmr:StyleRegion startCol="5" startRow="3" endCol="5">
              <xsl:attribute name="endRow">
select="count(/page/content/sql:rowset/sql:row)+3" />
              <gmr:Style HAlign="1" VAlign="2" WrapText="0" ShrinkToFit="0"
Rotation="0" Shade="0" Indent="0" Locked="1" Hidden="0" Fore="0:0:0"
Back="FFFF:FFFF:FFFF" PatternColor="0:0:0" Format="0.00">
                <gmr:Font Unit="10" Bold="0" Italic="0" Underline="0"
StrikeThrough="0" Script="0">Arial</gmr:Font>

If you look at <gmr:Style>'s Format attribute, this is the input that is
needed to produce the correct decimal places. This specific snippet of code
should round all data in Column 6 (Gnumeric starts counting at 0, so Col="5"
is the sixth column) starting at row 3 and ending with the last row of data.

If you look at the count function under <xsl:attribute name="endRow">, this
returns the value 4500 from my particular test data. This dynamically tells
what row to stop applying the formatting to. There is no way to specify
unbounded for endRow, so this count function is the only way I can get it to
apply the formatting to every row for any instance of data queried.

Now here's the "odd behavior". This code works perfectly when I query data
that is a few hundred rows long. If there is, for example, 500 rows being
queried the count function correctly returns 503, which is the last row I
want formatted. (My data outputs on rows 3 to 503 to make room for a
heading.) But when I query data from around 700 or so upward (I haven't
found an exact cutoff yet), it will never apply the formatting. (All the
numbers will have trailing 0's cut off and not rounded to two decimal
places.) This is extremely irritating, and this will need to work for
thousands of rows. If I simply replace the count fuction with a number like
250, it works. (Rows 3-253 are formatted properly, and the few thousand
remaining are left unformatted.) If I start putting in values like 2000,
3500, 11480, it won't apply formatting to ANY row. It gives me the cold

I was wondering if anyone ran has run into a similar problem and knows a
fix. If I was ambiguous anywhere, just let me know and I'll clarify.

View this message in context:
Sent from the Cocoon - Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message