10 个解决方案
#1
超过65335会死的!!!
#2
最多就几千条,不会超过1万的,放心!
MSHFlexGrid1如何将sql数据库中的数据全部显示出来?如何将显示出来的数据进行导出,导出到excel?
MSHFlexGrid1如何将sql数据库中的数据全部显示出来?如何将显示出来的数据进行导出,导出到excel?
#3
'这个是增加至ListView中的.
Private Sub Command1_Click()
Dim Item As ListItem
ListView1.View = lvwReport
For i = 1 To MSHFlexGrid1.Cols - 1
ListView1.ColumnHeaders.Add , , "第" & i & "列"
Next
For i = 1 To MSHFlexGrid1.Rows - 1
Set Item = ListView1.ListItems.Add(, , MSHFlexGrid1.TextMatrix(i, 1))
For j = 2 To MSHFlexGrid1.Cols - 1
Item.SubItems(j - 1) = MSHFlexGrid1.TextMatrix(i, j)
Next
Next
End Sub
'这个是增加至List1中的,因List1中只能有一列,所以就只增加MSHFlexGrid1的第一列
Private Sub Command2_Click()
For i = 1 To MSHFlexGrid1.Rows - 1
list1.AddItem MSHFlexGrid1.TextMatrix(i, 1)
Next
End Sub
Private Sub Command1_Click()
Dim Item As ListItem
ListView1.View = lvwReport
For i = 1 To MSHFlexGrid1.Cols - 1
ListView1.ColumnHeaders.Add , , "第" & i & "列"
Next
For i = 1 To MSHFlexGrid1.Rows - 1
Set Item = ListView1.ListItems.Add(, , MSHFlexGrid1.TextMatrix(i, 1))
For j = 2 To MSHFlexGrid1.Cols - 1
Item.SubItems(j - 1) = MSHFlexGrid1.TextMatrix(i, j)
Next
Next
End Sub
'这个是增加至List1中的,因List1中只能有一列,所以就只增加MSHFlexGrid1的第一列
Private Sub Command2_Click()
For i = 1 To MSHFlexGrid1.Rows - 1
list1.AddItem MSHFlexGrid1.TextMatrix(i, 1)
Next
End Sub
#4
你搞错了,我是要把sql数据库中的所有数据都在MSHFlexGrid1中全部显示出来?然后将显示出来的数据进行导出,导出到excel?看明白了吧?
#5
连接数据库之后,打开数据表,一条记录一条记录读,然后按照字段逐个填到GRID里面去.
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,看明白了吧?
这些东西论坛上都有现成的代码的.楼主自己稍微花点力气搜索一下就有了
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,看明白了吧?
这些东西论坛上都有现成的代码的.楼主自己稍微花点力气搜索一下就有了
#6
连接数据库之后,打开数据表,一条记录一条记录读,然后按照字段逐个填到GRID里面去.
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,请问代码怎么写,好人做到底,谁能告诉我啊?
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,请问代码怎么写,好人做到底,谁能告诉我啊?
#7
显示应该很简单三,用一个adodc控件连接数据表,MSHFlexGrid1的datasource设成adodc就ok了。导出麻烦点,先创建一个excel对象,然后打开,用循环语句把数据依次写入到excel工作表中,然后保存excel文件。
#8
楼主莫非是连一点点代码都没有写??
或者是什么都不会呢?
如果你有现成的代码,调试不通,或许帮你看看会比较简单些.
或者是什么都不会呢?
如果你有现成的代码,调试不通,或许帮你看看会比较简单些.
#9
以下是我的代码,但只能导出MSHFlexGrid1中显示的数据,但MSHFlexGrid1中显示出来的不是所有数据
Private Sub Command11_Click()
On Error Resume Next
If MSHFlexGrid1.TextMatrix(1, 2) = "" Then
MsgBox "没有数据导出", vbInformation, "提示"
Exit Sub
End If
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
Set excelApp = CreateObject("Excel.Application")
Dim exbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Set exbook = excelApp.Workbooks.Add
excelApp.SheetsInNewWorkbook = 1
excelApp.Visible = False '是否显示导出过程(true是)
excelApp.UserControl = True
Me.MousePointer = vbHourglass '控制鼠标为读取数据
With excelApp.ActiveSheet
.Range("h1:h1") = "报表日期:" & Format$(Date, "yyyy-mm-dd")
End With
With excelApp.ActiveSheet
.Range("a1:a1") = "代码"
.Range("b1:b1") = "拼音码"
.Range("c1:c1") = "人员名称"
.Range("d1:d1") = "工作类型"
.Range("e1:e1") = "部门代码"
.Range("f1:f1") = "部门名称"
End With
With excelApp.ActiveSheet
.Cells(2).ColumnWidth = 8 '第一列
.Cells(3).ColumnWidth = 8 '第二列
.Cells(4).ColumnWidth = 8 '第三列
.Cells(5).ColumnWidth = 8 '第四列
.Cells(6).ColumnWidth = 8 '第五列
.Cells(7).ColumnWidth = 16 '第六列
End With
With excelApp.ActiveSheet
For i = 1 To MSHFlexGrid1.Rows
For j = 1 To MSHFlexGrid1.Cols
.Cells(i + 1, j).Value = "" & Format$(MSHFlexGrid1.TextMatrix(i, j))
Next j
Next i
End With
With excelApp
abc = Format$(Date, "yyyymmdd") & "人员信息表"
aa = .Dialogs(xlDialogSaveAs).Show(abc) '
.Workbooks(1).Saved = True '不提示保存对话框
End With
Me.MousePointer = 0 '释放鼠标为读取数据
exbook.Close (True) '关闭EXBOOK
excelApp.Quit '退出
Set exsheet = Nothing '释放EXCEL
Set exbook = Nothing '释放EXCEL
Set excelApp = Nothing '释放EXCEL
MsgBox "导出成功!", vbOKOnly + vbInformation, "消息提示"
End Sub
Private Sub Command11_Click()
On Error Resume Next
If MSHFlexGrid1.TextMatrix(1, 2) = "" Then
MsgBox "没有数据导出", vbInformation, "提示"
Exit Sub
End If
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
Set excelApp = CreateObject("Excel.Application")
Dim exbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Set exbook = excelApp.Workbooks.Add
excelApp.SheetsInNewWorkbook = 1
excelApp.Visible = False '是否显示导出过程(true是)
excelApp.UserControl = True
Me.MousePointer = vbHourglass '控制鼠标为读取数据
With excelApp.ActiveSheet
.Range("h1:h1") = "报表日期:" & Format$(Date, "yyyy-mm-dd")
End With
With excelApp.ActiveSheet
.Range("a1:a1") = "代码"
.Range("b1:b1") = "拼音码"
.Range("c1:c1") = "人员名称"
.Range("d1:d1") = "工作类型"
.Range("e1:e1") = "部门代码"
.Range("f1:f1") = "部门名称"
End With
With excelApp.ActiveSheet
.Cells(2).ColumnWidth = 8 '第一列
.Cells(3).ColumnWidth = 8 '第二列
.Cells(4).ColumnWidth = 8 '第三列
.Cells(5).ColumnWidth = 8 '第四列
.Cells(6).ColumnWidth = 8 '第五列
.Cells(7).ColumnWidth = 16 '第六列
End With
With excelApp.ActiveSheet
For i = 1 To MSHFlexGrid1.Rows
For j = 1 To MSHFlexGrid1.Cols
.Cells(i + 1, j).Value = "" & Format$(MSHFlexGrid1.TextMatrix(i, j))
Next j
Next i
End With
With excelApp
abc = Format$(Date, "yyyymmdd") & "人员信息表"
aa = .Dialogs(xlDialogSaveAs).Show(abc) '
.Workbooks(1).Saved = True '不提示保存对话框
End With
Me.MousePointer = 0 '释放鼠标为读取数据
exbook.Close (True) '关闭EXBOOK
excelApp.Quit '退出
Set exsheet = Nothing '释放EXCEL
Set exbook = Nothing '释放EXCEL
Set excelApp = Nothing '释放EXCEL
MsgBox "导出成功!", vbOKOnly + vbInformation, "消息提示"
End Sub
#10
哈哈,我自己解决了这个问题,我打了补丁就可以全显示了!
#1
超过65335会死的!!!
#2
最多就几千条,不会超过1万的,放心!
MSHFlexGrid1如何将sql数据库中的数据全部显示出来?如何将显示出来的数据进行导出,导出到excel?
MSHFlexGrid1如何将sql数据库中的数据全部显示出来?如何将显示出来的数据进行导出,导出到excel?
#3
'这个是增加至ListView中的.
Private Sub Command1_Click()
Dim Item As ListItem
ListView1.View = lvwReport
For i = 1 To MSHFlexGrid1.Cols - 1
ListView1.ColumnHeaders.Add , , "第" & i & "列"
Next
For i = 1 To MSHFlexGrid1.Rows - 1
Set Item = ListView1.ListItems.Add(, , MSHFlexGrid1.TextMatrix(i, 1))
For j = 2 To MSHFlexGrid1.Cols - 1
Item.SubItems(j - 1) = MSHFlexGrid1.TextMatrix(i, j)
Next
Next
End Sub
'这个是增加至List1中的,因List1中只能有一列,所以就只增加MSHFlexGrid1的第一列
Private Sub Command2_Click()
For i = 1 To MSHFlexGrid1.Rows - 1
list1.AddItem MSHFlexGrid1.TextMatrix(i, 1)
Next
End Sub
Private Sub Command1_Click()
Dim Item As ListItem
ListView1.View = lvwReport
For i = 1 To MSHFlexGrid1.Cols - 1
ListView1.ColumnHeaders.Add , , "第" & i & "列"
Next
For i = 1 To MSHFlexGrid1.Rows - 1
Set Item = ListView1.ListItems.Add(, , MSHFlexGrid1.TextMatrix(i, 1))
For j = 2 To MSHFlexGrid1.Cols - 1
Item.SubItems(j - 1) = MSHFlexGrid1.TextMatrix(i, j)
Next
Next
End Sub
'这个是增加至List1中的,因List1中只能有一列,所以就只增加MSHFlexGrid1的第一列
Private Sub Command2_Click()
For i = 1 To MSHFlexGrid1.Rows - 1
list1.AddItem MSHFlexGrid1.TextMatrix(i, 1)
Next
End Sub
#4
你搞错了,我是要把sql数据库中的所有数据都在MSHFlexGrid1中全部显示出来?然后将显示出来的数据进行导出,导出到excel?看明白了吧?
#5
连接数据库之后,打开数据表,一条记录一条记录读,然后按照字段逐个填到GRID里面去.
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,看明白了吧?
这些东西论坛上都有现成的代码的.楼主自己稍微花点力气搜索一下就有了
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,看明白了吧?
这些东西论坛上都有现成的代码的.楼主自己稍微花点力气搜索一下就有了
#6
连接数据库之后,打开数据表,一条记录一条记录读,然后按照字段逐个填到GRID里面去.
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,请问代码怎么写,好人做到底,谁能告诉我啊?
导出的话么,用EXCEL对象,再按照GRID一格一格写进EXCEL再保存,请问代码怎么写,好人做到底,谁能告诉我啊?
#7
显示应该很简单三,用一个adodc控件连接数据表,MSHFlexGrid1的datasource设成adodc就ok了。导出麻烦点,先创建一个excel对象,然后打开,用循环语句把数据依次写入到excel工作表中,然后保存excel文件。
#8
楼主莫非是连一点点代码都没有写??
或者是什么都不会呢?
如果你有现成的代码,调试不通,或许帮你看看会比较简单些.
或者是什么都不会呢?
如果你有现成的代码,调试不通,或许帮你看看会比较简单些.
#9
以下是我的代码,但只能导出MSHFlexGrid1中显示的数据,但MSHFlexGrid1中显示出来的不是所有数据
Private Sub Command11_Click()
On Error Resume Next
If MSHFlexGrid1.TextMatrix(1, 2) = "" Then
MsgBox "没有数据导出", vbInformation, "提示"
Exit Sub
End If
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
Set excelApp = CreateObject("Excel.Application")
Dim exbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Set exbook = excelApp.Workbooks.Add
excelApp.SheetsInNewWorkbook = 1
excelApp.Visible = False '是否显示导出过程(true是)
excelApp.UserControl = True
Me.MousePointer = vbHourglass '控制鼠标为读取数据
With excelApp.ActiveSheet
.Range("h1:h1") = "报表日期:" & Format$(Date, "yyyy-mm-dd")
End With
With excelApp.ActiveSheet
.Range("a1:a1") = "代码"
.Range("b1:b1") = "拼音码"
.Range("c1:c1") = "人员名称"
.Range("d1:d1") = "工作类型"
.Range("e1:e1") = "部门代码"
.Range("f1:f1") = "部门名称"
End With
With excelApp.ActiveSheet
.Cells(2).ColumnWidth = 8 '第一列
.Cells(3).ColumnWidth = 8 '第二列
.Cells(4).ColumnWidth = 8 '第三列
.Cells(5).ColumnWidth = 8 '第四列
.Cells(6).ColumnWidth = 8 '第五列
.Cells(7).ColumnWidth = 16 '第六列
End With
With excelApp.ActiveSheet
For i = 1 To MSHFlexGrid1.Rows
For j = 1 To MSHFlexGrid1.Cols
.Cells(i + 1, j).Value = "" & Format$(MSHFlexGrid1.TextMatrix(i, j))
Next j
Next i
End With
With excelApp
abc = Format$(Date, "yyyymmdd") & "人员信息表"
aa = .Dialogs(xlDialogSaveAs).Show(abc) '
.Workbooks(1).Saved = True '不提示保存对话框
End With
Me.MousePointer = 0 '释放鼠标为读取数据
exbook.Close (True) '关闭EXBOOK
excelApp.Quit '退出
Set exsheet = Nothing '释放EXCEL
Set exbook = Nothing '释放EXCEL
Set excelApp = Nothing '释放EXCEL
MsgBox "导出成功!", vbOKOnly + vbInformation, "消息提示"
End Sub
Private Sub Command11_Click()
On Error Resume Next
If MSHFlexGrid1.TextMatrix(1, 2) = "" Then
MsgBox "没有数据导出", vbInformation, "提示"
Exit Sub
End If
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
Set excelApp = CreateObject("Excel.Application")
Dim exbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Set exbook = excelApp.Workbooks.Add
excelApp.SheetsInNewWorkbook = 1
excelApp.Visible = False '是否显示导出过程(true是)
excelApp.UserControl = True
Me.MousePointer = vbHourglass '控制鼠标为读取数据
With excelApp.ActiveSheet
.Range("h1:h1") = "报表日期:" & Format$(Date, "yyyy-mm-dd")
End With
With excelApp.ActiveSheet
.Range("a1:a1") = "代码"
.Range("b1:b1") = "拼音码"
.Range("c1:c1") = "人员名称"
.Range("d1:d1") = "工作类型"
.Range("e1:e1") = "部门代码"
.Range("f1:f1") = "部门名称"
End With
With excelApp.ActiveSheet
.Cells(2).ColumnWidth = 8 '第一列
.Cells(3).ColumnWidth = 8 '第二列
.Cells(4).ColumnWidth = 8 '第三列
.Cells(5).ColumnWidth = 8 '第四列
.Cells(6).ColumnWidth = 8 '第五列
.Cells(7).ColumnWidth = 16 '第六列
End With
With excelApp.ActiveSheet
For i = 1 To MSHFlexGrid1.Rows
For j = 1 To MSHFlexGrid1.Cols
.Cells(i + 1, j).Value = "" & Format$(MSHFlexGrid1.TextMatrix(i, j))
Next j
Next i
End With
With excelApp
abc = Format$(Date, "yyyymmdd") & "人员信息表"
aa = .Dialogs(xlDialogSaveAs).Show(abc) '
.Workbooks(1).Saved = True '不提示保存对话框
End With
Me.MousePointer = 0 '释放鼠标为读取数据
exbook.Close (True) '关闭EXBOOK
excelApp.Quit '退出
Set exsheet = Nothing '释放EXCEL
Set exbook = Nothing '释放EXCEL
Set excelApp = Nothing '释放EXCEL
MsgBox "导出成功!", vbOKOnly + vbInformation, "消息提示"
End Sub
#10
哈哈,我自己解决了这个问题,我打了补丁就可以全显示了!