Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSL 101 question. Please help.

From: "Chad" <chad.dokmanovich@------.--->
To: NULL
Date: 11/1/2006 6:18:00 PM

I need to write a common routine that may be called by web pages to produce 
a FORMATTED excel documented. I cannot use MS Office. I've considered many 
methods, butam leaning torwards XML/XSL. I found this article which got me 
started:

http://support.microsoft.com/kb/307021/

My routined will accept a query string, it will run it, and then create and 
Excel doc. What I do not know how to do is to format a date in 31-Dec-2006 
style. I also want to be able to display some dates in the style 31-Dec-2006 
12:59 PM.

Can someone please help? I was trying to use the Styles StyleDate and 
StyleDateTime (see below), but these were not working because the data that 
was in the "MyDate" Sql Server DateTime column was written in a format 
similar to this 2006/12/31/ 12:59:00.223:0500 (or something close-you 
probably know what I mean). As a result, the Style was not applied to the 
datetime value.

Here's my XSL file so far. If someone could help, I'd be grateful.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">
  <xsl:template match="/">
    <HTML>
      <HEAD>
        <STYLE>
          .HDR { background-color:bisque;font-weight:bold }
.style0
          {
          mso-number-format:General;
          text-align:general;
          vertical-align:bottom;
          white-space:nowrap;
          mso-rotate:0;
          mso-background-source:auto;
          mso-pattern:auto;
          color:windowtext;
          font-size:10.0pt;
          font-weight:400;
          font-style:normal;
          text-decoration:none;
          font-family:Arial;
          mso-generic-font-family:auto;
          mso-font-charset:0;
          border:none;
          mso-protection:locked visible;
          mso-style-name:Normal;
          mso-style-id:0;
          }
          .StyleDate
          {
          mso-style-parent:style0;
          mso-number-format:"Medium Date";
          }
.StyleNumber
          {
          mso-style-parent:style0;
          mso-number-format:"0\.000";
          text-align:right;
          }
          .StyleMoney
          {
          mso-style-parent:style0;
          mso-number-format:"0\.00";
          text-align:right;
          }
.StyleDateTime
   {
   mso-style-parent:style0;
   mso-number-format:"d\\-mmm\\-yy\\ h\:mm\\ AM\/PM";
   }
        </STYLE>
      </HEAD>
      <BODY>
        <TABLE>
          <COLGROUP WIDTH="100" ALIGN="CENTER"></COLGROUP>
          <COLGROUP WIDTH="200" ALIGN="LEFT"></COLGROUP>
          <COLGROUP WIDTH="200" ALIGN="LEFT"></COLGROUP>
          <COLGROUP WIDTH="100" ALIGN="LEFT"></COLGROUP>
          <COLGROUP WIDTH="100" ALIGN="LEFT"></COLGROUP>
          <COLGROUP WIDTH="300" ALIGN="LEFT"></COLGROUP>
          <COLGROUP WIDTH="100" ALIGN="LEFT"></COLGROUP>
          <COLGROUP WIDTH="300" ALIGN="LEFT"></COLGROUP>
          <COLGROUP WIDTH="300" ALIGN="LEFT"></COLGROUP>
          <TD CLASS="HDR">Customer ID</TD>
          <TD CLASS="HDR">Company</TD>
          <TD CLASS="HDR">Contact</TD>
          <TD CLASS="HDR">Country</TD>
          <TD CLASS="HDR">Phone</TD>
          <TD CLASS="HDR">My Date Column</TD>
          <TD CLASS="HDR">Number</TD>
          <TD CLASS="HDR">Money</TD>
          <TD CLASS="HDR">My Date Time</TD>
          <xsl:for-each select="NewDataSet/Table">
            <TR>
              <TD>
                <xsl:value-of select="CustomerID"/>
              </TD>
              <TD>
                <xsl:value-of select="CompanyName"/>
              </TD>
              <TD>
                <xsl:value-of select="ContactName"/>
              </TD>
              <TD>
                <xsl:value-of select="Country"/>
              </TD>
              <TD>
                <xsl:value-of select="Phone"/>
              </TD>
              <TD CLASS="StyleDate">
                <xsl:value-of select="MyDate"/>
              </TD>
              <TD CLASS="StyleNumber">
                <xsl:value-of select="MyNumber"/>
              </TD>
              <TD CLASS="StyleMoney">
                <xsl:value-of select="MyMoney"/>
              </TD>
              <TD CLASS="StyleDateTime">
                <xsl:value-of select="MyDateTime"/>
              </TD>
            </TR>
          </xsl:for-each>
        </TABLE>
      </BODY>
    </HTML>
  </xsl:template>
</xsl:stylesheet>




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent