请写详细点,谢谢各位大神!!!我在线等!!分数不够我还可以追加,急啊!!
Dim a, b As String
Dim txtsql As String
Private Sub Command1_Click()
b = Option2.Value
Dim rs0 As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
b = True
txtsql = "select 队名,地类, sum(面积数) as 总数 from 包厢 group by 队名,地类"
rs0.CursorLocation = adUseClient
rs0.Open txtsql, cn, adOpenKeyset, adLockPessimistic
Set DataGrid1.DataSource = rs0
rs0.Requery
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
这是我界面确定按钮的代码,当我点确定的时候,统计数据显示在datagrid里面
我的意思是想点command3的时候统计数据就导出到excel表中去,该怎么弄啊!!
请各位大神帮忙!!
能具体点吗,大神,如何操作,能麻烦你给点代码吗!!!
vb中的datagrid里面的数据如何导出到excel表里面
首先在你的工程中引用Excel对象,比如“Microsoft Excel 11 Object Library”;然后在执行导出的代码里声明对象(代码仅供参考):Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim strFilename as String ''Excel文件 Dim i as Integer,j as Intege...
vb中,怎么将datagrid中的数据另存为Excel文件?
Public Sub import_Excel(Adc As Adodc, data_grid As DataGrid)On Error GoTo err Set Application = CreateObject("Excel.Application") '建立EXCEL对象 Set WorkBook = Application.Workbooks.Add() '建立一个新的Excel文档 Dim k, Column, Row, r, c As Integer Adc.Recordset.MoveFirst Columns...
VB里怎样将data grid记录导出excel
其实方法很多的,下面代码是将datagrid的记录逐行写入EXCEL Dim Excel As Object Dim WorkBook As Object Dim WorkSheet As Object Dim RangeX As Object Dim R As Long, c As Long, cc As Long Dim bm As Variant On Error GoTo 0 Set Excel = CreateObject("excel.application") Set WorkB...
vb 执行sql语句得到的结果集怎样输出到excel单元格中?
可以,在vb窗口建个datagrid,adodc,用adodc绑定你的数据库,datagrid的DataSource选择那个adodc,这样就能把记录集中的数据显示在datagrid表格中,然后再把datagrid表格中的查询结果导入到Excel中,把datagrid导入到Excel的代码如下:Dim ex As Object Dim i As Integer Dim j As Integer Dim XlApp As Ex...
vb.net中从DataGridView里面把数据导出到excel中
excel.Cells(1, i + 1) = DataGridView1.Columns(i).HeaderText Next '设置标题 Dim j As Integer For i = 0 To DataGridView1.Rows.Count - 1 '填充数据 For j = 0 To DataGridView1.Columns.Count - 1 excel.Cells(i + 2, j + 1) = DataGridView1(j, i).Value Next Next ex...
VB6.0的DATAGRID数据导出EXCEL
Conn.Execute "insert into [excel 8.0;database=" & Filepath & "].[S_Line_GE$] select 回路编号,顶点序号,东坐标,北坐标,高程,回路电压,回路导线,里程,转角,方位角,控制区段,杆塔编号,杆塔型号 from S_Line_GE order by 回路编号,里程"'将库中的数据导出到刚刚建立的表中。看上去多...
vb.net从datagridview内容导入到Excel,并在Excel的第三行开始显示_百度...
直接在工作表的首行追加2行就可以了啊,你也可以直接选择我下面的函数 Public Function Export_Excel(ByVal dgv As DataGridView) As Boolean Try If dgv.Rows.Count <= 0 Then '如果没有记录就退出 MessageBox.Show("没有记录可以导出", "没有可以导出的项目", MessageBoxButtons.OK, Me...
VB中怎么把DataGrid1的查询出的结果连同标题一起导出
导出到电子表格Excel Private Sub Command1_Click()Dim K As Integer Set oExcel = CreateObject("Excel.Application")Set oBook = oExcel.Workbooks.Add()With oBook.Worksheets(1).Columns("A:A").ColumnWidth = 13.88 .Columns("B:B").ColumnWidth = 5.75 .Columns("C:C").ColumnWidth ...
vb.net dataGridView导出EXCEL
Public Function daochu(ByVal x As DataGridView) As Boolean '导出到Excel函数 Try If x.Rows.Count <= 0 Then '判断记录数,如果没有记录就退出 MessageBox.Show("没有记录可以导出", "没有可以导出的项目", MessageBoxButtons.OK, MessageBoxIcon.Information)Return False Else '如果有记录就...
DataGrid中的数据怎样输出到EXECL中去
Olecon:= TOleContainer.Create(self);Olecon.oleobject:= Olecon.CreateObject('excel.sheet',false);或选择导入一个excel文件来创建OLE对象:Olecon.oleobject:= Olecon.CreateObjectFromFile(xlsname,false);最好隐藏excel的几个工具条,这样就好象是嵌在你的程序中的一个表而已了:Olecon.OleObject...