This is a migrated thread and some comments may be shown as answers.

System Out Of Memory Exception while Exporting to Excel

1 Answer 102 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Lithin
Top achievements
Rank 1
Lithin asked on 08 Nov 2018, 11:53 AM

Hi ,

The telerik version we are using is : 2016.1.225.45.

We are facing an out of memory exception while trying to export close to 200k records using Telerik spreadsheet. 

The for each loop snippet shown below executes for each of the 200k records.It is taking more than 5 mins. Is there any way to reduce the time consumption ?

 Dim currentRow As Integer = 6
        For Each row As DataRow In data.Rows
            sheet1.Cells(currentRow, 0).SetFormat(New CellValueFormat("@"))
            sheet1.Cells(currentRow, 0).SetValue(Convert.ToString(row("ClientID")))
            sheet1.Cells(currentRow, 0).SetIsWrapped(True)
            sheet1.Cells(currentRow, 1).SetFormat(New CellValueFormat("@"))
            sheet1.Cells(currentRow, 1).SetValue(Convert.ToString(row("ShortName")))
            sheet1.Cells(currentRow, 1).SetIsWrapped(True)
            sheet1.Cells(currentRow, 2).SetFormat(New CellValueFormat("@"))
            sheet1.Cells(currentRow, 2).SetValue(Convert.ToString(row("KnowledgeCategory")))
            sheet1.Cells(currentRow, 2).SetIsWrapped(True)
            sheet1.Cells(currentRow, 3).SetFormat(New CellValueFormat("@"))
            sheet1.Cells(currentRow, 3).SetValue(Convert.ToString(row("AuthoredBy")))
            sheet1.Cells(currentRow, 3).SetIsWrapped(True)
            sheet1.Cells(currentRow, 4).SetFormat(New CellValueFormat("@"))
            If IsDBNull(row("AuthoringDate")) Or String.IsNullOrEmpty(row("AuthoringDate").ToString()) Then
                AuthoringDate = ""
            Else
                AuthoringDate = Convert.ToDateTime(row("AuthoringDate")).ToString("dd/MM/yyyy")
            End If
            sheet1.Cells(currentRow, 4).SetValue(AuthoringDate)
            sheet1.Cells(currentRow, 4).SetIsWrapped(True)
            sheet1.Cells(currentRow, 5).SetFormat(New CellValueFormat("@"))
            sheet1.Cells(currentRow, 5).SetValue(Convert.ToString(row("IndustryName")))
            sheet1.Cells(currentRow, 5).SetIsWrapped(True)
            If ChangeType <> "Deleted Records" Then
                sheet1.Cells(currentRow, 6).SetFormat(New CellValueFormat("@"))
                sheet1.Cells(currentRow, 6).SetValue(Convert.ToString(row("TranslationChange")))
                sheet1.Cells(currentRow, 6).SetIsWrapped(True)
                sheet1.Cells(currentRow, 7).SetFormat(New CellValueFormat("@"))
                sheet1.Cells(currentRow, 7).SetValue(Convert.ToString(row("Comment")))
                sheet1.Cells(currentRow, 7).SetIsWrapped(True)
            Else
                sheet1.Cells(currentRow, 6).SetFormat(New CellValueFormat("@"))
                sheet1.Cells(currentRow, 6).SetValue(Convert.ToString(row("Comment")))
                sheet1.Cells(currentRow, 6).SetIsWrapped(True)
            End If

            currentRow = currentRow + 1
        Next

Also while exporting the worksheet, an out of memory exception is thrown. Please provide some help over the issue.

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Anna
Telerik team
answered on 13 Nov 2018, 08:52 AM
Hi,

Have you had the chance to check out our SpreadStreamProcessing library? it is specifically designed to be fast and memory-efficient in scenarios that are limited to creation and export of files. If this case does not involve import and editing, I believe this library should do the trick. You can find the link to the documentation here: https://docs.telerik.com/devtools/document-processing/libraries/radspreadstreamprocessing/overview

Regards,
Anna
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Spreadsheet
Asked by
Lithin
Top achievements
Rank 1
Answers by
Anna
Telerik team
Share this question
or