cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Puerto <jav...@apache.org>
Subject Unable to create field with date format in POI block
Date Wed, 09 Jun 2010 13:34:20 GMT
Hi!

I'm working with Apache Cocoon 2.2 and POI block to generate a report in
excel format. http://cocoon.apache.org/2.1/userdocs/xls-serializer.html

I need the date, not the time part so I generated a gnumeric xml from a
xhtml table:

  <xsl:template match="xhtml:td">
    <xsl:param name="row"/>
    <gmr:Cell Row="{$row}" Col="{position() - 1}">
      <xsl:attribute name="ValueType">
        <xsl:choose>
          <xsl:when test="normalize-space(.) = ''">10</xsl:when>
          <xsl:when test="contains(@class, 'dfDate')">60</xsl:when>
          <xsl:when test="contains(@class, 'dfNumber')">40</xsl:when>
          <xsl:when test="contains(@class, 'dfFloat')">40</xsl:when>
          <xsl:otherwise>60</xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
      <xsl:apply-templates select="node()"/>
    </gmr:Cell>
  </xsl:template>

To add the date format I used the following StyleRegion:

<gmr:StyleRegion startCol="{position() - 1}" startRow="1"
endCol="{position() - 1}" endRow="{$rows}">
  <gmr:Style HAlign="1" VAlign="2" WrapText="0" ShrinkToFit="0" Rotation="0"
Shade="0" Indent="0" Hidden="0" Fore="0:0:0" Back="FFFF:FFFF:FFFF"
PatternColor="0:0:0" Format="dd.mm.yyyy"/>
</gmr:StyleRegion>

StyleRegion area was calculated correctly, I already checked this because I
format some numeric values and it works without problems with the same code.
To add a date I tried to set the value of the Cell tag with these patterns:
dd.MM.yyyy ,dd/MM/yyyy and yyyy/MM/dd

The serialized file does not correctly set the date field. When I open it
with MS Excel 2007 the cells format is "text". If I double click for edit
and then save the cell works setting the date correctly.

After that, I opened the file with Gnumeric 1.8.4 and save in gnumeric own
format, then I opened the file with a text editor. The date fields is stored
as the difference between 31/12/1899 and the date in days. I created a class
to obtain this values from a java.util.Date but the serializer can't render
it and shows as a number.

Can anybody help me? In my tests I was unable to set a cell as date
correctly.

Salu2.

Mime
View raw message