从XML导入数据到Excel时格式化空日期

时间:2016-07-15 14:15:04

标签: xml excel asp-classic

我有一个经典的ASP页面,它通过XML生成Excel文件。

SELECT * 
FROM users 
WHERE cbe_user_birthday BETWEEN 
      cbe_user_birthday- INTERVAL 10 YEAR AND   
      cbe_user_birthday + INTERVAL 10 YEAR

XML文件标题

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=File.xls"

然后为每一行(仅显示日期列的示例)

<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
    <DownloadComponents/>
    <LocationOfComponents HRef="file:///\\"/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    <WindowHeight>12525</WindowHeight>
    <WindowWidth>15195</WindowWidth>
    <WindowTopX>480</WindowTopX>
    <WindowTopY>120</WindowTopY>
    <ActiveSheet>0</ActiveSheet>
    <ProtectStructure>False</ProtectStructure>
    <ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
    <Style ss:ID="Default" ss:Name="Normal">
        <Alignment ss:Vertical="Bottom"/>
        <Borders/>
        <Font/>
        <Interior/>
        <NumberFormat/>
        <Protection/>
    </Style>
    <Style ss:ID="s62">
        <NumberFormat ss:Format="dd/mm/yyyy;@"/>
    </Style>
</Styles>
    <Worksheet ss:Name="Sheet1">

<Table ss:ExpandedColumnCount="9" ss:ExpandedRowCount="<%=objRS.RecordCount + 1%>" x:FullColumns="1" x:FullRows="1">
<Row>
    <Cell><Data ss:Type="String">Date</Data></Cell>
</Row>

fncFormatDateXML将日期格式化为yyyy-mm-dd:T00:00:00.000,如果不是有效日期,则输出空字符串。

我遇到的问题是,如果日期单元格为空,则显示00/01/190,但我想成为一个空单元格。

0 个答案:

没有答案