首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

100分急求asp导出到excel的有关问题!

2012-02-28 
100分急求asp导出到excel的问题!!服务器是公司的服务器,可以自己设置,但是网管那里不同意安装excel,所以我

100分急求asp导出到excel的问题!!
服务器是公司的服务器,可以自己设置,但是网管那里不同意安装excel,所以我从office里面找来了组件:MSOWC.DLL(2.94M),以前我曾经安装过这个组件,就可以用了,但是现在不行了:
提示:
Microsoft   VBScript   运行时错误   错误   '800a01ad '  

ActiveX   部件不能创建对象:   'Excel.Application '  

/hr/out.asp,行16
------------------------------------------------
程序代码:
set   objExcelApp   =CreateObject( "Excel.Application ")  
 
哪位能帮解决下,谢谢了,分不够可以再补。我QQ:123451234,验证:88888

我已经搜索了许多文章,还是不能解决。用aspcheck也检测不到Excel.Application,但是确实已经在服务器注册成功了这个组件。

[解决办法]
导出成.csv文件的行不,如果行的话你可以试试下面这段代码,我现在用来备份网站日志用的,可以正常使用,Message_clear过程可以再优化一下,因为我发现导出时因为一些特殊符号会造成结构出错

Response.AddHeader "Content-Disposition ", "attachment; filename=此处是文件名.csv "
Response.CharSet = "UTF-8 "
Response.ContentType = "application/octet-stream "
dim i,m
m=0
set rs = conn.Execute( "select * From [表名] order by id desc ")
Response.Write "字段1 "
Response.Write ", " & "字段2 "
Response.Write ", " & "字段3 "
Response.Write ", " & "字段4 "
Response.Write ", " & "字段5 "
Response.Flush()
do while not rs.eof
Response.Write vbCrLf & Message_clear(RemoveHTML(rs(0)))
for i=1 to rs.fields.count-1
Response.Write ", " & Message_clear(RemoveHTML(rs(i)))
next
Response.Flush()
rs.Movenext
loop
rs.Close
set rs = nothing

function Message_clear(body)
if trim(body)= " " then exit function
Message_clear = replace(body, ", ", ", ")
Message_clear = replace(Message_clear, "; ", "; ")
Message_clear = replace(Message_clear, " ' ", " ")
Message_clear = replace(Message_clear, "% ", "% ")
Message_clear = replace(Message_clear,chr(13)&chr(10), " ")
end function
[解决办法]
在服务器注册表中查找excel.appliction先.如果没就运行不了.

*****************************************************************************

用功譬若掘井,与其多掘数井而皆不及泉,何若老守一井,力求及泉而用之不竭乎?

[解决办法]
应该是权限问题,你的服务器是ntfs格式吧?
[解决办法]
我顶
[解决办法]
把读出的数据用<table>格式,在网页中显示出来,同时,加上下一句即可把EXCEL表在客客户端显示。

<%response.ContentType = "application/vnd.ms-excel "%>

  注意:显示的页面中,只把<table>输出,最好不要输出其他表格以外的信息。

[解决办法]
把客户的模板用Excel打开,然后“文件”-“另存为网页”。 保存好之后是一个扩展名为.htm的文件。
接着用文本编辑器打开,你会看到Excel的每一行数据其实对应这一个表格的 <tr> </tr> 。你要做的就是把数据添加到新的 <tr> </tr> 里就可以了。
[解决办法]
<![if !supportAnnotations]> <style id= "dynCom " type= "text/css "> <!-- --> </style>

<script language= "JavaScript "> <!--

