Free Support Forum - groupdocs.com

Xlsx to html - System.OutOfMemoryException


#1

Hello, I’m running tests in the viewer and I’m having some problems with xlsx files, first I had problem with the git example, so I created a sample version with the code that was in the support, and I got similar errors.

With the git example with 2 mb files it crashes the browser, and in the example of the media it finishes the memory.

What am I doing wrong?

image.png (17.2 KB)

image.png (27.5 KB)

image.png (53.7 KB)


#2

@foller,

Please share with us the following details so that we can investigate the issue at our end.

  • Problematic xlsx file
  • Version of GroupDocs.Viewer you are using
  • Sample application you have created for testing

#3

helo, here is the problematic xlsx file, but the problem is with any xlsx file that has more than 1 mb.
The version is 19.5.
Follow the project, I just created a new project in .NET, installed the viewer through nuget and copied the example code from the documentation.

Pasta 1mb.zip (333.8 KB)
WebApplication4.zip (940.2 KB)


#4

@foller,

Thanks for providing the required details. The OutOfMemory exception is usually thrown when there is not enough memory to continue the execution of a process or program. Therefore, the possibility is there that your application is unable to find the required amount of contiguous memory to execute GetPages function for the large Excel files. For more details on this exception and its causes, please read this article.

To handle such situations while rendering large Excel files, you can break down the sheet into multiple HTML pages instead of a single page. This is how you can render a large sheet into multiple HTML pages:

ViewerConfig config = new ViewerConfig();
config.StoragePath = @"D:\storage\";
config.EnableCaching = true;
// Initailize ViewerHandler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
//Set HtmlOptions to render multiple pages per sheet
HtmlOptions options = new HtmlOptions();
options.CellsOptions.OnePagePerSheet = false;
options.CellsOptions.CountRowsPerPage = 500;
// Get Html pages
List<PageHtml> pages = htmlHandler.GetPages("Pasta 1mb.xlsx", options);

#5

usman.aziz Thanks for the reply, I added the cache, it is already breaking on several pages automatically. I’m running on another computer with more processing and memory. But now I’m having a sloppy issue this is running the viewer for 40 minutes and has not brought all the pages.

Computer
Processor i7 7 generation
Memory 16 gb
SSD Disc

Screenshot_2.png (7.3 KB)
Screenshot_1.png (12.2 KB)


#6

@foller,

I have tried rendering your provided Excel document using your sample application. The average total time to render the document into 152 HTML pages is approx. 11 seconds. I performed this test with the same specs of processor and RAM that you have mentioned. For reference, please download the modified sample application that shows the total rendering time on the index page (see screenshot).


#7

Helow Usman, the xlsx problem was solved with the code that you returned me, but I’m still having problems with other file types, xlsx has lost the properties of the columns and now only the values ​​appear. The workflow.doc file returns an error, but the other types of files are still taking too long to process. follows files and print. What we can do to make these tests faster, I was hired by the company to do tests until Friday to buy the product if it meets the needs.

image.png (19.8 KB)
Documento388.zip (2.0 MB)
Workflow.zip (2.6 MB)
arquivo (5).zip (3.6 MB)


#8

@foller,

We are able to observe this behavior where Excel worksheet loses it’s formatting when rendered as multiple pages per sheet. Therefore, we have logged this issue in our Internal Issue Tracking System as VIEWERNET-2052 for further investigation.

We are able to reproduce the exception at our end and it has been logged into our internal Issue Tracking System as VIEWERNET-2051 for further investigation.

The rendering time depends upon multiple factors such as the number of pages, document’s content which can include text, images, tables; the amount of resources that application can use; server’s specifications and so on. It is expected that the larger documents (having large number of pages) may take more time as compared to the smaller ones. Furthermore, we have tried rendering all of your provided documents and they are not taking much time (i.e. Documento388.pdf takes around 37 seconds) except for arquivo (5).docx which contains 1478 pages.

The cache feature of GroupDocs.Viewer API also improves the rendering time when a large document is rendered multiple times. Once the document is rendered, the files are stored in cache and then reused when the same document is rendered again. This way, a considerable time is saved.

Another way to avoid delays when rendering large documents is to render one page at a time. This can be implemented in the front end applications where we can render a fix number (i.e. 5 pages) of pages at start and then instead of rendering all the pages at once, we can render each page when user scroll downs for the next page. For this the API provides the following properties:

HtmlOptions options = new HtmlOptions();
// This will render page number 2 only.
options.PageNumber = 2;
options.CountPagesToRender = 1;
List<PageHtml> Pages = htmlHandler.GetPages("file.docx", options);

For reference, please download this simple console application that we used for testing.


#9

@foller,

The issue you have reported earlier regarding the formatting of the Excel worksheets (logged as VIEWERNET-2052) has been fixed. The fix will be included in the upcoming release (v19.6) of GroupDocs.Viewer for .NET.


#10

@foller,

The issue you have faced earlier, logged as VIEWERNET-2052, has been fixed in this release.