Why i can't use Workbooks.Open() ?

Hello when i do my app finish and i Build > Archive to my phone i have problem when use the Workbooks.Open() my app will stoped working.

This is my code.

     IApplication application = excelEngine.Excel;
     application.DefaultVersion = ExcelVersion.Xlsx;

     var asset = Android.App.Application.Context.Assets.Open("test.xlsx"); //this is my stream it is working don't care this.

     IWorkbook workbook = application.Workbooks.Open(fileContent); //it is not working.

I installed on Syncfusion.Xamarin.XlsIO only not Syncfusion.XlsIO.Net.Core


3 Replies 1 reply marked as answer

SK Shamini Kiruba Sobers Syncfusion Team September 30, 2020 09:39 AM UTC

Hi Dep, 

Greetings from Syncfusion. 

In Xamarin platforms, you can use Workbooks.Open() method only with stream and not with filename. Kindly refer the code snippets from the following UG links. 

Help links: 

Please let us know if it helps. 

Regards, 
Shamini 



DE dep September 30, 2020 02:25 PM UTC

Can you do something for get that i'm just need use for HttpClient but that just my sample.


SK Shamini Kiruba Sobers Syncfusion Team October 1, 2020 01:05 PM UTC

Hi Dep, 

We suggest you to add the input Excel document as Embedded resource in the project and load it into stream as shown in the below code snippet. 

Code Snippet: 

//Gets assembly 
Assembly assembly = typeof(App).GetTypeInfo().Assembly; 
 
//Gets input Excel document from an embedded resource collection 
Stream excelStream = assembly.GetManifestResourceStream("GettingStarted.Sample.xlsx"); 
 
IWorkbook workbook = application.Workbooks.Open(excelStream); 

Steps to make input Excel document an Embedded resource: 

  1. Add the input Excel document in the project.
  2. Right click on the document -> select properties -> select the Build Action as Embedded resource.

We have prepared simple sample for your reference and the same can be downloaded from the following link. 

Sample Link:  

Kindly try this and let us know if it helps. 

Regards, 
Shamini 


Marked as answer
Loader.
Up arrow icon