function msoCommentShow(com_id,anchor_id) {
if(msoBrowserCheck()) {
c = document.all(com_id);
a = document.all(anchor_id);
if (null != c) {
var cw = c.offsetWidth;
var ch = c.offsetHeight;
var aw = a.offsetWidth;


var ah = a.offsetHeight;
var x = a.offsetLeft;
var y = a.offsetTop;
var el = a;
while (el.tagName != "BODY ") {
el = el.offsetParent;
x = x + el.offsetLeft;
y = y + el.offsetTop;
}
var bw = document.body.clientWidth;
var bh = document.body.clientHeight;
var bsl = document.body.scrollLeft;
var bst = document.body.scrollTop;
if (x + cw + ah/2 > bw + bsl && x + aw - ah/2 - cw > = bsl ) {
c.style.left = x + aw - ah / 2 - cw;
}
else {
c.style.left = x + ah/2;
}
if (y + ch + ah/2 > bh + bst && y + ah/2 - ch > = bst ) {
c.style.top = y + ah/2 - ch;
}
else {
c.style.top = y + ah/2;
}
c.style.visibility = "visible ";
}
}
}

function msoCommentHide(com_id) {
if(msoBrowserCheck()) {
c = document.all(com_id)
if (null != c) {
c.style.visibility = "hidden ";
c.style.left = "-10000 ";
c.style.top = "-10000 ";
}
}
}

function msoBrowserCheck() {
ms=navigator.appVersion.indexOf( "MSIE ");
vers = navigator.appVersion.substring(ms+5, ms+6);
ie4 = (ms> 0) && (parseInt(vers) > =4);
return ie4
}

if (msoBrowserCheck()) {
document.styleSheets.dynCom.addRule( ".msocomspan1 ", "position:absolute ");
document.styleSheets.dynCom.addRule( ".msocomspan2 ", "position:absolute ");
document.styleSheets.dynCom.addRule( ".msocomspan2 ", "left:-1.5ex ");
document.styleSheets.dynCom.addRule( ".msocomspan2 ", "width:2ex ");
document.styleSheets.dynCom.addRule( ".msocomspan2 ", "height:0.5em ");
document.styleSheets.dynCom.addRule( ".msocomanch ", "font-size:0.5em ");
document.styleSheets.dynCom.addRule( ".msocomanch ", "color:red ");
document.styleSheets.dynCom.addRule( ".msocomhide ", "display: none ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "visibility: hidden ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "position: absolute ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "top:-10000 ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "left:-10000 ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "width: 33% ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "background: infobackground ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "color: infotext ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "border-top: 1pt solid threedlightshadow ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "border-right: 2pt solid threedshadow ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "border-bottom: 2pt solid threedshadow ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "border-left: 1pt solid threedlightshadow ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "padding: 3pt 3pt 3pt 3pt ");
document.styleSheets.dynCom.addRule( ".msocomtxt ", "z-index: 100 ");
}

// -->
</script>
<![endif]> <!--[if gte mso 9]> <xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name> v_Export </x:Name>


<x:WorksheetOptions>
<x:DefaultRowHeight> 240 </x:DefaultRowHeight>
<x:Print>
<x:ValidPrinterInfo/>
<x:PaperSizeIndex> 9 </x:PaperSizeIndex>
<x:HorizontalResolution> 600 </x:HorizontalResolution>
<x:VerticalResolution> 600 </x:VerticalResolution>
</x:Print>
<x:Selected/>
<x:LeftColumnVisible> 2 </x:LeftColumnVisible>
<x:Panes>
<x:Pane>
<x:Number> 3 </x:Number>
<x:ActiveRow> 17 </x:ActiveRow>
<x:ActiveCol> 4 </x:ActiveCol>
</x:Pane>
</x:Panes>
<x:ProtectContents> False </x:ProtectContents>
<x:ProtectObjects> False </x:ProtectObjects>
<x:ProtectScenarios> False </x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight> 10830 </x:WindowHeight>
<x:WindowWidth> 15480 </x:WindowWidth>
<x:WindowTopX> 360 </x:WindowTopX>
<x:WindowTopY> 75 </x:WindowTopY>
<x:AcceptLabelsInFormulas/>
<x:ProtectStructure> False </x:ProtectStructure>
<x:ProtectWindows> False </x:ProtectWindows>
</x:ExcelWorkbook>
<x:ExcelName>
<x:Name> v_Export </x:Name>
<x:Formula> =v_Export!$A$1:$J$1 </x:Formula>
</x:ExcelName>
</xml> <![endif]--> <!--[if gte mso 9]> <xml>
<o:shapedefaults v:ext= "edit " spidmax= "1026 "/>
</xml> <![endif]--> <!--[if gte mso 9]> <xml>
<o:shapelayout v:ext= "edit ">
<o:idmap v:ext= "edit " data= "1 "/>
</o:shapelayout> </xml> <![endif]-->
</head>

