使用vb2010获取要插入的最后一个单元格以及excel中的下一个空单元格

时间:2017-08-04 14:36:22

标签: excel vb.net excel-vba vba

xlwsheet.Cells(10, 2) = SearchedID.ToString
        xlwsheet.Cells(11, 2) = Name.ToString
        xlwsheet.Cells(12, 2) = ""
        xlwsheet.Cells(13, 2) = BlckYr.ToString
        For num1 = 0 To dgv1stSem.RowCount - 1
            For num2 = 0 To dgv1stSem.ColumnCount - 1
                For num3 = 1 To dgv1stSem.Columns.Count
                    Try
                        xlwsheet.Cells(17 + num1, 1 + num2) = dgv1stSem.Item(num2, num1).FormattedValue.ToString
                    Catch ex As Exception

                    End Try
                Next
            Next
        Next
        xlapp = Nothing
        xlwbook = Nothing
    End If

我正在尝试将4个datagridview导出为ex​​cel,但我只能传输1个datagridview,如何找到最后一个单元格和下一个空单元格以开始第二个datagridview的下一次传输?

0 个答案:

没有答案