2,462
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
' 建立对象并打开 Excel
On Error Resume Next
Set MyExcel = GetObject("Excel.Application")
Set MyExcel = CreateObject("Excel.Application")
Set MyBook = MyExcel.Workbooks.Add
Set MySheet = MyBook.Worksheets("sheet1")
MySheet.Name = "走台角度统计表"
MyExcel.Visible = True
'写入excel文件
MySheet.Activate
Dim i As Integer
For i = 0 To slj - 1
MySheet.Cells(i + 4, 2) = CS1(i) & "#"
MySheet.Cells(i + 4, 2).HorizontalAlignment = xlCenter
MySheet.Cells(i + 4, 3).HorizontalAlignment = xlCenter
MySheet.Cells(i + 4, 3) = CS2(i)
If CS2(i) <> 0 Then
MySheet.Cells(i + 4, 3).Interior.ColorIndex = 20
End If
MySheet.Cells(i + 4, 4) = Format(CS3L(i), "0.00")
MySheet.Cells(i + 4, 5) = Format(CS3R(i), "0.00")
MySheet.Cells(i + 4, 6) = Format(CS4L(i), "0.00")
MySheet.Cells(i + 4, 7) = Format(CS4R(i), "0.00")
MySheet.Cells(i + 4, 8) = Format(CS5L(i), "0.00")
MySheet.Cells(i + 4, 9) = Format(CS5R(i), "0.00")
MySheet.Cells(i + 4, 10) = Format(CS6L(i), "0.00")
MySheet.Cells(i + 4, 11) = Format(CS6R(i), "0.00")
MySheet.Cells(i + 4, 12) = Format(CS7L(i), "0.00")
MySheet.Cells(i + 4, 13) = Format(CS7R(i), "0.00")
Next i
MySheet.Cells(2, 2) = "支架号"
MySheet.Cells(2, 2).Font.Bold = True
MySheet.Cells(2, 3) = "支架倾角"
MySheet.Cells(2, 3).Font.Bold = True
MySheet.Cells(2, 4) = "绳倾角"
MySheet.Cells(2, 4).Font.Bold = True
MySheet.Cells(3, 4) = "左"
MySheet.Cells(3, 5) = "右"
MySheet.Cells(2, 6) = "走台角度"
MySheet.Cells(2, 6).Font.Bold = True
MySheet.Cells(3, 6) = "前"
MySheet.Cells(3, 7) = "后"
MySheet.Cells(2, 8) = "走台梁角度"
MySheet.Cells(2, 8).Font.Bold = True
MySheet.Cells(3, 8) = "前"
MySheet.Cells(3, 9) = "后"
MySheet.Cells(2, 10) = "踏板角度"
MySheet.Cells(2, 10).Font.Bold = True
MySheet.Cells(3, 10) = "前"
MySheet.Cells(3, 11) = "后"
MySheet.Cells(2, 12) = "走台栏杆角度"
MySheet.Cells(2, 12).Font.Bold = True
MySheet.Cells(3, 12) = "前"
MySheet.Cells(3, 13) = "后"
MySheet.Range("B2:B3").Merge
MySheet.Range("C2:C3").Merge
MySheet.Range("D2:E2").Merge
MySheet.Range("F2:G2").Merge
MySheet.Range("H2:I2").Merge
MySheet.Range("J2:K2").Merge
MySheet.Range("L2:M2").Merge
MySheet.Range("B2:M2").HorizontalAlignment = xlCenter
MySheet.Range("B3:M3").HorizontalAlignment = xlCenter
MyExcel.ActiveWindow.Zoom = True
MyExcel.ActiveWindow.Zoom = 130
With MySheet.Range(Cells(2, 2), Cells(slj + 3, 13)).Borders
.LineStyle = 1
.Weight = 2
End With
'加粗外框线
MySheet.Range(Cells(2, 2), Cells(slj + 3, 13)).Borders(xlEdgeBottom).Weight = xlMedium
MySheet.Range(Cells(2, 2), Cells(slj + 3, 13)).Borders(xlEdgeLeft).Weight = xlMedium
MySheet.Range(Cells(2, 2), Cells(slj + 3, 13)).Borders(xlEdgeRight).Weight = xlMedium
MySheet.Range(Cells(2, 2), Cells(slj + 3, 13)).Borders(xlEdgeTop).Weight = xlMedium
MySheet.Cells(1, 2) = "支架走台角度统计表 " & riqi
With MySheet.Range("B1").Characters(Start:=1, Length:=9).Font
.Name = "隶书"
.Size = 16
End With
With MySheet.Range("B1").Characters(Start:=InStr(Cells(1, 2).Text, "2"), Length:=Len(Cells(1, 2).Text)).Font
.Name = "隶书"
.Size = 11
End With
MySheet.Range("B1:M1").Merge
MySheet.Range("B1:M1").HorizontalAlignment = xlCenter
End Sub
' 建立对象并打开 Excel
On Error Resume Next
Set MyExcel = GetObject(, "Excel.Application")
If (MyExcel Is Nothing) Then
Set MyExcel = CreateObject("Excel.Application")
End If
Set MyBook = MyExcel.Workbooks.Add
' . . . . . .
' 后面其它代码不变…………