[英]How to add Header and Footer in excel with vb.net?
我正在學習 vb.net 並嘗試做一個小程序來填充 excel 中的一些單元格。 這不是那么困難,我可以找到太多信息,但現在我試圖將圖像插入到 excel 的 Header 中,我不知道如何。 我閱讀了 Microsoft 網頁中有關“Microsoft.Office.Interop.Excel”的所有文檔,但沒有成功。
如何添加 Header?
非常感謝您的幫助。
我在 de 文檔中看到了這個屬性,但我沒有成功:
您可以使用以下代碼執行此操作:
Imports Microsoft.Office.Interop
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button2.Click
'open excel document
Dim App1 As Excel.Application = New Excel.Application
'Start Excel and get Application object.
App1 = CreateObject("Excel.Application")
App1.Visible = True
'connection for package
Dim Wb As Excel.Workbook = App1.Workbooks.Open("someExcelFile.xlsx")
Dim Ws As Excel.Worksheet = Wb.Worksheets(1)
'Here you add Header and Footer in excel file someExcelFile.xlsx
Ws.PageSetup.CenterHeader = "&12&""Arial"" This is the &B&""Courier New""&16 HEADER &12&B&""Arial"" of Worksheet !!!"
Ws.PageSetup.CenterFooter = "&12&""Arial"" This is the &B&""Courier New""&16 FOOTER &12&B&""Arial"" of Worksheet !!!"
Wb.Save()
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.