| xlSheet.Columns(Icol).ColumnWidth = Fieldlen(Icol) "Excel列宽等于字段长 xlSheet.Cells(Irow, Icol).Value = .Fields(Icol - 1) "向Excel的CellS中写入字段值 Case Else Fieldlen1 = LenB(.Fields(Icol - 1))
If Fieldlen(Icol) < Fieldlen1 Then xlSheet.Columns(Icol).ColumnWidth = Fieldlen1 "表格列宽等于较长字段长 Fieldlen(Icol) = Fieldlen1 "数组Fieldlen(Icol)中存放最大字段长度值 Else xlSheet.Columns(Icol).ColumnWidth = Fieldlen(Icol) End If
xlSheet.Cells(Irow, Icol).Value = .Fields(Icol - 1) End Select Next If Irow <> 1 Then If Not .EOF Then .MoveNext End If Next With xlSheet .Range(.Cells(1, 1), .Cells(1, Icol - 1)).Font.Name = "黑体" "设标题为黑体字 .Range(.Cells(1, 1), .Cells(1, Icol - 1)).Font.Bold = True "标题字体加粗 .Range(.Cells(1, 1), .Cells(Irow, Icol - 1)).Borders.LineStyle = xlContinuous "设表格边框样式 End With xlApp.Visible = True "显示表格 xlBook.Save "保存 Set xlApp = Nothing "交还控制给Excel End With |