Hi,
I have a data table that contains around 9000 rows,
And I am sending the data into pre-formated Excel sheet
and you can see my code below:
Dim myRow as Integer = 13
Dim rowNTMS as DataRow
With oWB.ActiveSheet
For Each rowNTMS In ExcelTABLE.Rows
.Cells(myRow, 1).value = rowNTMS(0).ToString
.Cells(myRow, 2).value = rowNTMS(1).ToString
.Cells(myRow, 3).value = rowNTMS(2).ToString
.Cells(myRow, 4).value = rowNTMS(3).ToString
.Cells(myRow, 5).value = rowNTMS(4).ToString
.Cells(myRow, 6).value = rowNTMS(5).ToString
myRow = myRow + 1
Next
End With
My problem is its writing per row in 1 second. This way it could take me
nearly 2-3 hours to complete the report.
Does anyone know any fastes way to achive this.
By the way the ExcelTABLE is my dataTable that fill with data.
Thank you very much for your kind understanding and reading my post.
Rgds,
Niyazi
Josef Brunner - 26 Apr 2006 10:44 GMT
Hi,
> My problem is its writing per row in 1 second. This way it could take me
> nearly 2-3 hours to complete the report.
>
> Does anyone know any fastes way to achive this.
> By the way the ExcelTABLE is my dataTable that fill with data.
I have the same problem. Does anyone have a solution yet? When I open an XML
File in Excel the import happens within a second, but when I read the XML
File throuhg vb and insert it line by line into Excel it takes a couple of
minutes...
thx,
Kurt
Niyazi - 27 Apr 2006 05:56 GMT
Hi,
I guess either we doing the right think or there is noone out there to
answer it.
I found that my coding the fastest way to doing things. The each row
contains nearly 7-9 columns and if I reduce it to say 2-3 column per row it
writes 2 row in per second.
Unfortunetly to me that I need to use 9 column for each row. So it is normal
to me to have 1sec for per row. 9000 row means 9000s / 60 = 150 min / 60 =
2.5 Hr
Plus I need to work with data before sending in to Result Table and that
takes nearly 10-15 min. Creating a Report in 3 Hrs its okay.
For the XML you should send your data first into Data Table in VB.NET and
use that data table and insert in Excel might be faster whatever you doing
now.
- Read from XML to dtRESULTTABLE
- Work with data whatever you want / Or if you don't want to work with data
then skip this section
- Create a new Excel sheet with using VB.NET + Excel.Interop and send the
dtRESULTTABLE data into Excel row by row. if your output has some pre
define
format or as template might takes a while but, say 2 sec or less per
row. Or if
you just insert it in Excel starting from A1 cell then it will take 2 row
in 1 sec.
reading from XML and sending it to Excel is much faster. You should avoid to
read per xml line and insert into Excel. Read all the XML line into dataTable
and then send it to Excel.
I hope this will help you.
Rgds,
Niyazi
> Hi,
>
[quoted text clipped - 11 lines]
> thx,
> Kurt
ct - 15 May 2006 19:59 GMT
Convert the datatable into and array and then insert the array into
excel using the sheet.range command as follows:
Sheet.Range("A1" , "I9000").Value = arrData
This would insert a 9000 by 9 array into an Excel sheet in one step.
Might be quite a bit faster.
Hope this helps.
Niyazi - 16 May 2006 05:53 GMT
Hi,
Thank you but I find the solution and it is much fatsrer in VS.NET 2005.
I create a stringBuilkder and used cupy and paste method but analysis of
data I used xsd adapter. And 9000 rows will just run in 0.42 second.
Thank you
> Convert the datatable into and array and then insert the array into
> excel using the sheet.range command as follows:
[quoted text clipped - 4 lines]
>
> Hope this helps.
Jeremy Chapman - 17 May 2006 00:04 GMT
output to csv and load that into excel.
> Convert the datatable into and array and then insert the array into
> excel using the sheet.range command as follows:
[quoted text clipped - 4 lines]
>
> Hope this helps.