|
VB中使用EXCEL输出(4) If Not (rst_gcl.BOF And rst_gcl.EOF) Then rst_gcl.MoveFirst End If rst_qm.Open "qianming", con, adOpenKeyset, adLockOptimistic, adCmdTable '打开签名表 rst_qm.MoveFirst '****************************工作表初使化*********************************** Dim xlsheet As excel.Worksheet Set xlsheet = xlbook.Sheets.Add '添加一张工作表 xlsheet.Name = "工程量汇总" xls.ActiveSheet.PageSetup.Orientation = xlLandscape '纸张设置为横向 xlsheet.Columns("a:j").Font.Size = 10 xlsheet.Columns("a:j").VerticalAlignment = xlVAlignCenter '垂直居中 xlsheet.Columns(1).HorizontalAlignment = xlHAlignCenter '1列水平居中对齐 xlsheet.Columns(1).ColumnWidth = 8 xlsheet.Columns(2).HorizontalAlignment = xlHAlignLeft xlsheet.Columns(2).ColumnWidth = 26 xlsheet.Columns("c:j").HorizontalAlignment = xlHAlignRight xlsheet.Columns("c:j").ColumnWidth = 10 xlsheet.Columns("c:j").NumberFormatLocal = "0.00_ " '3到10列保留两位小数 '***************************写入标头************************************* xlsheet.Rows(1).RowHeight = 40 xlsheet.Range(xlsheet.Cells(1, 1), xlsheet.Cells(1, 10)).MergeCells = True xlsheet.Cells(1, 1).Value = "工程量汇总" xlsheet.Cells(1, 1).Font.Size = 14 xlsheet.Cells(1, 1).Font.Bold = True xlsheet.Rows(2).RowHeight = 18 xlsheet.Rows(2).HorizontalAlignment = xlHAlignCenter xlsheet.Cells(2, 1).Value = "序号" xlsheet.Cells(2, 2).Value = "工程项目及名称" xlsheet.Cells(2, 3).Value = "土方开挖(m3)"
|