Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
MS Excle Load Error
posted

I got the following error while i was trying to load Excel file stream. I am using Infragistics35.WebUI.Excel.v9.2. Version=9.2.20092.2056.

 I can open the file from MS Excel.

Index was out of range. It must be non-negative and less than the size of the collection.

Parameter name: index .

When load Excel file saved as xlsx format, The Excel file loading was succed. but load  a Excel file as xls fomat was faild.

I was debug the source code. the error code is in followwing function.

// BiffRecordStream.cs

  private void CacheNextBlock( ref byte[] buffer, ref int bufferPosition )
  {
   int copyEndCount = 0;
   if ( bufferPosition < buffer.Length )
    copyEndCount = buffer.Length - bufferPosition;

   RecordBlockInfo currentBlockInfo = this.blocks[ this.currentBlock ];
   int currentBlockLength = currentBlockInfo.BlockLength;

   int blockLength;
   if ( this.positionInCurrentBlock == currentBlockLength )
    blockLength = this.blocks[ this.currentBlock + 1 ].BlockLength;
   else
    blockLength = currentBlockLength - this.positionInCurrentBlock;

   byte[] newBuffer = new byte[ copyEndCount + blockLength ];

   if ( copyEndCount != 0 )
    Buffer.BlockCopy( buffer, bufferPosition, newBuffer, 0, copyEndCount );

   this.ReadFromCurrentBlock( newBuffer, copyEndCount, blockLength );

   bufferPosition = 0;
   buffer = newBuffer;
  }

this.blocks.Count has 5, but  this.currentBlock + 1 is 5

We need to use xls format file. Can I received bug Fixed module?

my e-mail address is silspa@korea.com

I wait your answer!

  • 15979
    posted

    Hello silspa,

    I have tested your file with this load code:

    private Workbook LoadXLS()

    {

       string excelPath = Server.MapPath("~/App_Data/5707.기간통신사_영업보고서.xls");

     

       Workbook wb = new Workbook(WorkbookFormat.Excel97To2003);

     

       wb = Workbook.Load(excelPath);

     

       return wb;

    }

     

    And the issue (“Index was out of range. It must be non-negative and less than the size of the collection”) was present in build 9.2.20092.2056 when I have tried to load your file.  

    After additional testing I have found that the reported by you behavior was researched and addressed from our R&D team and it is resolved in the latest service release for your version of ASP.NET controls - v9.2 build 9.2.20092.2183.

    You can see our latest service releases in our web site - “Support > Service Releases” and download them from “My IG > My Keys and Downloads” page.

    If you cannot see/download our latest service release you may need to register your product key first. You can register your product key in “Support > Register Your Product” page.

    Test this issue with the provided build version and let me know if this behavior is still present.

    If you need further assistance with this case, feel free to contact me.