-- 作者:blackzhu
-- 发布时间:2013/1/7 11:06:00
--
保存报表
报表除打印之外,通过下面两个方法,还可以保存为htm或者pdf格式的文件。
- SaveHTM
将报表保存为HTM格式的文件。
- SavePDF
将报表保存为PDF格式的文件。
示例
Dim doc As New
PrintDoc
\'定义一个新报表 Dim rt As New
prt.RenderTable
\'定义一个新表格 Dim ColNames As
String() =
New
String(){"客户","产品", "数量","单价","金额"} Dim drs As List(of
DataRow) =
DataTables("订单").Select("日期 = #"
&
Date.Today
&
"#") For c As Integer = 0 To ColNames.Length - 1
\'逐列设置和填入内容 rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
For
r
As
Integer = 0
To
drs.Count
-1
\'开始填入该列内容 rt.Cells(r + 1, c).Text = drs(r)(ColNames(c)) Next Next rt.Style.Gridlines.All = New
prt.Linedef(Color.Gray) doc.Body.Children.Add(rt) \'将表格加入到报表 doc.SaveHtm("c:\\data\\test.htm")
帮助还有呀?
|
-- 作者:易服
-- 发布时间:2013/1/7 11:15:00
--
我也看了帮助,按钮代码如下:
e.Form.Controls("Label3").text="导出中,请稍候..." Dim Time,Time1 As Date Time = Date.now Application.Doevents
If FileSys.DirectoryExists("D:\\My Documents\\学生成绩") Then \'目录存在 Else FileSys.CreateDirectory("D:\\My Documents\\学生成绩") \'创建目录 End If
Tables("成绩排名").SaveHTM( "D:\\My Documents\\学生成绩\\" & e.Form.Controls("ComboBox2").value & "班" & e.Form.Controls("ComboBox1").value & "期" & "成绩排名.htm" ) Tables("成绩排名").Redraw = True
Time1 = Date.Now e.Form.Controls("Label3").text="导出成功!耗时 " & (Time1-Time).TotalSeconds & " 秒"
以前是可以的,是代码有问题吗?
[此贴子已经被作者于2013-1-7 11:15:40编辑过]
|
-- 作者:易服
-- 发布时间:2013/1/7 12:07:00
--
变通一下
e.Form.Controls("Label3").text="导出中,请稍候..." Dim Time,Time1 As Date Time = Date.now Application.Doevents
If FileSys.DirectoryExists("D:\\My Documents\\学生成绩") Then \'目录存在 Else FileSys.CreateDirectory("D:\\My Documents\\学生成绩") \'创建目录 End If
Dim doc As New PrintDoc \'定义一个新报表 Dim rt As New prt.RenderTable \'定义一个新表格 Dim ColNames As String() = New String(){"班级","姓名", "语文","数学","英语","物理","化学","生物","政治","地理","总分"} Dim drs As List(of DataRow) = DataTables("成绩排名").Select(" 班级=" & e.Form.Controls("ComboBox2").value & "") For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容 rt.Cells(0,c).Text = ColNames(c) \'列名作为标题 For r As Integer = 0 To drs.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = drs(r)(ColNames(c)) Next Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) doc.Body.Children.Add(rt) \'将表格加入到报表 doc.SaveHtm("D:\\My Documents\\学生成绩\\" & e.Form.Controls("ComboBox2").value & "班" & e.Form.Controls("ComboBox1").value & "期" & "成绩排名.htm")
Tables("成绩排名").Redraw = True Time1 = Date.Now e.Form.Controls("Label3").text="导出成功!耗时 " & (Time1-Time).TotalSeconds & " 秒"
|