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


  共有2279人关注过本帖平板打印复制链接

主题:导出列问题

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


加好友 发短信
等级:小狐 帖子:394 积分:5997 威望:0 精华:0 注册:2015/2/17 10:18:00
导出列问题  发帖心情 Post By:2015/7/17 11:25:00 [只看该作者]

通过选取部分列,导出部分列多层表头电子表,研究半天http://www.foxtable.com/help/topics/1971.htm结果导出的还是全部列(依葫芦画瓢画成西瓜了)。前面的选择与后面的导出好像没关联起来。谢谢老师将下代码改正:



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


Dim tbl As Table = Tables("职工一览表")
Dim hdr As Integer = tbl.HeaderRows 
Dim cnt As Integer
Dim Book As New XLS.Book 
Dim Sheet As XLS.Sheet = Book.Sheets(0)
tbl.CreateSheetHeader(Sheet)  
For c As Integer = 0 To tbl.Cols.Count - 1
    If tbl.Cols(c).Visible Then
        For r As Integer = 0 To tbl.Rows.Count - 1
            sheet(r + hdr,cnt).value = tbl(r,c)
        Next
        cnt = cnt + 1
    End If
Next
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()

 回到顶部