请教八爪鱼!!
我是个新手,所以把你说的导出为EXECL的第三种方法直接用了.但库中的内容写不进.XLS中.
我想打开XXJBB1中的内容.麻烦你帮我看看错在哪?同时还想问问,如果我想把查寻后符合条件
的人都写到EXECL中,这个循环该怎么写?这句是什么意?
xmlns="http://www.w3.org/TR/REC-html40">
这是我写的xmlToExcel.asp
<% set conn = server.createobject ("adodb.connection")
conn.open "FQ1", "sa", "123" '打开数据源'
strSelect="select * from XXJBB1" .
Set rs=server.createobject("adodb.recordset")
rs.open strSelect,conn,1,1
set fso=server.createobject("scripting.filesystemobject")
strXmlFile=server.MapPath("xmlToExcelTmp.xml")
strXslFile=server.MapPath("xmlToExcel.xsl")
strExcelFile=server.MapPath("xmlToExcel.xls")
if fso.fileExists(strXmlFile) then fso.deletefile strXmlFile
rs.save strXmlFile,1
rs.close
Conn.close
set Conn=nothing
set xmlDoc=server.createobject("microsoft.xmldom")
set xslDoc=server.createobject("microsoft.xmldom")
xslDoc.load(strXslFile)
xmlDoc.load(strXmlFile)
xmlDoc.loadXml(xmlDoc.transformNode(xslDoc))
if fso.fileExists(strExcelFile) then fso.deletefile strExcelFile
Set xslFile = fso.CreateTextFile(strExcelFile , True)
xslFile.WriteLine(xmlDoc.xml)
xslFile.Close
fso.deletefile strXmlFile
set fso=nothing
response.redirect "xmlToExcel.xls"
%>
<html xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema" xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html;"/>
<style>
.xl24{mso-style-parent:style0;mso-number-format:"\@";text-align:right;}
</style>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</head>
</html>
你写的xmlToExcel.xls代码,我直接就保存为的xmlToExcel.xls了.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<xsl:output method="html" indent="yes" />
<xsl:template match="xml/rs:data">
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<style>
.xl24{mso-style-parent:style0;mso-number-format:"\@";text-align:right;}
</style>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0">
<tr><xsl:for-each
select="/xml/s:Schema/s:ElementType/s:AttributeType">
<th><xsl:value-of select="@name" /></th>
</xsl:for-each>
</tr>
<xsl:apply-templates select="z:row" />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="z:row">
<xsl:variable name="position"><xsl:value-of select="position()"
/></xsl:variable>
<tr><xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType">
<!-- 读取定义好的数据列名 -->
<xsl:variable name="strColumn"><xsl:value-of
select="@name" /></xsl:variable>
<xsl:variable name="strValue"><xsl:value-of
select="/xml/rs:data/z:row[position()=$position]/@*[name() = $strColumn]" /></xsl:variable>
<td class="xl24">
<xsl:value-of select="$strValue" />
</td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
问题点数:0、回复次数:3Top
1 楼liuzxit(dotnetRGB.com)回复于 2003-12-03 08:25:31 得分 0
能保証正常select出數據后﹐如果仍沒看到需要的Excel內容的話﹖
1.估計是你的msxml版本低了吧﹐試試去MS下載個msxmlsp2或更高的版本安裝再看看
2.請確定你的FSO有足夠的讀寫權限
3.請保証沒打開同名的Excel文件
[如果我想把查寻后符合条件
的人都写到EXECL中,这个循环该怎么写?]?
不用循環﹐直接寫好Select語句即可
[xmlns="http://www.w3.org/TR/REC-html40">]?
這句是我把Excel文件另存為htm文件時﹐它就有這句﹐所以我照抄的﹐它是指定一個命名空間﹐估計在w3c中定義好的吧﹐只知照用而已
Top
2 楼fengquan()回复于 2003-12-03 12:54:24 得分 0
我在网上下了一个MSXML4.0SP2,远行报错:
xmlDoc.loadXml(xmlDoc.transformNode(xslDoc))出错
错误类型:
msxml3.dll (0x80004005)
/ks/xmltoexcel.asp, 第 24 行
Top
3 楼superdullwolf(超级大笨狼,每天要自强,MVP)回复于 2003-12-03 12:57:31 得分 0
www.adr.gov.cn/download/excel.rar
我做的,你参考吧,里面有点绝活!Top




