Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

SheetRender ToImage Throws Exception: Index was out of range. Must be non-negative and less than the size of the collection.

Last post 07-28-2010, 5:30 AM by aspose.notifier. 4 replies.
Sort Posts: Previous Next
  •  07-22-2010, 7:58 AM 249910

    SheetRender ToImage Throws Exception: Index was out of range. Must be non-negative and less than the size of the collection. .NET

    Attachment: Present (inaccessible)

    Hello,

     

    We are creating TIF files from XLS files.  We have an XLS that generates the exception “Index was out of range. Must be non-negative and less than the size of the collection.”  The error is generated when the 4th worksheet in the XLS is converted to a TIF.  We have been able to convert other XLS files that contain more worksheets than this one so we do not understand why this one is failing.  It displays properly in Excel.  It appears to be a problem with SheetRender.

     

    The uploaded ZIP file, XLS-IndexException.zip, contains the problem XLS file.

     

    We are using Aspose.Cells.dll 5.0.0.13 which was given to us last week.

     

    This is the code that we are using to render the tifs.

     

        Workbook book = new Workbook();

        book.Open(fullPath);

     

        if (imgOptions == null)

        {

            imgOptions = new ImageOrPrintOptions();

            imgOptions.ImageFormat = ImageFormat.Tiff;

            imgOptions.HorizontalResolution = 200;

            imgOptions.VerticalResolution = 200;

            imgOptions.TiffCompression = TiffCompression.CompressionCCITT4;

            imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;

        }

     

        int bookPageCount = 0;

     

        for (int i = 0; i < book.Worksheets.Count; i++)

        {

            Worksheet sheet = book.Worksheets[i];

            if (settingOrientation) sheet.PageSetup.Orientation = orientation;

            if (settingZoom) sheet.PageSetup.Zoom = zoom;

            if (settingPrintGridlines) sheet.PageSetup.PrintGridlines = printGridlines;

            if (settingAutoFitColumns) sheet.AutoFitColumns();

            if (settingAutoFitRows) sheet.AutoFitRows();

     

            if (imgOptions.TiffCompression == TiffCompression.CompressionCCITT4)

            {

                foreach (Cell cell in sheet.Cells)  // If rendering to B&W, force black text on white background.

                {

                    cell.Style.Font.Color = Color.Empty;

                    cell.Style.ForegroundColor = Color.Empty;

                    cell.Style.BackgroundColor = Color.Empty;

                    cell.Style.Pattern = BackgroundType.None;

                }

            }

     

            SheetRender sr = new SheetRender(sheet, imgOptions);

            int sheetPageCount = sr.PageCount;                   

            string subPageName = string.Empty;

     

            for (int j = 0; j < sheetPageCount; j++)

            {

                subPageName = SubPageName(pageName, (uint)(bookPageCount + j));  // Generates a unique file name

                sr.ToImage(j, batchDir + @"\" + subPageName + ".tif");

            }

     

            sr = null;

            bookPageCount += sheetPageCount;

        }

     

    I look forward to your reply.

     

    Thank you,

    Robert

     
  •  07-22-2010, 1:02 PM 249983 in reply to 249910

    Re: SheetRender ToImage Throws Exception: Index was out of range. Must be non-negative and less than the size of the collection.

    Hi,

    Thanks for providing us the template file with sample code:

    I can find the issue as you have described using your template file with sample code provided. We will figure your issue out soon. I have logged your issue into our issue tracking system with an id: CELLSNET-18687. Once we have any update about it, we will let you know.

    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-23-2010, 6:24 AM 250125 in reply to 249983

    Re: SheetRender ToImage Throws Exception: Index was out of range. Must be non-negative and less than the size of the collection.

    Attachment: Present (inaccessible)
    Hi,

    Please try the attached version.

    We have fixed your issue now.

    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  07-23-2010, 7:50 AM 250147 in reply to 250125

    Re: SheetRender ToImage Throws Exception: Index was out of range. Must be non-negative and less than the size of the collection. .NET

    Hello,

    I can confirm that this fixes the problem.

    Thank you,

    Robert

     
  •  07-28-2010, 5:30 AM 250822 in reply to 249910

    Re: SheetRender ToImage Throws Exception: Index was out of range. Must be non-negative and less than the size of the collection.

    The issues you have found earlier (filed as 18687) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
View as RSS news feed in XML