| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 756 人关注过本帖
标题:listview导出EXCEL?
只看楼主 加入收藏
plggli
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-3-16
收藏
 问题点数:0 回复次数:2 
listview导出EXCEL?

如何将listview内容导出EXCEL表格

搜索更多相关主题的帖子: EXCEL listview 
2006-04-28 17:11
moshen62
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2006-1-12
收藏
得分:0 

'*****************************************************打印报表*********************************************
Public Sub PrintReort()
On Error Resume Next
Dim i As Long, j As Long
Dim newFrm As FrmWait

If mvarmXPLvw.XPColumnHeaders.Count = 0 Then Exit Sub
If mvarmXPLvw.XPListItems.Count = 0 Then Exit Sub

'---------------------------------------------------------------
Set newFrm = New FrmWait
newFrm.Show
newFrm.FrmCaption = "打印 " & mvarFrmObject.Caption
Call newFrm.SetLblDescCaption("正在创建打印机的环境......")
Call newFrm.SetPsBarMode(1)
'---------------------------------------------------------------

If mExcel Is Nothing Then
'Set mExcel = CreateObject("Excel.Application")
Call CreateExcelObject 'Excel 创建对象
End If

If mExcel.Visible = True Then
mExcel.Visible = False
End If

mExcel.Caption = mvarFrmObject.Caption


Set mWorkBook = mExcel.Application.Workbooks.Add '新建工作区
Set mWorksheet = mWorkBook.Worksheets(1)
mWorksheet.Name = mvarFrmObject.Caption

'---------------------------------------------------------------
Call newFrm.SetLblDescCaption("正在导入要打印的数据,请等待......")
Call newFrm.SetPsBarMode(0)
Call newFrm.SetPsBarMax(mvarmXPLvw.XPColumnHeaders.Count + mvarmXPLvw.XPListItems.Count * mvarmXPLvw.XPColumnHeaders.Count + 5)
'---------------------------------------------------------------

For i = 1 To mvarmXPLvw.XPColumnHeaders.Count
mWorksheet.Cells(1, i) = mvarmXPLvw.XPColumnHeaders(i).Text
'---------------------------------------------------------------
Call newFrm.SetPsbarValue
'---------------------------------------------------------------
Next
For i = 1 To mvarmXPLvw.XPListItems.Count
For j = 1 To mvarmXPLvw.XPColumnHeaders.Count
mWorksheet.Cells(i + 1, j) = mvarmXPLvw.XPListItems(i).ListSubItems(j).Text
'---------------------------------------------------------------
Call newFrm.SetPsbarValue
'---------------------------------------------------------------
Next
Next

'---------------------------------------------------------------
Call newFrm.SetLblDescCaption("正在整理要打印的数据,请等待......")
Call newFrm.SetPsbarValue
'---------------------------------------------------------------

Call SettingExcelParameter(mExcel, mWorksheet, mWorkBook, mvarmXPLvw.XPColumnHeaders.Count, mvarmXPLvw.XPListItems.Count + 1)

mExcel.DisplayAlerts = False '设置不显示警告消息

mExcel.Visible = True

'---------------------------------------------------------------
Call newFrm.SetPsbarValue(1)
newFrm.Hide
'---------------------------------------------------------------

mWorksheet.PrintPreview

'---------------------------------------------------------------
newFrm.Show
Call newFrm.SetLblDescCaption("打印完毕正在关闭打印机环境,请等待......")
Call newFrm.SetPsbarValue(1)
'---------------------------------------------------------------

mExcel.Visible = False

Set mWorksheet = Nothing
Call mWorkBook.Close
Set mWorkBook = Nothing
mExcel.Workbooks.Close

'---------------------------------------------------------------
Call newFrm.SetPsbarValue(1)
Call WaitBehindDelay(500)

Unload newFrm
Set newFrm = Nothing
'---------------------------------------------------------------
End Sub
'**********************************************************************************************************


2006-04-28 18:40
plggli
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-3-16
收藏
得分:0 

不完整

2006-05-09 12:34
快速回复:listview导出EXCEL?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025811 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved