在VB 中怎么把数据导到EXCEL里面去
解决方案 »
- 新手请教:文本框lost_focus事件和相邻的button的问题
- 你们的公司的老总都在干什么?
- 小问题:如何清除form的picture属性的值
- 开发一个类似于QQ类的软件,需要多少钱?
- 怎么让SQL的查询中的日期字段,按指定的日期格式返回记录?
- 我想将 报表控件 中的每一个CELL变成下拉列表的形式,请问用哪个控件可以实现?
- 请教各位VB高手,我这里有一棘手问题,万望指点!!!!!!!!!!
- VB中直接运行一个应用程序或打开相应类型的文件(例如.exe或.html),用什么语句
- 本人遇到一个奇怪的问题,请大家帮忙想一下,急呀!!!!!!!!!!
- 用那个api可以关闭窗口?
- 我要做一个类似msdn中搜索用的combobox,如何实现?(急,再线等待)
- 过路的朋友。来看看,一个很简单的问题,我就是不行!
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1) With Rs_Dzgl_Receipt
If .RecordCount < 1 Then
MsgBox ("没有记录!")
Exit Sub
End If
xlSheet.Cells(1, 4).Value = .Fields("bt")
xlSheet.Cells(2, 1).Value = .Fields("invoice")
xlSheet.Cells(2, 9).Value = .Fields("packdate")
xlSheet.Cells(3, 1).Value = .Fields("")
'合并单元格
Dim nIcol As Integer
xlSheet.Range(xlSheet.Cells(3, 1), xlSheet.Cells(5, 9)).Select
With xlApp.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(1, 9)).Select
With xlApp.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
'网格线
With xlSheet
.Range(.Cells(1, 1), .Cells(1, 9)).Font.Name = "黑体"
'设标题为黑体字
.Range(.Cells(1, 1), .Cells(1, 9)).Font.Bold = True
'标题字体加粗
.Range(.Cells(1, 1), .Cells(1, 9)).Borders.LineStyle = xlContinuous
'设表格边框样式
End With
'显示表格
Dim ExclFileName As String
ExclFileName = App.Path & "\箱单" & Text1(1).Text & ".xls"
If Dir(ExclFileName) <> "" Then
Kill ExclFileName
End If
xlSheet.SaveAs (ExclFileName)
xlApp.Application.Visible = True
'交还控制给Excel
xlSheet.PrintPreview
' xlApp.Application.Quit
' xlApp.Quit
End With