如果我们想在VB.NET环境下进行Excel的操作的话,应当如何正确的进行呢?关于VB.NET操作Excel这一问题可能对于没有太多开发经验的新手来说有点困难。今天在这里就为大家详细介绍一下这一应用技巧,让大家有一个详尽的认识。#t#
今天写的VB.NET操作Excel代码,一些要做保留,记录 Public Class ExportXlsClass ExportXls
- 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
- rngirngi = 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
VB.NET操作Excel的相关代码编写方法就为大家介绍到这里。
网站标题:教你迅速掌握VB.NET操作Excel
当前网址:http://www.shufengxianlan.com/qtweb/news20/456420.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联