在VB中把EXCEL文件导入MSFLEXGRID 之二
来源:百度文库 编辑:神马文学网 时间:2024/04/28 14:57:53
首先需要引用Excel库:
从"工程"菜单中选择"引用"栏;选择Microsoft Excel 11.0 Object Library(EXCEL2003),然后选择"确定"。表示在工程中要引用EXCEL类型库。
Private Sub Command1_Click()
Dim ExcelApp As Excel.Application
Set ExcelApp = CreateObject("excel.application")
ExcelApp.Workbooks.Open (App.Path & " est2.xls")
With MSFlexGrid1
.Rows = ExcelApp.Sheets(1).UsedRange.Rows.Count
.Cols = 4
For r = 0 To .Rows - 1
For c = 1 To .Cols
If c = 1 Then
.TextMatrix(r, c - 1) = Year(Date) & "-" & ExcelApp.Sheets(1).Cells(r + 1, c + 1) & "-" & ExcelApp.Sheets(1).Cells(r + 1, c)
Else
.TextMatrix(r, c - 1) = ExcelApp.Sheets(1).Cells(r + 1, c + 1)
End If
Next
Next
End With
ExcelApp.Quit
End Sub
Private Sub Command2_Click()
Open App.Path & "导出.txt" For Output As #1
With MSFlexGrid1
For r = 0 To .Rows - 1
For c = 0 To .Cols - 1
Print #1, .TextMatrix(r, c);
If c < .Cols - 1 Then Print #1, ",";
Next
Print #1,
Next
End With
Close #1
MsgBox "导出完毕"
End Sub
从"工程"菜单中选择"引用"栏;选择Microsoft Excel 11.0 Object Library(EXCEL2003),然后选择"确定"。表示在工程中要引用EXCEL类型库。
Private Sub Command1_Click()
Dim ExcelApp As Excel.Application
Set ExcelApp = CreateObject("excel.application")
ExcelApp.Workbooks.Open (App.Path & " est2.xls")
With MSFlexGrid1
.Rows = ExcelApp.Sheets(1).UsedRange.Rows.Count
.Cols = 4
For r = 0 To .Rows - 1
For c = 1 To .Cols
If c = 1 Then
.TextMatrix(r, c - 1) = Year(Date) & "-" & ExcelApp.Sheets(1).Cells(r + 1, c + 1) & "-" & ExcelApp.Sheets(1).Cells(r + 1, c)
Else
.TextMatrix(r, c - 1) = ExcelApp.Sheets(1).Cells(r + 1, c + 1)
End If
Next
Next
End With
ExcelApp.Quit
End Sub
Private Sub Command2_Click()
Open App.Path & "导出.txt" For Output As #1
With MSFlexGrid1
For r = 0 To .Rows - 1
For c = 0 To .Cols - 1
Print #1, .TextMatrix(r, c);
If c < .Cols - 1 Then Print #1, ",";
Next
Print #1,
Next
End With
Close #1
MsgBox "导出完毕"
End Sub
在VB中把EXCEL文件导入MSFLEXGRID 之二
excel导入VB
vb中msflexgrid使用举例
vb中msflexgrid的使用举例
vb中msflexgrid的使用举例
ADO把Recordset导入EXCEL后打印~ VB / 数据库(包含打印,安装,报表)...
在VB应用程序中使用INI文件
VB 实现 数据快速导入EXCEL
VB 实现 数据快速导入EXCEL
在Excel 2007中导入或导出文本文件-星光网络学院
如何在AutoCAD软件中导入Excel表格
3步在会声会影的字幕中导入TXT文件
VB中MsFlexGrid控件的使用细则(收集)
用DLL实现把数据库的记录导出到EXCEL中(VB) - 应用程序 - VB教程
怎样把ADO产生的recordset保存为excel文件 VB / 基础类 - CSDN社...
将excel数据导入oracle中- -
将excel数据导入oracle中- -
将网页表格导入到Excel中
MSFlexGrid与Excel
FIash MX中如何导入FreeHand文件?
在Excel中创建一个常用文件菜单
在word中插入随excel文件更新的表格
在会声会影中导入TGA序列文件
VB中使MsFlexGrid和MSHFlexGrid控件支持鼠标滚动操作2