We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to open and write to an existing excel file?

Thread ID:

Created:

Updated:

Platform:

Replies:

129636 Mar 27,2017 10:49 AM UTC Mar 28,2017 03:39 PM UTC Xamarin.Forms 1
loading
Tags: XlsIO
c
Asked On March 27, 2017 10:49 AM UTC

Hi, I'm a student learning Xamarin.Forms. I'd like to ask how do you open and write to an existing excel file? I read this article (https://help.syncfusion.com/file-formats/xlsio/loading-and-saving-workbook?cs-save-lang=1&cs-lang=csharp) but I get an error.    

//Creates a new instance for ExcelEngine.     
ExcelEngine excelEngine = new ExcelEngine();           
//Loads or open an existing workbook through Open method of IWorkbooks     
IWorkbook workbook = excelEngine.Excel.Workbooks.Open(@"filename.xlsx");

The error says "Argument 1: cannot convert from 'string' to 'System.IO.Stream'".
I know I should use a dependency but I'm not sure how to do it.
And from here (https://www.syncfusion.com/forums/120967/how-do-you-display-the-excel-sheet-on-your-phone), I copied this part:  
 
string resourcePath = "GettingStarted.xlsx";
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
Stream fileStream = assembly.GetManifestResourceStream(resourcePath);
//Opens the workbook IWorkbook workbook = application.Workbooks.Open(fileStream);

But I get this error: An exception of type 'System.ArgumentNullException' occurred in Syncfusion.XlsIO.Portable.dll but was not handled in user code Additional information: Value cannot be null.

(Btw, I want to make an app that opens an existing excel file, write additional data (in different rows)to it every time the button is clicked.)

Abirami Varadharajan [Syncfusion]
Replied On March 28, 2017 03:39 PM UTC

Hi Cathleen, 
  
Thank you for contacting Syncfusion support. 
  
We have prepared the sample to open and save the file in Xamarin platform. The sample can be downloaded from the following link. 
  
  
Note: We suspect issue might be occurred as if the file is not located in the provided location or else file shouldn’t have embedded in the resource. 
  
If you still able to reproduce the issue, then kindly modify and share the issue reproducing sample which will be helpful for us to provide prompt solution at the earliest. 
  
Regards, 
Abirami. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;