We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception thrown when converting to images after changing Separator in the workbook settings

Hi,

I’m trying to convert an Excel worksheet to image and try to mimic the ‘Separators’ feature in Excel application settings:
image.png (35.0 KB)

However, I found Aspose threw an exception after I changed the code using Aspose APIs.

Code:

        var doc = new Workbook(@"\test.xlsx");
        var options = new ImageOrPrintOptions
        {
            ImageType = ImageType.Emf,
            OnlyArea = false, // copy as picture - as shown when printed
            TextRenderingHint = TextRenderingHint.ClearTypeGridFit,
            OnePagePerSheet = true,
            Transparent = true
        };
        doc.Worksheets[0].PageSetup.PrintArea = "B7:G20";
        doc.Settings.NumberDecimalSeparator = ',';
        doc.Settings.NumberGroupSeparator = ' '; // the possible problematic line
        new SheetRender(doc.Worksheets[0], options).ToImage(0, @".\out.emf");

It threw an exception on the last line.

Aspose.Cells.CellsException: Non-negative number required.
Parameter name: length

I’ve attached my test files for your reference. Could you please help me take a look?

test.zip (11.1 KB)

Thanks,

@ServerSide527,
It seems that you are using some older version as no exception is raised while running the above sample code using the sample test.xlsx file. You may please try it using the latest version and share the feedback. The program output is shared here for your reference.
out.zip (10.4 KB)

Hi,

I have tried the latest Aspose.Cells version and indeed the issue does not happen again. Thanks for pointing this out.

Due to a regression in a separate topic How to access Asian/Latin font in chart legends / axis labels / textboxes? I’m yet not able to upgrade Aspose.Cells, but it is good that the issue mentioned here has been fixed so I can make use of the API later.

Thanks again.

@ServerSide527,
You are welcome.