社区
VB基础类
帖子详情
高分求:如何将listview表格中的内容导出到EXCEL2000文件中?
tianhao123
2003-12-09 05:26:14
最好给个例子!
...全文
39
2
打赏
收藏
高分求:如何将listview表格中的内容导出到EXCEL2000文件中?
最好给个例子!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Kain
2003-12-09
打赏
举报
回复
mark
SoHo_Andy
2003-12-09
打赏
举报
回复
'将listView中的数据导出到Excel的例子
'希望对你有帮助
Private Sub PrintToExcel()
On Error GoTo ErrTrap
Dim xlsApp As New Excel.Application
Dim xlsBook As New Excel.Workbook
Dim xlsSheet As New Excel.Worksheet
Dim i As Integer
Dim j As Integer
Dim xlsRow As Integer
Dim xlsCol As Integer
xlsCol = lsvShow.ColumnHeaders.Count - 3
xlsRow = 3
Set xlsBook = xlsApp.Workbooks.Add
Set xlsSheet = xlsBook.Worksheets(1)
xlsSheet.PageSetup.Orientation = xlLandscape '横向打印
frm_Wait.Show
xlsApp.Columns(1).NumberFormatLocal = "@"
'写入列名
For i = 1 To lsvShow.ColumnHeaders.Count - 3
xlsApp.Cells(xlsRow, i) = " " & Trim(lsvShow.ColumnHeaders(i).Text)
xlsApp.Columns(i).Select
xlsApp.Selection.ColumnWidth = lsvShow.ColumnHeaders(i).Width / 100
Next i
'xlsApp.Columns(1).AutoFit
xlsRow = xlsRow + 1
'写入列表内容
For i = 1 To lsvShow.ListItems.Count
xlsApp.Cells(xlsRow, 1) = Trim(lsvShow.ListItems(i).Text)
For j = 1 To lsvShow.ColumnHeaders.Count - 4
xlsApp.Cells(xlsRow, j + 1) = Trim(lsvShow.ListItems(i).SubItems(j))
xlsApp.Cells(xlsRow, j + 1).WrapText = True
Next j
xlsRow = xlsRow + 1
Next i
'写入标题和时间
xlsApp.Range(xlsApp.Cells(1, 1), xlsApp.Cells(1, xlsCol)).Select
With xlsApp.Selection
.MergeCells = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
xlsApp.Cells(1, 1) = labKeyName.Caption
xlsApp.Cells(1, 1).Font.Size = 24
xlsApp.Cells(1, 1).Font.Bold = True
xlsApp.Cells(2, 1) = "打印时间:" & Date
'设置边框
xlsApp.Range(xlsApp.Cells(3, 1), xlsApp.Cells(xlsRow, xlsCol)).Select
With xlsApp.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With xlsApp.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With xlsApp.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With xlsApp.Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With xlsApp.Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With xlsApp.Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
xlsApp.Visible = True
frm_Wait.Visible = False
Call VBA.AppActivate(xlsBook.Name)
On Error GoTo 0
Exit Sub
ErrTrap:
On Error GoTo 0
End Sub
我在CSDN参与的3000个帖子
今日偶然翻到,感慨万千 1:申述:版主,是否扣了我的专家分? 2:100分急
求
,随机输出十个小写字母,但是,要
求
这十个字母不相同 3:
求
Sn=a+aa+aaa+…+aaa…a(n个a)之值 4:数组题 望高手帮忙! 5:呵呵,来推荐...
WEB开发文档2 总结
//blog.donews.com/lvjiyong/archive/2006/06/29/931071.aspx怎样将后台生成的在内存
中
的图象显示到客户端Microsoft IE WebControls下载地址如何在DATAGRID
中
使用JAVASCRIPT脚本控制DataGrid
中
连接到下一页显示数据...
vb/vb.net开发精粹(6)
C2.exe不能执行是如何...在程序
中
违反唯一约束条件的写入命令,如何做令程序不自动退出 在程序
中
违反唯一约束条件的写入命令,如何做令程序不自动退出 对象打开时不允许操作 对象打开时不允许操作 C2.exe不能执行
CSDN回帖得分大全(近两年)
#pragma comment如何导入指定
文件
夹的lib
文件
+
导出
函数命名规范的问题 [VC/MFC 进程/线程/DLL] √ 在管理员登录框
中
点击了确定,为什么进入不了管理界面? [VC/MFC 基础类] √ 关于初级dll编写...
ExMobi®从入门到精通
ExMobi®从入门到精通 本书电子版和示例代码请访问GIT仓库: https://github.com/nandy007/ExMobiBeginnerBook ExMobi门户:http://www.exmobi.cn ExMobi论坛:...
VB基础类
7,763
社区成员
197,609
社区内容
发帖
与我相关
我的任务
VB基础类
VB 基础类
复制链接
扫一扫
分享
社区描述
VB 基础类
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章