<body link=blue vlink=fuchsia>


[解决办法]
都挺牛的
[解决办法]
<table x:str border=0 cellpadding=0 cellspacing=0 width=989 style= 'border-collapse:
collapse;table-layout:fixed;width:743pt '>
<col width=144 style= 'mso-width-source:userset;mso-width-alt:5266;width:108pt '>
<col width=150 style= 'mso-width-source:userset;mso-width-alt:5485;width:113pt '>
<col width=136 style= 'mso-width-source:userset;mso-width-alt:4973;width:102pt '>
<col width=64 style= 'width:48pt '>
<col width=93 style= 'mso-width-source:userset;mso-width-alt:3401;width:70pt '>
<col width=64 style= 'width:48pt '>
<col width=73 style= 'mso-width-source:userset;mso-width-alt:2669;width:55pt '>
<col width=74 style= 'mso-width-source:userset;mso-width-alt:2706;width:56pt '>
<col width=79 style= 'mso-width-source:userset;mso-width-alt:2889;width:59pt '>
<col width=112 style= 'mso-width-source:userset;mso-width-alt:4096;width:84pt '>
<tr class=xl25 height=16 style= 'height:12.0pt '>
<td height=16 class=xl25 width=144 style= 'height:12.0pt;width:108pt '
x:str= " '铃音编号 "> <a name= "v_Export "> 铃音编号 </a> </td>
<td class=xl25 width=150 style= 'width:113pt ' x:str= " '歌曲名称 "> 歌曲名称 </td>
<td class=xl25 width=136 style= 'width:102pt ' x:str= " '歌手 "> 歌手 </td>


<td class=xl25 width=64 style= 'width:48pt ' x:str= " '价格 "> 价格 </td>
<td class=xl25 width=93 style= 'width:70pt ' x:str= " '6月下载 "> 6月下载 </td>
<td class=xl25 width=64 style= 'width:48pt ' x:str= " '7月下载 "> 7月下载 </td>
<td class=xl25 width=73 style= 'width:55pt ' x:str= " 'SP名称 "> SP名称 </td>
<td class=xl25 width=74 style= 'width:56pt ' x:str= " '服务商 "> 服务商 </td>
<td class=xl25 width=79 style= 'width:59pt ' x:str= " '下载增量 "> 下载增量 </td>
<td class=xl25 width=112 style= 'width:84pt ' x:str= " '有效期 "> 有效期 <![if !supportAnnotations]> <span
class=msocomspan1> <span class=msocomspan2 id= "_anchor_1 "
onmouseover= "msoCommentShow( '_com_1 ', '_anchor_1 ') "
onmouseout= "msoCommentHide( '_com_1 ') " language=JavaScript> <a
class=msocomanch href= "#_msocom_1 " name= "_msoanchor_1 "> [1] </a> </span> </span> <![endif]> </td>
</tr>
<tr height=16 style= 'height:12.0pt '>
<td height=16 style= 'height:12.0pt ' x:str= " '0220000379 "> 0220000379 </td>
<td x:str= " '好姑娘 "> 好姑娘 </td>
<td x:str= " '李晓杰 "> 李晓杰 </td>
<td x:str= " '3.00 "> 3.00 </td>
<td align=right x:num> 1836 </td>
<td align=right x:num> 2110 </td>
<td x:str= " '浙江思创 "> 浙江思创 </td>
<td x:str= " '安徽联通 "> 安徽联通 </td>
<td align=right x:num> 274 </td>
<td class=xl24 align=right x:num= "1 "> 1900-1-1 </td>
</tr>
<tr height=16 style= 'height:12.0pt '>
<td height=16 style= 'height:12.0pt ' x:str= " '0220000320 "> 0220000320 </td>
<td x:str= " '好姑娘 "> 好姑娘 </td>
<td x:str= " '李晓杰 "> 李晓杰 </td>
<td x:str= " '2.00 "> 2.00 </td>
<td align=right x:num> 5601 </td>
<td align=right x:num> 5755 </td>
<td x:str= " '浙江思创 "> 浙江思创 </td>
<td x:str= " '安徽联通 "> 安徽联通 </td>
<td align=right x:num> 154 </td>
<td class=xl24 align=right x:num= "1 "> 1900-1-1 </td>
</tr>
<![if supportMisalignedColumns]>
<tr height=0 style= 'display:none '>
<td width=144 style= 'width:108pt '> </td>
<td width=150 style= 'width:113pt '> </td>
<td width=136 style= 'width:102pt '> </td>
<td width=64 style= 'width:48pt '> </td>
<td width=93 style= 'width:70pt '> </td>
<td width=64 style= 'width:48pt '> </td>
<td width=73 style= 'width:55pt '> </td>
<td width=74 style= 'width:56pt '> </td>
<td width=79 style= 'width:59pt '> </td>
<td width=112 style= 'width:84pt '> </td>
</tr>
<![endif]>
</table>

