[VB] change row and column

Public Function PivotTable(ByVal  As DataTable) As DataTable
 Dim dest As New DataTable("Pivoted" + .TableName)

 dest.Columns.Add(" ")

 Dim r As DataRow
 For Each r In .Rows
 Next r
 Dim i As Integer
 For i = 0 To (.Columns.Count - 1) - 1
 Next i

 For i = 0 To dest.Rows.Count - 1
 Dim c As Integer
 For c = 0 To dest.Columns.Count - 1
 If c = 0 Then
 dest.Rows(i)(0) = .Columns((i + 1)).ColumnName
 dest.Rows(i)(c) = .Rows((c - 1))((i + 1))
 End If
 Next c
 Next i
 Return dest
 End Function 'PivotTable

출처: http://aspalliance.com/538_CodeSnip_Pivot_Tables_with_ADONET_and_Display_in_a_DataGrid_Paged_Horizontally


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s