ArgumentOutOfRange excpetion while extracting pictures from worksheet

Last post 02-25-2009, 9:38 PM by Laurence. 8 replies.
Sort Posts: Previous Next
  •  01-27-2009, 11:23 AM 162141

    ArgumentOutOfRange excpetion while extracting pictures from worksheet

    Attachment: Present (inaccessible)
    Hi, I am using the following code to extract pictures from a worksheet:

                           Workbook wb = new Workbook();
                wb.Open(@"E:\test2.xls");
                foreach (Worksheet ws in wb.Worksheets)
                {
                    if (ws.Type == SheetType.Chart)
                        continue;

                    int index = 0;
                    foreach (Picture picture in ws.Pictures)
                    {
                        //save the image:
                        Bitmap bmp = new Bitmap(new MemoryStream(picture.Data));
                        bmp.Save("E:\\pout"+(index++)+".bmp");
                    }
                }


    but I get the following exception:

    "Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index", which is thrown while trying to access the Aspose.Cell.Picture.Data property.

    I am using Aspose.Cell version 4.6.0.2 with .NET 2.0. (XLS file attached with this post)

    Stack trace:

       at System.Collections.ArrayList.get_Item(Int32 index)\
       at Aspose.Cells.MsoDrawing.ᑒ.get_ఄ(Int32 ۯ)\r\n   at Aspose.Cells.Picture.get_᛭()
       at Aspose.Cells.Picture.get_Data()
       at AsposeTest.Program.Main(String[] args) in E:\\Projects\\ExcelConvCleaner\\AsposeTest\\AsposeTest\\Program.cs:line 90
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

     at System.Threading.ThreadHelper.ThreadStart()

     
  •  01-27-2009, 11:54 AM 162152 in reply to 162141

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

    Hi,

    Thanks for proving us the template file,

    We found the issue you have mentioned, we will figure it out soon.

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  01-30-2009, 10:42 AM 162691 in reply to 162152

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

    so any estimates on when this could be resolved?
     
  •  01-30-2009, 11:19 AM 162698 in reply to 162691

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

    Hi,

    Hopefully we can provide a fix in the next week.

    Thanks for being patient!


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  02-02-2009, 1:36 AM 162864 in reply to 162698

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

     
    Hi,

     
    Please try the fix attached @: http://www.aspose.com/community/forums/thread/162392.aspx  and kindly try the following codes:
     
     
    Workbook wb = new Workbook();
                      wb.Open(@"F:\test\test27.xls");
                      foreach (Worksheet ws in wb.Worksheets)
                      {
                            if (ws.Type == SheetType.Chart)
                                  continue;

                            int index = 0;
                            foreach (Picture picture in ws.Pictures)
                            {
                                  //save the image:
                                  byte[] data = picture.Data;
                                  if (data != null)
                                  {
                                        continue;
                                  }
                                  Bitmap bmp = new Bitmap(new MemoryStream(data));
                                  bmp.Save("f:\\test\\pout" + (index++) + ".bmp");
                            }
                      }
                      wb.Save(@"F:\test\ssOUT.xls");
     
     
     
    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  02-03-2009, 11:49 AM 163201 in reply to 162864

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

                                 byte[] data = picture.Data;
                                  if (data != null)
                                  {
                                        continue;
                                  }

    this is supposed to be if(data==null) right?

    and I noticed there was a Aspose.Cells.tlb file along with the assembly...does this need to be included?
     
  •  02-03-2009, 12:16 PM 163206 in reply to 163201

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

    Hi,

    Well, the .tlb file is a type library file usually used to get the type infos about Aspose.Cells APIs (class hierarchy, overloaded methods list, enumeration constants) if you want to use the component in some other languages like ASP - JavaScript, ASP -VBScript, LotusScript, PHP, Python etc. And, no, you don't need to include it with the assembly to use in .NET projects.

     

    Thank you. 


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  02-04-2009, 12:13 AM 163287 in reply to 163206

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

    Hi,

    And, yes, your understanding is correct regarding code, here is the complete sample code:

    Workbook wb = new Workbook();
                      wb.Open(@"F:\test\test.xls");
                      foreach (Worksheet ws in wb.Worksheets)
                      {
                            if (ws.Type == SheetType.Chart)
                                  continue;

                            int index = 0;
                            foreach (Picture picture in ws.Pictures)
                            {
                                  //save the image:
                                  byte[] data = picture.Data;
                                  if (data == null)
                                  {
                                        continue;
                                  }
                                  Bitmap bmp = new Bitmap(new MemoryStream(data));
                                  bmp.Save("f:\\test\\pout" + (index++) + ".bmp");
                            }
                      }
                      wb.Save(@"F:\test\ssOUT.xls");
     
     
    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  02-25-2009, 9:38 PM 167037 in reply to 162141

    Re: ArgumentOutOfRange excpetion while extracting pictures from worksheet

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


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