Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
Export to Excel : outofmemory issue
posted

I'm trying to export a lot of data into Excel, but on the 'save' command, I get always an outofmemory problem.

Does somebody has an idea how to solve this issue?

Here is some sample code (Visual Studio 2008, with the Excel component 9.2) : 

Dim workbook As New Infragistics.Excel.Workbook(Infragistics.Excel.WorkbookFormat.Excel2007)

  workbook.SaveExternalLinkedValues = False

  workbook.CalculationMode = Infragistics.Excel.CalculationMode.Manual

  workbook.RecalculateBeforeSave = True

 

        Dim wks As Infragistics.Excel.Worksheet = Nothing

        Dim SheetRow As Integer = 1

        Dim RowsCount As Integer = 0

        Dim wksRow As Infragistics.Excel.WorksheetRow

 

        wks = workbook.Worksheets.Add("Sheet" & SheetRow)

        With wks

            For rowi As Long = 1 To 100000

                RowsCount += 1

                wksRow = wks.Rows(rowi)

                With wksRow

                    For i As Integer = 1 To 50

                        .Cells(i).Value = "VAL"

                    Next

                End With

            Next

        End With

        wks = Nothing

        workbook.Save("c:\abc11.xlsx")  '-Out Of memory exception!!!