<div style= 'mso-element:comment-list '> <![if !supportAnnotations]>

<hr class=msocomhide align=left size=1 width= "33% ">

<![endif]>



<div style= 'mso-element:comment '> <![if !supportAnnotations]>

<div id= "_com_1 " class=msocomtxt
onmouseover= "msoCommentShow( '_com_1 ', '_anchor_1 ') "
onmouseout= "msoCommentHide( '_com_1 ') " language=JavaScript> <![endif]>

<div> <![if !supportAnnotations]> <a class=msocomhide href= "#_msoanchor_1 "
name= "_msocom_1 "> [1] </a> <![endif]> <!--[if gte mso 9]> <xml>
<v:shapetype id= "_x0000_t202 " coordsize= "21600,21600 " o:spt= "202 " path= "m,l,21600r21600,l21600,xe ">
<v:stroke joinstyle= "miter "/>
<v:path gradientshapeok= "t " o:connecttype= "rect "/>
</v:shapetype> <v:shape id= "_x0000_s1025 " type= "#_x0000_t202 " style= 'position:absolute;
margin-left:774pt;margin-top:83.25pt;width:96pt;height:59.25pt;z-index:1;
visibility:hidden ' fillcolor= "infoBackground [80] " o:insetmode= "auto ">
<v:fill color2= "infoBackground [80] "/>
<v:shadow on= "t " color= "black " obscured= "t "/>
<v:path o:connecttype= "none "/>
<v:textbox style= 'mso-direction-alt:auto '/>
<x:ClientData ObjectType= "Note ">
<x:MoveWithCells/>
<x:SizeWithCells/>
<x:AutoFill> False </x:AutoFill>
<x:Row> 0 </x:Row>
<x:Column> 9 </x:Column>
<x:Author> pisces </x:Author>
</x:ClientData>
</v:shape> </xml> <![endif]--> <![if !vml]> <span style= 'mso-ignore:vglayout '> <![endif]>

<div v:shape= "_x0000_s1025 " style= 'padding:.75pt 0pt 0pt .75pt;text-align:left '
class=shape> <font class= "font7 "> pisces: </font> <font class= "font6 "> <br>
1900-1-1表示已经过期 </font> </div>

<![if !vml]> </span> <![endif]> </div>

<![if !supportAnnotations]> </div>

<![endif]> </div>

</div>

</body>

</html>
[解决办法]
拷贝上面代码,保存为.asp文件,运行即可得到一个excel文件。

PS:就连Excel里的批注,也同样可以生成为,html+javascript格式。

热点排行