PopulateArray from dataset then fill excel in 'one shoot'

nighttrain

New member
Joined
Oct 10, 2012
Messages
1
Programming Experience
3-5
Hi guys, i heard that best way to populate an excel by values e.g from dataset is to fill the array and then populate the excel sheet. I got below code:

VB.NET:
[/FONT]
[COLOR=#666600][FONT=inherit].........
[/FONT][/COLOR][COLOR=#000000][FONT=inherit]DA[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Fill[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]DS[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#008800][FONT=inherit]"sheet"[/FONT][/COLOR][COLOR=#666600][FONT=inherit])
[/FONT][/COLOR][COLOR=#000088][FONT=inherit]Dim[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iColumn[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iRow [/FONT][/COLOR][COLOR=#000088][FONT=inherit]As [/FONT][/COLOR][COLOR=#000088][FONT=inherit]Integer
[/FONT][/COLOR][COLOR=#000088][FONT=inherit]Dim[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iColumnMax[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iRowMax [/FONT][/COLOR][COLOR=#000088][FONT=inherit]As [/FONT][/COLOR][COLOR=#000088][FONT=inherit]Integer[/FONT][/COLOR][COLOR=#000000][FONT=inherit]                        
iRowMax [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#000000][FONT=inherit] DS[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Tables[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#006666][FONT=inherit]0[/FONT][/COLOR][COLOR=#666600][FONT=inherit]).[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Rows[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Count [/FONT][/COLOR][COLOR=#666600][FONT=inherit]-[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#000000][FONT=inherit]                        
iColumnMax [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#000000][FONT=inherit] DS[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Tables[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#006666][FONT=inherit]0[/FONT][/COLOR][COLOR=#666600][FONT=inherit]).[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Columns[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Count [/FONT][/COLOR][COLOR=#666600][FONT=inherit]-[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1 [/FONT][/COLOR][COLOR=#000088][FONT=inherit]For[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iRow [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#006666][FONT=inherit]0 [/FONT][/COLOR][COLOR=#000088][FONT=inherit]To[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iRowMax                            
[/FONT][/COLOR][COLOR=#000088][FONT=inherit]For[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iColumn [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#006666][FONT=inherit]0 [/FONT][/COLOR][COLOR=#000088][FONT=inherit]To[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iColumnMax                                
[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]iRow [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]2[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] iColumn [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#666600][FONT=inherit]).[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Value [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#000000][FONT=inherit] DS[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Tables[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#006666][FONT=inherit]0[/FONT][/COLOR][COLOR=#666600][FONT=inherit]).[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Rows[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]iRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit]).[/FONT][/COLOR][COLOR=#000000][FONT=inherit]Item[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]iColumn[/FONT][/COLOR][COLOR=#666600][FONT=inherit])
[/FONT][/COLOR][COLOR=#000088][FONT=inherit]Next
[/FONT][/COLOR][COLOR=#000088][FONT=inherit]Next
[/FONT][/COLOR]


that's the way i am filling the excel sheet, but sometimes it takes almost 1 hour with big wuerie, so i decided to try something else like put firstly the values from dataset to array and then fill the sheet in one shoot. Could someone show me how i could do that on my above example?

thanks & regards
 
Back
Top