Foxtable(狐表)用户栏目专家坐堂 → 导出列问题


  共有2330人关注过本帖树形打印复制链接

主题:导出列问题

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/7/17 11:31:00 [显示全部帖子]

 Dim ckl As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1")
Dim nms As New List(of String)
For i As Integer = 0 To ckl.Items.count - 1 '获取已经勾选的列
    If ckl.GetItemChecked(i) Then
        nms.Add(ckl.Items(i))
    End If
Next
If nms.Count = 0 Then
    MessageBox.Show("至少要选择一列","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If
'生成Excel表
Dim dt As Table = Tables("订单")
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
dt.CreateSheetHeader(Sheet)  '生成表头
Dim rcount As Integer = dt.HeaderRows
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
    For i As Integer = 0 To nms.count -1
        Sheet(r + rcount, i).Value = dt.rows(r)(nms(i))
    Next
Next
'保存并打开excel文件
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/7/17 11:51:00 [显示全部帖子]

Dim ckl As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1")
Dim dt As Table = Tables("表A")
Dim cvw As String = dt.getColVisibleWidth
Dim nms As New List(of String)
For i As Integer = 0 To ckl.Items.count - 1 '获取已经勾选的列
    If ckl.GetItemChecked(i) Then
        nms.Add(ckl.Items(i))
    Else
        dt.Cols(ckl.Items(i)).Visible = False
    End If
Next
If nms.Count = 0 Then
    MessageBox.Show("至少要选择一列","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If
'生成Excel表

Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
dt.CreateSheetHeader(Sheet)  '生成表头
Dim rcount As Integer = dt.HeaderRows
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
    For i As Integer = 0 To nms.count -1
        Sheet(r + rcount, i).Value = dt.rows(r)(nms(i))
    Next
Next

dt.SetColVisibleWidth(cvw)

'保存并打开excel文件
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/7/17 14:36:00 [显示全部帖子]

 测 试 没 问 题

 回到顶部