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

Free Support Forum - aspose.com

Creating Workbbok with InputStream is not working

Hi

I am getting some exception when i try to create a workbbok from a Inputstream of HttpPostedBase class.Here i am attaching asample code.

[HttpPost]

public ActionResult ImportFiles(FormCollection form, HttpPostedFileBase rulesTemplateFileUpload,ManageRulesDto objManageRulesDto){

try

{

string statusMessage = string.Empty;

Stream templateStream = rulesTemplateFileUpload.InputStream;

Workbook objWorkbook = new Workbook(templateStream);--Here I am getting Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

return View();

}

catch (Exception ex)

{

throw new ex;

}

}

In above code am getting Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Hi,


It works fine, may be there is some issue with your code obtaining into the stream before using Aspose.Cells API to loading workbook from the input stream. By the way, could you try to set the Position of stream to “0” e.g add a line to your code e.g

[HttpPost]

public ActionResult ImportFiles(FormCollection form, HttpPostedFileBase rulesTemplateFileUpload,ManageRulesDto objManageRulesDto){

try

{

string statusMessage = string.Empty;

Stream templateStream = rulesTemplateFileUpload.InputStream;

templateStream.Position = 0;

Workbook objWorkbook = new Workbook(templateStream);–Here I am getting Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

return View();

}

catch (Exception ex)

{

throw new ex;

}

}


If you still find the issue, kindly create a runnable Sample project, zip it and post it here to show the issue. We will check it soon.


Thank you.

Hi

The above code also not working.So here am attaching my template.Please have a look on the template also

Hi,


I can notice the exception “ArgumentOutOfRangeException” using the below code with your template file.

Sample code:

FileStream stream = File.OpenRead(@“e:\test2\Sample.xls”);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Position = 0;
Workbook wb = new Workbook(stream);
//This also does not work.
//Workbook wb = new Workbook(@“e:\test2\Samplec.xls”);

I have logged a ticket with an id: CELLSNET-40365. We will soon look into it.

Thank you.

Hi,

Please download and try this fix: Aspose.Cells for .NET v 7.1.1.1

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.