以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 分页加载后,导出只是第一页数据 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=179901) |
-- 作者:huhu -- 发布时间:2022/9/16 16:36:00 -- 分页加载后,导出只是第一页数据 DataTables("临时版本跟踪表").LoadFilter = "" DataTables("临时版本跟踪表").Load Dim kh As WinForm.ComboBox = e.Form.Controls("客户") Dim bdjx As WinForm.ComboBox = e.Form.Controls("博达机型") Dim xqbh As WinForm.TextBox = e.Form.Controls("需求编号") Dim xqms As WinForm.TextBox = e.Form.Controls("需求描述") Dim qssj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker3") Dim jzsj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker4") \'If xqbh.text = "请输入需求编号" Then \' DataTables("临时版本跟踪表").LoadFilter = "客户 like \'%" & kh.text & "%\' and 博达机型 like \'%" & bdjx.text & "%\'" \' DataTables("临时版本跟踪表").Load \'Else \' DataTables("临时版本跟踪表").LoadFilter = "客户 like \'%" & kh.text & "%\' and 博达机型 like \'%" & bdjx.text & "%\' and [需求编号] like \'%" & xqbh.text & "%\'" \' DataTables("临时版本跟踪表").Load \'End If If qssj.text = "" AndAlso jzsj.text = "" Then If xqms.text = "请输入字符串模糊匹配" Then DataTables("临时版本跟踪表").LoadFilter = "客户 like \'%" & kh.text & "%\' and 博达机型 like \'%" & bdjx.text & "%\'" DataTables("临时版本跟踪表").Load Else DataTables("临时版本跟踪表").LoadFilter = "客户 like \'%" & kh.text & "%\' and 博达机型 like \'%" & bdjx.text & "%\' and [需求描述] like \'%" & xqms.text & "%\'" DataTables("临时版本跟踪表").Load End If Else If xqms.text = "请输入字符串模糊匹配" Then DataTables("临时版本跟踪表").LoadFilter = "客户 like \'%" & kh.text & "%\' and 博达机型 like \'%" & bdjx.text & "%\' and 需求提交时间 > \'" & qssj.Value & "\' and 需求提交时间 < \'" & jzsj.Value.adddays(1) & "\'" DataTables("临时版本跟踪表").Load Else DataTables("临时版本跟踪表").LoadFilter = "客户 Like \'%" & kh.text & "%\' and 博达机型 like \'%" & bdjx.text & "%\' and [需求描述] like \'%" & xqms.text & "%\' and 需求提交时间 > \'" & qssj.Value & "\' and 需求提交时间 < \'" & jzsj.Value.adddays(1) & "\'" DataTables("临时版本跟踪表").Load End If End If Dim dt As Table = Tables("临时版本跟踪表") Dim filepath As String = "C:\\临时版本跟踪表\\" & "查询导出" & ".xls" Dim nms() As String = {"临时版本编号", "需求编号", "博达机型", "客户", "需求提交时间", "预计提供时间", "开发环境", "代码message", "软件环境", "show_version", "技术支持邮箱", "研发邮箱", "客户期望交期", "log", "发布目录", "测试目录", "状态", "状态直白", "需求描述"} \'要导出的列名 Dim caps() As String = {"临时版本编号", "需求编号", "博达机型", "客户", "需求提交时间", "预计提供时间", "开发环境", "代码message", "软件环境", "show_version", "技术支持邮箱", "研发邮箱", "客户期望交期", "log", "发布目录", "测试目录", "状态", "状态直白", "需求描述"} \'对应的列标题 Dim szs() As Integer = {100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 80, 200, 300} \'对应的列宽 Dim Book As New XLS.Book \'定义一个Excel工作簿 Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表 Dim st As XLS.Style = Book.NewStyle \'日期列的显示格式 st.Format = "yyyy-MM-dd hh:mm:ss" For c As Integer = 0 To nms.length - 1 Sheet(0, c).Value = caps(c) \'指定列标题 Sheet.Cols(c).Width = szs(c) \'指定列宽 If dt.Cols(nms(c)).IsDate Then \'如果是日期列 Sheet.Cols(c).Style = st \'设置显示格式 End If Next For r As Integer = 0 To dt.Rows.Count - 1 \'填入数据 For c As Integer = 0 To nms.length - 1 If Not dt.rows(r).Isnull(nms(c)) Then Sheet(r + 1, c).Value = dt.rows(r)(nms(c)) Next Next Book.Save(filepath)-----’实际数据分好几页呢,可是导出后只有第一页数据。 MessageBox.show("保存路径:" & FilePath, "导出成功", MessageBoxButtons.OK, MessageBoxIcon.Information) DataTables("临时版本跟踪表").Load With DataTables("临时版本跟踪表") .LoadOver = "需求编号" .LoadReverse = True .LoadTop = 27 .LoadPage = 0 .Load() If .TotalPages = 0 Then .LoadPage = 0 e.Form.Controls("TextBox1").Value = .LoadPage & "/" & .TotalPages Else e.Form.Controls("TextBox1").Value = .LoadPage + 1 & "/" & .TotalPages End If End With |
-- 作者:有点蓝 -- 发布时间:2022/9/16 16:51:00 -- 加载多少数据就只能导出多少数据。要导出全部的,就必须全部加载 |
-- 作者:huhu -- 发布时间:2022/9/16 17:03:00 -- 意思是不能用分页?分页就只能导出第一页了? |
-- 作者:有点蓝 -- 发布时间:2022/9/16 17:07:00 -- 是的。可以继续加载第二页,然后把第二页数据继续追加到execl文件之前的数据后面 |
-- 作者:huhu -- 发布时间:2022/9/16 17:45:00 -- 还是想保留分页,不然全部显示出来,看着很傻的。那么怎么追加呢? |
-- 作者:有点蓝 -- 发布时间:2022/9/17 8:49:00 -- 可以导出前,加载全部数据,导出后,重新分页加载 |
-- 作者:有点蓝 -- 发布时间:2022/9/17 8:52:00 -- 追加 Dim Book As New XLS.Book \'定义一个Excel工作簿 Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表 dim 已有行数 as integer = Sheet.rows.count For r As Integer = 0 To dt.Rows.Count - 1 \'填入数据 For c As Integer = 0 To nms.length - 1 If Not dt.rows(r).Isnull(nms(c)) Then Sheet(r + 已有行数, c).Value = dt.rows(r)(nms(c)) Next Next |