以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 窗口设计中报表导出问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=94417) |
||||||||
-- 作者:东方电子威斯顿 -- 发布时间:2016/12/23 9:09:00 -- 窗口设计中报表导出问题 老师,您好,这个项目中我在窗口中增加了一个导出检验记录的按钮,但是感觉这样导出有点麻烦,这个检验记录是根据模板自动生成的,用这个按钮每次都要先把检验记录保存以后才能应用窗口,能不能直接应用这个模板呢?还有就是这个编程Dim count As Integer = 47这个数据我能不能用根据项目中的零缺陷数量自动更改呢?自己更改了好几次都不行,希望老师帮忙更改一下,谢谢! |
||||||||
-- 作者:有点蓝 -- 发布时间:2016/12/23 9:24:00 -- 上传代码或者例子说明 |
||||||||
-- 作者:东方电子威斯顿 -- 发布时间:2016/12/23 9:48:00 -- 老师,不知道怎么回事,项目上传不了,下面是窗口按钮的代码:请老师帮忙看一下能不能解决上面的问题,谢谢! Dim count As Integer = 47 Dim sfile As String = ProjectPath & "检验记录.xls" Dim dfile As String = ProjectPath & "test.xls" FileSys.CopyFile(sfile, dfile, True) Dim book As new XLS.Book(dfile) Dim sheet As XLS.Sheet = book.Sheets(0) Dim nums1 As new List(Of String) Dim nums2 As new List(Of String) Dim nums3 As new List(Of String) For Each dr As DataRow In DataTables("检验记录").Select("电容量_序号 is not null") nums1.Add(dr("电容量_测试值")) nums2.add(dr("损耗角正切_测试值")) nums3.add(dr("漏电流_测试值")) Next For i As Integer = 1 To 30 If i > count Then Exit For sheet(62+i, 2).value = nums1(Rand.Next(count)) sheet(62+i, 10).value = nums2(Rand.Next(count)) sheet(62+i, 18).value = nums3(Rand.Next(count)) Next For i As Integer = 31 To 60 If i > count Then Exit For sheet(32+i, 6).value = nums1(Rand.Next(count)) sheet(32+i, 14).value = nums2(Rand.Next(count)) sheet(32+i, 22).value = nums3(Rand.Next(count)) Next For i As Integer = 61 To 90 If i > count Then Exit For sheet(99+i, 2).value = nums1(Rand.Next(count)) sheet(99+i, 10).value = nums2(Rand.Next(count)) sheet(99+i, 18).value = nums3(Rand.Next(count)) Next For i As Integer = 91 To 120 If i > count Then Exit For sheet(62+i, 6).value = nums1(Rand.Next(count)) sheet(62+i, 14).value = nums2(Rand.Next(count)) sheet(62+i, 22).value = nums3(Rand.Next(count)) Next book.save(dfile) Dim proc As new Process proc.File = dfile proc.Start
|
||||||||
-- 作者:有点蓝 -- 发布时间:2016/12/23 10:25:00 -- 还是上传模板吧,不知道你零缺陷数量是怎么来的,也不知道模板的样式。 创建一个新项目,导入这个表的数据,把项目和模板一起上传。 上传方法:http://foxtable.com/bbs/dispbbs.asp?boardid=2&Id=78,关闭浏览器的极速模式,多试几次
|
||||||||
-- 作者:东方电子威斯顿 -- 发布时间:2016/12/23 11:02:00 -- 这是项目和模板,
|
||||||||
-- 作者:有点蓝 -- 发布时间:2016/12/23 12:06:00 -- If Tables("电解电容").Current Is Nothing Then Return Dim count As Integer = Tables("电解电容").Current("零缺陷数量") Dim Book As New XLS.Book(ProjectPath & "Attachments\\检验记录.xls") \'打开模板 Dim fl As String = ProjectPath & "Reports\\检验记录.xls" Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim nums1 As new List(Of String) Dim nums2 As new List(Of String) Dim nums3 As new List(Of String) For Each dr As DataRow In DataTables("检验记录").Select("电容量_序号 is not null") nums1.Add(dr("电容量_测试值")) nums2.add(dr("损耗角正切_测试值")) nums3.add(dr("漏电流_测试值")) Next For i As Integer = 1 To 30 If i > count Then Exit For sheet(62+i, 2).value = nums1(Rand.Next(count)) sheet(62+i, 10).value = nums2(Rand.Next(count)) sheet(62+i, 18).value = nums3(Rand.Next(count)) Next For i As Integer = 31 To 60 If i > count Then Exit For sheet(32+i, 6).value = nums1(Rand.Next(count)) sheet(32+i, 14).value = nums2(Rand.Next(count)) sheet(32+i, 22).value = nums3(Rand.Next(count)) Next For i As Integer = 61 To 90 If i > count Then Exit For sheet(99+i, 2).value = nums1(Rand.Next(count)) sheet(99+i, 10).value = nums2(Rand.Next(count)) sheet(99+i, 18).value = nums3(Rand.Next(count)) Next For i As Integer = 91 To 120 If i > count Then Exit For sheet(62+i, 6).value = nums1(Rand.Next(count)) sheet(62+i, 14).value = nums2(Rand.Next(count)) sheet(62+i, 22).value = nums3(Rand.Next(count)) Next Book.Build() \'生成报表 Book.Save(fl) \'book.save(dfile) Dim proc As new Process proc.File = fl proc.Start
|