Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In our desktop environment, I have reached the best mix between performance, flexibility and stability by using Excel via COM.</p> <p>Access to Excel is always via the same thread.</p> <p>I use late-binding (in VB.Net) to make my app version independent. </p> <p>The rest of the application is developed in C#, only this part and some other small parts are in VB, because they are easier in VB.Net.</p> <pre><code>Dim workBook As Object = GetObject(fileName) Dim workSheet As Object = workBook.WorkSheets.Item(WorkSheetNr) Dim range As Object = workSheet.Cells.Item(1, 1) Dim range2 As Object = range.CurrentRegion Dim rrow As Integer = range2.Row ' For XL97, first convert to integer. XL97 will generate an error ' Dim rcolumn As Integer = range2.Column Dim top As Object = workSheet.Cells.Item(rrow, rcolumn) Dim bottom As Object = top.Offset(range2.Rows.Count - 1, range2.Columns.Count - 1) range = workSheet.Range(top, bottom) Dim values As Object(,) values = range.Value </code></pre> <p>Here you have a 2-dimensional array containing the values from Excel. The last statement gets the data from Excel to .Net.</p> <p>Since the limits on the size of a Excel sheet, these cannot get very large, so memory should not be a problem.</p> <p>We have done some tests on performance, on multiple systems. It is optimized to create as few as possible (out-of-process) COM calls.</p> <p>This way was the one that has given us the best performance, specially since the data is directly in an array, and access to this data is faster as going through a dataset.</p> <p>Slow in this solution is starting Excel. But if you need to process multiple files, right after each other, the cost of starting Excel is made only once.</p> <p>Also I would not use this solution in a server environment.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload