我已用VB寫程序自動生成EXCEL報表,但是問題是,我在EXECL里面點文件下的打印時,單元格之間沒有表格線,問用什麼函數可以解決此問題,而不要用戶自己設置,急!

解决方案 »

  1.   

    先生成一个excel报表的模板,再把数据填进去
      

  2.   

    录制宏,给选定单元格添加表格线。如下:
        With Selection.Borders(xlEdgeLeft)    '左边框
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideVertical)    '内框
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
    自己看着要吧。