Foxtable(狐表)用户栏目专家坐堂 → 导出的表格没有网格线


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

主题:导出的表格没有网格线

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


加好友 发短信
等级:狐神 帖子:6887 积分:43621 威望:0 精华:0 注册:2009/3/2 14:07:00
导出的表格没有网格线  发帖心情 Post By:2017/9/29 7:03:00 [只看该作者]

    Dim dt As Table = e.Form.controls("table1").Table
    Dim Book As New XLS.Book '定义一个Excel工作簿
    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
    
    For c As Integer = 0 To dt.Cols.Count -1 '添加列标题
        Sheet(0, c).Value = dt.Cols(c).Name
    Next
    For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
        For c As Integer = 0 To dt.Cols.Count -1
            Sheet(r +1, c).Value = dt.rows(r)(c)
        Next
    Next
    
    Dim St2 As XLS.Style = Book.NewStyle
    St2.Format = "yyyy-MM-dd"
    Sheet.Cols(dt.Cols("出生日期").Index).Style = st2
    
    '打开工作簿
    Book.Save("c:\reports\test.xls")
    Dim Proc As New Process
    Proc.File = "c:\reports\test.xls"
    Proc.Start()


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/9/29 9:23:00 [只看该作者]

Dim dt As Table = Tables("表c") 'e.Form.controls("table1").Table
Dim Book As New XLS.Book '定义一个Excel工作簿
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

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


For c As Integer = 0 To dt.Cols.Count -1 '添加列标题
    Sheet(0, c).Value = dt.Cols(c).Name
    Sheet(0, c).style = style
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
    For c As Integer = 0 To dt.Cols.Count -1
        Sheet(r +1, c).Value = dt.rows(r)(c)
        Sheet(r +1, c).style = style
        If dt.cols(c).name = "出生日期" Then
            Sheet(r+1,c).Style = st2
        End If
    Next
Next


'打开工作簿
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()


 回到顶部