Free Support Forum - groupdocs.com

.Net Version trying simple and getting "Parameter is not valid."

Version 17.6.0.0

When running the below code, I get the error “Parameter is not valid” at GetPages. Any ideas?

        try
        {

            ViewerConfig config = new ViewerConfig();
            config.StoragePath = Common.StoragePath;

            ViewerImageHandler imageHandler = new ViewerImageHandler(config);

            ImageOptions options = new ImageOptions();

            List<PageImage> Images = imageHandler.GetPages(@"C:\work\groupdocs\Junk.xlsx", options);


            foreach (PageImage image in Images)
            {
                Common.SaveAsImage(image.PageNumber + "_" + "ABCD", image.Stream);
            }
        }
        catch (Exception err)
        {

            string er = err.Message;
        }

@todds,

Thanks for using GroupDocs.Viewer for .NET API. In order to investigate the issue at our end, we would require you to please share with us the problematic document. 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 problematic document. We have successfully reproduced your reported issue at our end. The issue has been logged into our internal Issue Tracking System with ID: VIEWERNET-1371. We shall further investigate this issue and in case of any updates, we’ll notify you here.

@todds,

The issue happens because the first sheet of the provided Excel document contains a huge number of empty rows. When the API tries to render the whole sheet (including the empty rows), it becomes impossible to create such a big image and the exception is thrown. To tackle this situation, please use options.CellsOptions.IgnoreEmptyRows = true as shown below.

    try
    {
        ViewerConfig config = new ViewerConfig();
        config.StoragePath = Common.StoragePath;

        ViewerImageHandler imageHandler = new ViewerImageHandler(config);

        ImageOptions options = new ImageOptions();
        // ignore empty rows
        options.CellsOptions.IgnoreEmptyRows = true; 

        List<PageImage> Images = imageHandler.GetPages(@"C:\work\groupdocs\Junk.xlsx", options);

        foreach (PageImage image in Images)
        {
            Common.SaveAsImage(image.PageNumber + "_" + "ABCD", image.Stream);
        }
    }
    catch (Exception err)
    {
        string er = err.Message;
    }

Hope it helps.

Thank you.

@todds,

You are welcome.

So, I’m using version 17.6 and I do not see options.CellsOptions.IgnoreEmptyRows. The online API says it is up to 17.9. How do I get version 17.9? Tried downloading the trial version, but it is at 17.6.

@todds,

Thanks for your response. The feature of ignoring empty rows in Excel sheets is available from version 17.8.0. You can download the latest version of GroupDocs.Viewer for .NET from here and add its reference manually. Furthermore, you can also add it in your application from NuGet using Package Manager Console with the following command.

Install-Package GroupDocs.Viewer -Version 17.9.0.

Hope it helps