• 基于VB和EXCEL的报表设计及打印


    Dim zsbexcel As Excel.Application

    Private Sub Command1_Click()
    Set zsbexcel = New Excel.Application
        zsbexcel.Visible = True
        zsbexcel.SheetsInNewWorkbook = 1
    Set zsbworkbook = zsbexcel.Workbooks.Add

    With zsbexcel.ActiveSheet.Range("A2:C9").Borders      
         .LineStyle = xlBorderLineStyleContinuous
         .Weight = xlThin
         .ColorIndex = 1
    End With

    With zsbexcel.ActiveSheet.Range("A3:C9").Font    
         .Size = 14
         .Bold = True
         .Italic = True
         .ColorIndex = 3
    End With

    zsbexcel.ActiveSheet.Rows.HorizontalAlignment = xlVAlignCenter     
    zsbexcel.ActiveSheet.Rows.VerticalAlignment = xlVAlignCenter       

    With zsbexcel.ActiveSheet
         .Cells(1, 2).Value = "100"
         .Cells(2, 2).Value = "200"
         .Cells(3, 2).Value = "=SUM(B1:B2)"
         .Cells(1, 3).Value = "TextHere"
         .Range("A3:A9") = "50"
    End With

    '这一段用来打印

    'zsbexcel.ActiveSheet.PageSetup.Orientation = xlPortrait       'xlLandscape
    'zsbexcel.ActiveSheet.PageSetup.PaperSize = xlPaperA4
    'zsbexcel.ActiveSheet.PrintOut
    'zsbexcel.DisplayAlerts = False
    'zsbexcel.Quit
    'zsbexcel.DisplayAlerts = True
    Set zsbexcel = Nothing

    End Sub

  • 相关阅读:
    BigDecimal精确到几位以及四舍五入
    IDEA配置
    IDEA配置
    IntelliJ IDEA 2018.3.3配置 Tomcat 9,控制台出现中文乱码 “淇℃伅”
    JSP九大内置对象详解
    面试题
    配置编码格式
    SpringAop注解(增强)异常
    springmvc异常
    android保持Session会话
  • 原文地址:https://www.cnblogs.com/ainima/p/6331641.html
Copyright © 2020-2023  润新知