Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从XML将数据导入Excel时格式化空日期_Xml_Excel_Asp Classic - Fatal编程技术网

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

从XML将数据导入Excel时格式化空日期,xml,excel,asp-classic,Xml,Excel,Asp Classic,我有一个经典的ASP页面,它通过XML生成Excel文件 Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment;filename=File.xls" XML文件头 <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadshe

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

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

<?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>

12525
15195
480
120
0
假的
假的
日期
然后针对每一行(仅显示日期列的示例)


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


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

找到解决方案了吗?解决方案是检查空日期。如果为空,则输出并排除标记。当我刚离开时,excel仍会按默认值生成1900.01.01日期在我的XML样式中,我有此样式。。然后,当我输出空日期时,单元格将为:。然后我的手机显示为空。抱歉-我不知道如何在此处设置答复的格式:)
<Row>
    <Cell ss:StyleID="s62"><Data ss:Type="DateTime"><% if objrs("DateCol")  <> #01/01/1902# then Response.write fncFormatDateXML(objrs("DateCol")) else response.write "" end if %></Data></Cell>
</Row>