不行的话直接用fso写吧,
我一直这样
我一直这样
解决方案 »
- 一个动态创建div导致js无故失效的问题
- js的prototype的问题
- 怎么这段JS在DW能运行,VS不行?
- 请问 在 ext 2.0 grid 创建了 一个 CheckboxSelectionModel 的 checkbox 列,但为什么 checkbox 不能 打勾
- 用javaScript验证密码输入是否一致,当判断出不一致时,怎么才能重填表单呢?
- 怎样让 Html 变成文本编辑框?
- 谁知到图像缩放,拖拽是怎么实现的,类似go2map
- 看看我写的 JavaScript版仿Windows扫雷(源码)
- 关闭浏览器
- 怎么样把全角转换成半角?
- 如何实现mailto:[email protected]?subject=aaa&body=thebody 中的thebody可以加上回车呀
- username为空或不是对象?
sub ExportToExcel(Param)
if not window.confirm("导出为Excel文件吗?" & chr(13) & chr(10) & "提示:导出为Excel文件必须将IE本地安全级别设置为默认级别或者把自定义" & chr(13) & chr(10) & " 级别里第二个选项设置为禁用,否则Excel文件将直接保存到C盘目录下") then
Exit sub
end if
dim webToExcelobj '这个是一个iframe网页的对象,
set webToExcelobj = document.frames("MainFrame")
if not isObject(EXPORT_OBJECT) then
document.body.insertAdjacentHTML "afterBegin","<OBJECT style='display:none' classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>"
end if
'获取<html>*****</html>之间的内容
for i = 0 to webToExcelobj.document.all.length - 1
if webToExcelobj.document.all(i).tagName = "HTML" then
WebToExcel webToExcelobj.document.all(i).outerHTML
Exit for
end if
next
end sub sub WebToExcel(htmlString)
On Error Resume next
dim fileName
fileName = ExcelDescript
if Trim(fileName) = "" then
fileName = "HtmlToExcel"
end if
fileName = fileName & "_" & Report_ID
fileName = fileName & "_" & FormatDateTime(now, vbShortDate) & ""
if not isObject(EXPORT_OBJECT) then
document.body.insertAdjacentHTML "afterBegin","<OBJECT style='display:none' classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>"
end if
if isObject(EXPORT_OBJECT) then
EXPORT_OBJECT.DataType = "HTMLData"
EXPORT_OBJECT.HTMLData = htmlString
EXPORT_OBJECT.ActiveSheet.Export "C:\" & fileName & ".xls", 0
if Err.Number = 0 then
alert( "导出成功!")
end if
else
msgbox "导出为Excel文件失败,请确定已安装Excel2000(或更高版本)."
end if
end sub