Dim Book As New XLS.Book '定义一个Excel工作簿 Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表 With Sheet.PrintSetting '页眉左边为日期,中间为时间,右边为表名 .Header = "&L&D &C&T &R&""隶书,常规""&20 数据分析表" '中页眉,并将字体设置为隶书和20号字大小 '在页脚右边打印页号和总页数 .Footer = "&R第&P页,总&N页" End With For i As Integer = 0 To 100 '向工作表的单元格中设置值 Sheet(i, 0).Value = (i + 1) * 10 Sheet(i, 1).Value = (i + 1) * 100 Sheet(i, 2).Value = (i + 1) * 1000 Next Book.Save("d:\reports\test.xls") '保存工作簿 Dim Proc As New Process '打开工作簿 Proc.File = "d:\reports\test.xls" Proc.Start()
|