Free Support Forum - groupdocs.com

Small xlxs file causing big issues when converting to HTML

.net version 17.6.0

The file size is 292Kb. I’m trying to only process the first page, but it seems like the whole document is bring processed.

Here is what I’m doing to only process one page. Let me know if this is correct.

            HtmlOptions options = new HtmlOptions();
            options.PageNumber = 1;
            options.CountPagesToRender = 1;

Does the whole file get processes even though I only want to display the first page? I have read there are some ways to display the first page almost instantly. I have not found a way to do that.

I have read that there is a method PreloadPagesCount(1) somewhere that makes displaying the first page very fast. I have not found that function

When running the function GetPages it takes a little while to get the pages and only one page comes back. However, the page.HtmlConent.Lenght is around 721650665. That’s pretty big for the first page. I cannot render that to the client.

Any help would be great.

Thanks

@todds,

Thanks for using GroupDocs.Viewer for .NET. Yes, you are using absolutely correct code to render first page of the document. The API doesn’t process all the pages of the document if you set PageNumber and CountPagesToRender properties of HtmlOptions. Instead, it renders only the specified number of pages into HTML or image representation. Please note that document rendering time depends on multiple factors such as document’s content which can include text, images, tables, graphical content etc.

PreloadPagesCount() function is not part of the back-end GroupDocs.Viewer for .NET API. Instead, it is implemented in some of our showcase applications. The purpose of this function is to render and load the specified number of pages when the user opens a document in the application. Whereas, the rest of the document’s pages are rendered when the user scrolls down in the viewer control. The backend code of PreloadPagesCount() is same as you mentioned in your post.

In order to investigate this matter at our end, would you please share with us the document that you are rendering? We shall be looking forward to your response.

Sample.zip (249.4 KB)

I have uploaded the sample xlxs file

Thanks

@todds,

Thanks for providing the sample document. We have successfully reproduced the issue that the API is not rendering the second sheet of the Excel document. Therefore, we have logged it in our internal Issue Tracking System (ID: VIEWERNET-1372) for further investigation. In case of any further updates, we’ll notify you here. Furthermore, the API also provides the feature of the partial rendering of large Excel sheets. Please see this documentation article for more details.

Hi @todds !

Try to use this option:
options.CellsOptions.IgnoreEmptyRows = true;

Thank you!

@todds,

I will like to add to the solution provided by my colleague. The first sheet of the sample file contains content at the start and then at the end as well (see this) and in between, there are thousands of empty rows. When the API renders the first sheet, it also renders the empty rows and as a result, it takes too much time to render the whole document and the HTML content of the first sheet becomes too lengthy.

To fix this issue you can use HtmlOptions.CellsOptions.IgnoreEmptyRows = true. This setting will tell the API to ignore the empty rows and render only those that contain some content. Hope it helps.