Foxtable(狐表)用户栏目专家坐堂 → 如何将excel模板里的颜色通过代码来修改


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

主题:如何将excel模板里的颜色通过代码来修改

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/8/10 9:57:00 [显示全部帖子]

参考

 

Dim Book As New XLS.Book("d:\test.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For i As Integer = 0 To Sheet.Rows.count-1
    Dim style2 As XLS.style = Sheet(i,0).Style  
    try
        'Dim Style1 As XLS.Style = book.NewStyle
        'Dim propertys = style2.Gettype.GetProperties
        'For Each p As object In propertys
        'Dim val = p.getValue(style2, Nothing)
        'p.SetValue(style1, val, Nothing)
        'Next
        style2.Forecolor = Color.red
    catch ex As exception
        style2 = book.NewStyle
        style2.ForeColor = Color.red
        Sheet(i,0).Style = style2
    End try
Next

book.Save("d:\abc.xls")
Dim proc As new Process
proc.File = "d:\abc.xls"
proc.Start


 回到顶部