Adagio
Well-known member
- Joined
- Dec 12, 2005
- Messages
- 162
- Programming Experience
- Beginner
Is there a way to increase performance when exporting to Excell from Vb.net using Interop?
I'm using code that looks a bit like this
The code itself works great, as in: we get the result as we want it... the problem is that it takes a long time. When we have e.g. 1000 rows it could easily take 10 minutes (depending on number of columns) before it's done. Considering that we "often" end up with 5000+ rows, time starts becoming a real problem
Is there a way to speed up this code? Is there an alternative to Interop Excel when exporting to Excel?
I'm using code that looks a bit like this
VB.NET:
Private excelApp As New Excel.Application
Private excelBook As Excel.Workbook
Private worksheet As Excel.Worksheet
excelBook = excelApp.Workbooks.Add
worksheet = CType(excelBook.Worksheets.Add(), Excel.Worksheet)
With worksheet
For each cell as MyCustomObject in listCell
.Range(cell.cellPosition).Value = cell.Value
' Here we also set vertial/horizontal alignment, wraptext = false, back and front color, etc
Next
End With
The code itself works great, as in: we get the result as we want it... the problem is that it takes a long time. When we have e.g. 1000 rows it could easily take 10 minutes (depending on number of columns) before it's done. Considering that we "often" end up with 5000+ rows, time starts becoming a real problem
Is there a way to speed up this code? Is there an alternative to Interop Excel when exporting to Excel?