惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 七月的火热

浅谈Excel 的VB编程 一组有用的操作Excel的函数 excel與vb.net的數據雙項操作,求高手幫忙! VB.net,存EXCEL中的时间问题! VB.net调用Excel怎样设定列的列宽? 如何用VB.NET控制Excel單元格裡的內容 使用VB.NET编写控制excel的程序 ASP.NET中数据库数据导入Excel并打印 如何用VB.NET控制Excel單元格裡的內容? VB.net: 使用ODBC, ASP.net, VB.Net访问Excel文件 经改良后的vb.net导出excel代码 wsdl和soap的关系 Microsoft Solutions Framework Version 3 White Papers C#设计模式(12)-Decorator Pattern C#设计模式(11)-Composite Pattern C#设计模式(10)-Adapter Pattern C#设计模式(9)-Prototype Pattern C#设计模式(8)-Builder Pattern C#设计模式(7)-Singleton Pattern
vb.net 操作excel - 七月的火热 - 博客园
七月的火热 · 2006-11-09 · via 博客园 - 七月的火热

今天写的代码,一些要做保留,记录 Public Class ExportXlsClass ExportXls

    Public Sub Printer()Sub Printer(ByVal pid As Int16, ByVal dbhlp As DBHelper, ByVal objds As ploy)
        Dim sqlstr As String

        sqlstr = "select * from Ploy where ployID=" & pid
        dbhlp.FillDataTable(sqlstr, objds, "Ploy")
        sqlstr = "select * from PForeign where ployID=" & pid
        dbhlp.FillDataTable(sqlstr, objds, "PForeign")

        Dim exl As New Excel.Application
        exl.Visible = True
        exl.DisplayAlerts = True
        exl.WindowState = Excel.XlWindowState.xlMaximized
        'Dim wb As Excel.Workbook = exl.Workbooks.Open(Application.StartupPath & "\print.xls")
        'Dim ws As Excel.Worksheet = wb.Worksheets("prt")
        Dim wb As Excel.Workbook = exl.Workbooks.Add()
        Dim ws As Excel.Worksheet = wb.Worksheets.Item(1)
        Dim Rng As Excel.Range

        Rng = ws.Columns(1)
        Rng.ColumnWidth = 16
        Rng = ws.Columns(2)
        Rng.ColumnWidth = 46
        Rng = ws.Columns(3)
        Rng.ColumnWidth = 16


        Dim dr As ploy.PloyRow
        dr = objds.Ploy.Rows(0)
        Try
            Rng = ws.Range("A1:A1", "C1:C1")
            Rng.Cells.Merge()'合并单元格
            Rng.Font.Name = "黑体"
            Rng.Font.Size = "22"
            Rng.HorizontalAlignment = -4108
            Rng.VerticalAlignment = -4108
            Rng.Value = dr.PSubject

        Catch ex As Exception

        End Try

        Try
            Rng = ws.Range("A2:A2", "C2:C2")
            Rng.Cells.Merge()
            Rng.Font.Name = "黑体"
            Rng.Font.Size = "14"
            Rng.HorizontalAlignment = -4108
            Rng.VerticalAlignment = -4108
            Rng.Value = "时间:" & dr.PTime

        Catch ex As Exception

        End Try

        Try
            Rng = ws.Range("A3:A3", "C3:C3")
            Rng.Cells.Merge()
            Rng.Font.Name = "黑体"
            Rng.Font.Size = "14"
            Rng.HorizontalAlignment = -4108
            Rng.VerticalAlignment = -4108
            Rng.Value = "地点:" & dr.Place

        Catch ex As Exception

        End Try

        Dim drF As ploy.PForeignRow
        Dim i, rngi As Integer
        Dim rngs, cellB, cellE As String

        rngi = 5 + objds.PForeign.Rows.Count
        cellB = "A5:A5"
        cellE = "C" & rngi.ToString & ":C" & rngi.ToString

        Rng = ws.Range(cellB, cellE)
        Rng.Font.Name = "仿宋_GB2312"
        Rng.Font.Size = "16"
        Rng.Borders.LineStyle = 1
        Rng.HorizontalAlignment = -4108
        Rng.VerticalAlignment = -4108

        Rng = ws.Range("A5")
        Rng.Value = "领馆"

        Rng = ws.Range("B5")
        Rng.Value = "出席人员"

        Rng = ws.Range("C5")
        Rng.Value = "职衔"

        rngi = 6
        For i = 0 To objds.PForeign.Rows.Count - 1
            drF = objds.PForeign.Rows(i)

            Rng = ws.Range("A" & rngi.ToString)
            Rng.Value = drF.PConsulate

            Rng = ws.Range("B" & rngi.ToString)
            Rng.Value = drF.PName

            Rng = ws.Range("C" & rngi.ToString)
            Rng.Value = drF.PRank

            rngi = rngi + 1
        Next

        'wb.Save()

        'If Not exl Is Nothing Then
        '    exl.Workbooks.Close()
        '    exl.Quit()
        '    System.Runtime.InteropServices.Marshal.ReleaseComObject(exl)

        'End If
        'If Not ws Is Nothing Then
        '    System.Runtime.InteropServices.Marshal.ReleaseComObject(ws)
        'End If
        'ws = Nothing
        'exl = Nothing
        'GC.Collect()


    End Sub

End Class