Exception when saving XLSX with comments to PDF format

Hi,

The following code with the attached XLSX file causes an “Index was outside the bounds of the array” exception in Aspose.Cells for .NET 21.4:

var loadOpts = new Aspose.Cells.LoadOptions
{
    MemorySetting = Aspose.Cells.MemorySetting.MemoryPreference
};

var workbook = new Aspose.Cells.Workbook("input.xlsx", loadOpts);

foreach (var sheet in workbook.Worksheets)
{
    sheet.PageSetup.PrintComments = Aspose.Cells.PrintCommentsType.PrintSheetEnd;
}

workbook.Save("output.pdf"); // hits exception

input.zip (731.8 KB)

Interestingly, the exception only occurs when the workbook is loaded with the MemoryPreference option.

Thanks

@ast3,

Please notice, I am able to reproduce the issue as you mentioned by using your template file. I found an exception “Index was outside the bounds of the array” when saving XLSX with comments to PDF format. Since you are using MemoryPreference mode (while loading the file) but you are shifting comments to the end of the sheet (via code), so the exception might occur. To get best results for MemoryPreference mode, you should not disturb/shift the data, objects or contents in rows and columns. I think, you may easily cope with it by not using MemoryPreference mode while loading the file rather specify the mode before shifting the comments. See the sample code segment for your reference:
e.g.
Sample code:


var workbook = new Aspose.Cells.Workbook(“e:\test2\input.xlsx”);
workbook.Settings.MemorySetting = MemorySetting.MemoryPreference;
foreach (Worksheet sheet in workbook.Worksheets)
{
sheet.PageSetup.PrintComments = Aspose.Cells.PrintCommentsType.PrintSheetEnd;
}

The above workaround will fix your issue.

Anyways, to investigate your issue in details and to figure it out, we have also logged a ticket with an id “CELLSNET-48048” for your issue. We will look into it to resolve it soon.

Once we have an update on it, we will let you know.

@ast3,

This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

The issues you have found earlier (filed as CELLSNET-48048) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao