当前位置:编程学习 > 网站相关 >>

关于"导出到EXCEL"按钮

怎么样实现“导出到excel”按钮的功能实现? --------------------编程问答-------------------- 自己写个VBA就可以了。我给你个一段例子代码。这是我现在在用的,挺好的。
Sub Initialize
Dim wks As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim excelApplication As Variant 
Dim excelWorkbook As Variant 
Dim excelSheet As Variant 
Dim docNum As Integer
Dim lines As Integer
Dim nstr As String
Set excelApplication = CreateObject("Excel.Application") 
excelApplication.Visible = True 
Set excelWorkbook = excelApplication.Workbooks.Add 
Set excelSheet = excelWorkbook.Worksheets("Sheet1")
excelSheet.Cells(1,1).Value = "部门"
excelSheet.Cells(1,2).Value = "请假日期"
excelSheet.Cells(1,3).Value = "请假人"
excelSheet.Cells(1,4).Value = "请假天数"
excelSheet.Cells(1,5).Value = "请假类别"
excelSheet.Cells(1,6).Value = "文档状态"
lines = 2
Set uidoc = wks.CurrentDocument
Set db = wks.CurrentDatabase.Database
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
While Not doc Is  Nothing
excelSheet.Cells(lines,1).Value = doc.GetItemValue("applybm")(0)
excelSheet.Cells(lines,2).Value = doc.GetItemValue("staDate")(0)
excelSheet.Cells(lines,3).Value = doc.GetItemValue("applyname")(0)
excelSheet.Cells(lines,4).Value = doc.GetItemValue("atd")(0)
excelSheet.Cells(lines,5).Value = doc.GetItemValue("applyfall")(0)
excelSheet.Cells(lines,6).Value = doc.GetItemValue("Status")(0)
lines=lines+1
Set doc = dc.GetNextDocument(doc)
Wend

End Sub
--------------------编程问答-------------------- 不错,又是一个思路,考下来看看怎样 --------------------编程问答-------------------- BS的话:
function getee(TBId) {
var divAle=document.createElement("div");
divAle.innerText="正在处理数据...";
divAle.position="absolute";
divAle.style.top="100";divAle.style.left="100";document.body.appendChild(divAle);
var oXL=new ActiveXObject("Excel.Application");
oXL.Visible=true;
var oWB=oXL.Workbooks.Add();
var oSheet=oWB.ActiveSheet;
var sel=document.body.createTextRange();

sel.moveToElementText(TBId);
sel.select();
sel.execCommand("Copy");
oSheet.Paste();
document.body.removeChild(divAle)
//document.all.contents.value=document.getElementById("hzbA4").innerHTML;
//document.all.btnSave.click();
alert("导出成功。");
location.href= location.href;
} --------------------编程问答-------------------- 访问视图得到的XML 文件,也可以变变的。 --------------------编程问答-------------------- 在代理中输入如下代码,在web上用一个按钮调用这个代理。在关系型数据库中导了10m的excel数据还是比较快的。最关键的是

Print |Content-Type:application/vnd.ms-excel|
Print |Content-Disposition:Attachment;charset="| & encoding & |";filename=| & fileName
Print |<HTML><HEAD><META http-equiv=Content-Type content="text/html; charset=|& encoding &|"></HEAD><Body>|

这两句代码
------------------------------------------------------------------------
'设置导出文件的类型为excel文档
Dim fileName As String
Dim encoding As String
fileName = docCGI.F_start_time(0) + "To" + docCGI.F_end_time(0) + ".xls"
encoding = "UTF-8"

Print |Content-Type:application/vnd.ms-excel|
Print |Content-Disposition:Attachment;charset="| & encoding & |";filename=| & fileName
Print |<HTML><HEAD><META http-equiv=Content-Type content="text/html; charset=|& encoding &|"></HEAD><Body>|

Dim htmlStr As String

htmlStr = htmlStr + |<table align=center width=100% style="font-size:12px">|

htmlStr = htmlStr + |<tr bgcolor=#cccccc>|
htmlStr = htmlStr + |<td>编  号</td>|
htmlStr = htmlStr + |<td>机器编号</td>|
htmlStr = htmlStr + |<td>产品类型</td>|
htmlStr = htmlStr + |<td>产品型号</td>|

htmlStr = htmlStr + |</tr>|

print |htmlStr|

Print |</table></BODY>| --------------------编程问答-------------------- 这些代码不知道怎么用!! 直接写按钮的lotusscript里面吗,这样的话在BS下按钮不见了.
@Command([ToolsRunMacro];"WWW")这样的话也不行...
郁闷,各位能不能指点下.多谢 --------------------编程问答-------------------- 把ming123e的代码写到你的那个功能表单的WebQuerySave事件的代理里就可以了。 --------------------编程问答-------------------- 一个简单的测试代理:
Sub Initialize
'定义界面工作空间
Dim workspace As New NotesUIWorkspace
'弹出一个确认对话框
Call workspace.Prompt(PROMPT_OK, "Say Hello", "Hello")
End Sub
-------------
怎么只能在CS下使用,BS下点击按钮无法显示网页呢? BS下要如何处理呢?
谢谢 --------------------编程问答--------------------
引用 3 楼 fanshenglove 的回复:
BS的话:
function getee(TBId) {
var divAle=document.createElement("div");
divAle.innerText="正在处理数据...";
divAle.position="absolute";
divAle.style.top="100";divAle.style.left="100";document.body.appe……

-------------
兄台的这个js可以用,能不能做到控制excel的列宽呢? 这个导入excel后很窄... --------------------编程问答-------------------- javascript有没有函数可以控制excel列宽的?
补充:企业软件 ,  Lotus
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,