‘1.打開Excel Dim exl As New Excel.Application() exl.Visible = True
‘2.添加工作簿 exl.Workbooks.Add()
‘3.設(shè)定活動工作表 ‘exl.Worksheets("sheets").active()
‘4.打開指定的Excel文件 ‘exl.Workbooks.Open("c:\book1.xls")
‘5.顯示Excel窗口 exl.Visible = True
‘6.更改標題欄 exl.Caption = "aaaaaaaaaaa"
‘7.為單元格賦值 exl.Cells(1, 4).value = 100 exl.Range("a1:b5").Value = 50
‘8.設(shè)置指定列寬度 exl.ActiveSheet.columns(1).columnwidth = 20
‘9.設(shè)行高 exl.ActiveSheet.rows(1).rowheight = 1 / 0.035
‘10.在第18行插入分頁 exl.ActiveSheet.rows(18).pagebreak = 1
‘11.在第4列前刪除分頁符 exl.ActiveSheet.columns(4).pagebreak = 0
‘12.指定邊框線的寬度 exl.ActiveSheet.range("b3:d3").borders(2).weight = 3
‘13.邊框線條類型 Dim sheet As Excel.Worksheet sheet = exl.ActiveSheet sheet.Range("b10:f13").Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = 1
‘14.設(shè)置頁腳 sheet.PageSetup.CenterFooter = "第&p頁"
‘15.頁眉 sheet.PageSetup.CenterHeader = "aaaaaa"
‘16.頂,、底、左、右邊距 sheet.PageSetup.HeaderMargin = 2 / 0.035 sheet.PageSetup.FooterMargin = 2 / 0.035 sheet.PageSetup.LeftMargin = 2 / 0.035 sheet.PageSetup.RightMargin = 2 / 0.035 ‘頁眉距頂端,、頁腳距底邊 sheet.PageSetup.HeaderMargin = 2 / 0.0354 sheet.PageSetup.FooterMargin = 2 / 0.035
‘22.頁面水平居中 sheet.PageSetup.CenterHorizontally = True ‘23.頁面垂直居中 sheet.PageSetup.CenterVertically = True
‘24.頁面紙張 sheet.PageSetup.PaperSize = Excel.XlPaperSize.xlPaperA4
‘25.打印網(wǎng)格(邊框是實線,,中間是虛線) sheet.PageSetup.PrintGridlines = True
‘26.復(fù)制整個工作表 sheet.Range("a1:f5").Copy() sheet.Range("a10").PasteSpecial() ‘粘貼
‘29.插入列/行 sheet.Columns(1).insert() sheet.Rows(1).insert()
‘31.合并格 sheet.Range("c4:d4").Merge()
‘33.調(diào)整字體 ‘sheet.Cells("a1: f10").font.name = 5
‘38.打印預(yù)覽 exl.ActiveWorkbook.PrintPreview()
‘39.打印 exl.ActiveWorkbook.PrintOut()
‘40.保存文件 exl.ActiveWorkbook.SaveAs("e:\aa.xls")
‘41.放棄存盤 exl.ActiveWorkbook.Saved = True
‘43.退出 exl.Quit()
|