DataGridView复制到Excel格式

2021-01-13 23:14

阅读:370

标签:GridView   div   for   cells   color   clipboard   row   grid   val   

 

Clipboard.Clear()  清除剪贴板
        If DataGridView2.Rows.Count > 0 Then
            Dim a As New List(Of String)
            For i As Integer = 0 To DataGridView2.Rows.Count - 1
                Dim b(DataGridView2.Columns.Count - 3) As String
                For j As Integer = 1 To DataGridView2.Columns.Count - 2
                    b(j - 1) = DataGridView2.Rows(i).Cells(j).Value
                Next
                a.Add(String.Join(vbTab, b))
            Next

            Clipboard.SetText(String.Join(vbCrLf, a.ToArray))
            a = Nothing
        End If

 

DataGridView复制到Excel格式

标签:GridView   div   for   cells   color   clipboard   row   grid   val   

原文地址:https://www.cnblogs.com/rf8862/p/12275196.html

上一篇:DataGridView显示行号

下一篇:windows git


评论


亲,登录后才可以留言!