Foxtable(狐表)用户栏目专家坐堂 → 如何给导出的表设置公式


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

主题:如何给导出的表设置公式

帅哥,在线噢!
lihe60
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6833 积分:43228 威望:0 精华:0 注册:2009/3/2 14:07:00
如何给导出的表设置公式  发帖心情 Post By:2019/3/19 14:53:00 [显示全部帖子]

Dim hdr As Integer = tjt.HeaderRows '获得表头的层数
Dim cnt As Integer
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)

Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.Red
Style.BorderColorBottom = Color.Red
Style.BorderColorLeft = Color.Red
Style.BorderColorRight = Color.Red

tjt.CreateSheetHeader(Sheet) '生成表头
For c As Integer = 0 To tjt.Cols.Count - 1
    '    sheet(0 ,c).Style = Style
    If tjt.Cols(c).Visible Then
        For r As Integer = 0 To tjt.Rows.Count - 1
            If tjt(r,c)<>Nothing
                sheet(r + hdr,cnt).value = tjt(r,c)
            End If
            '            sheet(r + hdr,cnt).Style = Style
        Next
        cnt = cnt + 1
    End If
Next

Dim St2 As XLS.Style = Book.NewStyle
St2.Format = "yyyy-MM-dd"
Dim i As Integer=-1
For Each c As Col In tjt.Cols
    If c.Visible
        i=i+1
        If c.Isdate
            Sheet.Cols(i).Style = st2
        End If
    End If
Next

Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()

如何给导出的表test第1列公式设置为第3列+第5列+第7列
[此贴子已经被作者于2019/3/19 14:53:00编辑过]

 回到顶部
帅哥,在线噢!
lihe60
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6833 积分:43228 威望:0 精华:0 注册:2009/3/2 14:07:00
  发帖心情 Post By:2019/3/19 15:11:00 [显示全部帖子]

Sheet(1,0).Formula = "=1+3"

意思是,B也可能是D,事先不确定是哪列的。
A1=B1+C1
A2=B2+C2


 回到顶部