下面这个表格,想要实现分组行根据+或者-的状态导出为excel,就是客户展开那些行,就导出那些行,如何实现?
此主题相关图片如下:屏幕截图 2024-08-08 140435.png
最好是能带上格式。怎么修改代码?
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For Each c As Col In CurrentTable.cols
If c.Visible Then
Sheet(0, c.Index).Value = c.Caption
End If
Next
For r As Integer = 0 To CurrentTable.Rows.Count - 1 '填入数据
For Each c As Col In CurrentTable.cols
If c.Visible Then
Sheet(r + 1, c.Index).Value = CurrentTable.rows(r)(c.name)
End If
Next
Next
'保存并打开excel文件
Book.Save(SpecialFolder.DesktopDirectory & "\下载数据" & Date.today & ".xls")
Dim Proc As New Process
Proc.File = SpecialFolder.DesktopDirectory & "\下载数据" & Date.Today & ".xls"
Proc.Start()
[此贴子已经被作者于2024/8/8 14:05:31编辑过]
我可以导出分组的行,问题的关键在于被折叠的行也会导出来,怎么实现不导处被折叠的行?
就是按照目录树的点选方式导出excel,怎么判断行是否是打开的状态?
Dim cnt As Integer = Tables("表A").grid.Rows.Count
For i As Integer = Tables("表A").HeaderRows To cnt - 1
Dim r = Tables("表A").grid.Rows(i)
If r.DataIndex = -1 Then
MsgBox("是分组行")
End If
If r.IsCollapsed Then
MsgBox("行已被折叠")
End If
Next