以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  隐藏列  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73639)

--  作者:fanjq8686
--  发布时间:2015/8/24 8:24:00
--  隐藏列

请教老师:

如何在导出EXECL报表时不导出隐藏的列?

 

谢谢!


--  作者:fanjq8686
--  发布时间:2015/8/24 9:07:00
--  
自己顶
--  作者:大红袍
--  发布时间:2015/8/24 9:23:00
--  

 你在模板里面,设计不引用此列就行。

 

 如果真要控制模板,就必须在报表打印之前,循环每一个单元格,看是否存在隐藏列的内容,存在,就删除掉。

 

 类似 http://www.foxtable.com/help/topics/2626.htm

 


--  作者:fanjq8686
--  发布时间:2015/8/24 9:34:00
--  
If User.IsRole("奖金核算人") Or User.Name = "开发者" Then
    Dim dt As Table = Tables("奖金核算窗口_Table1")
    Dim hdr As Integer = dt.HeaderRows \'获得表头的层数
   
    Dim Book As New XLS.Book \'定义一个Excel工作簿
    Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
   
    dt.CreateSheetHeader(Sheet,0,0,False) \'生成表头
    For c As Integer = 0 To dt.Cols.Count - 1
        For r As Integer = 0 To dt.Rows.Count - 1
            sheet(r + hdr,c).value = dt(r,c)
        Next
    Next
    \'    For r As Integer = 0 To 2  \'填入列标题
    \'        For c As Integer = 0 To dt.Cols.Count -1 \'添加列标题
    \'            Sheet(r, c).Value = dt.Cols(c).Name
    \'        Next
    \'    Next
    For r As Integer = 0 To dt.Rows.Count - 1 \'填入数据
        For c As Integer = 0 To dt.Cols.Count -1
            Sheet(r +2, c).Value = dt.rows(r)(c)
        Next
    Next
    Dim y As Integer = Date.Today.Year
    Dim m As Integer = Date.Today.Month
   
    \'打开工作簿
    Book.Save(ProjectPath & "Reports\\" & y & "年" & m & "奖金汇总表.xls")
    Dim Proc As New Process
    Proc.File = ProjectPath & "Reports\\" & y & "年" & m & "奖金汇总表.xls"
    Proc.Start()
Else
    MessageBox.Show("对不起, 您无此授权!")
    Return
End If

--  作者:大红袍
--  发布时间:2015/8/24 10:16:00
--  

Dim dt As Table = Tables("奖金核算窗口_Table1")
Dim hdr As Integer = dt.HeaderRows \'获得表头的层数

Dim Book As New XLS.Book \'定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表

dt.CreateSheetHeader(Sheet,0,0,True) \'生成表头
Dim i As Integer = 0
For c As Integer = 0 To dt.Cols.Count - 1
    If dt.cols(c).visible = True
       
        For r As Integer = 0 To dt.Rows.Count - 1
            sheet(r + hdr,i).value = dt(r,c)
        Next
        i += 1
    End If
Next

Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month

\'打开工作簿
Book.Save(ProjectPath & "Reports\\" & y & "年" & m & "奖金汇总表.xls")
Dim Proc As New Process
Proc.File = ProjectPath & "Reports\\" & y & "年" & m & "奖金汇总表.xls"
Proc.Start()


--  作者:fanjq8686
--  发布时间:2015/8/24 12:04:00
--  
谢谢!