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
60
WorkBook Load Issue - Need help
posted

Hi,

I worked in the "Importing from Excel" functionality, it is working fine with following code provided we need to set the Properties of the excel file to "Build Actions = Embedded Resource".

 string   resourceName = "ExcelWebGrid.Resources." + this.GetExcelFileName(); 

 using (Stream stream = this.GetType().Assembly.GetManifestResourceStream(resourceName)) {  

 dataWorkbook = Workbook.Load(stream);

 }.

This will work , if we have the Excel file in our current Project / Solution. But in my requirements , User will upload the Excel Document from their Local Machine. i need to read that excel file to display to the XamWebGrid, Please see the following code.

 using (Stream  stream = openDiaglog.File.OpenRead())  { 

 dataWorkbook = Workbook.Load(stream);

}

 

While executing the above code, i am getting the following error.

 

   Invalid or unrecognized file format.
   Parameter name: stream

and the stack Trace will be
   at d.a(Stream A_0, String A_1, Boolean A_2, IPackageFactory A_3)
   at d.a(Stream A_0, String A_1, IPackageFactory A_2)
   at Infragistics.Silverlight.Excel.Workbook.Load(Stream stream, IPackageFactory packageFactory, Boolean verifyExcel2007Xml)
   at Infragistics.Silverlight.Excel.Workbook.Load(Stream stream, IPackageFactory packageFactory)
   at Infragistics.Silverlight.Excel.Workbook.Load(Stream stream)
   at ExcelWebGrid.MainPage.TestExcel_Click(Object sender, RoutedEventArgs e)

My understanding on this issue is,

WorkBook.Load Method expects the "Stream" parameter. But in my code i am passing the "FileStream" as the parameter.

 

 

 

Please suggest the way to solve my issue.

Thanks, Thyagu.

 

Parents Reply Children