Created
June 27, 2016 11:59
-
-
Save metinsaylan/642f091ba7902d323717e1c8bc6f8d0f to your computer and use it in GitHub Desktop.
Rotate DataTable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Shared Function RotateTable(dt As DataTable) As DataTable | |
Dim dt2 As New DataTable() | |
For i As Integer = 0 To dt.Rows.Count | |
dt2.Columns.Add() | |
Next | |
For i As Integer = 0 To dt.Columns.Count - 1 | |
dt2.Rows.Add() | |
dt2.Rows(i)(0) = dt.Columns(i).ColumnName | |
Next | |
For i As Integer = 0 To dt.Columns.Count - 1 | |
For j As Integer = 0 To dt.Rows.Count - 1 | |
dt2.Rows(i)(j + 1) = dt.Rows(j)(i) | |
Next | |
Next | |
Return dt2 | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment