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.
Unfortunately, activation email could not send to your email. Please try again.

Filename Null Value

Thread ID:

Created:

Updated:

Platform:

Replies:

129673 Mar 27,2017 11:22 PM Apr 7,2017 12:58 AM Xamarin.Forms 10
loading
Tags: XlsIO
c
Asked On March 27, 2017 11:22 PM

I'd like to ask how do you open and write to an existing excel file because I keep getting an error regards to the filename. 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.


Abirami Varadharajan [Syncfusion]
Replied On March 28, 2017 11:35 AM

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. 


c
Replied On March 29, 2017 02:35 PM

Hi, I tried your solution. Is there a way to write to an existing excel file without getting prompted to save every time the button is pressed?

Mathu Mohan Vijayakumar [Syncfusion]
Replied On March 30, 2017 12:00 PM

Hi Cathleen,  
   
Thank you for updating us. 
   
We have prepared the sample to write an existing Excel file without prompting and the sample can be downloaded from the following link.  
   
Regards,  
Mathu Mohan V A 
 


c
Replied On March 31, 2017 06:41 AM

Thank you so much! May I ask if there was another way to get the last used cell and write to the row below it (every time the button is clicked)?

This worked for me, but doesn't access the last used cell:

     private static int i = 2;

     {
            i++;
            sheet["A" + i.ToString()].Value2 = " " + txtFullName.Text;
            sheet["B" + i.ToString()].Value2 = " " + i.ToString();
            sheet["C" + i.ToString()].Value2 = " " + i.ToString();
            sheet["D" + i.ToString()].Value2 = " " + i.ToString();
            sheet["E" + i.ToString()].Value2 = " " + i.ToString();
     }

c
Replied On April 1, 2017 07:37 AM

Currently, the code writes to a new row every time the button is clicked but the previous row becomes empty, which is not what I want it to do.

What it does to the excel file when the button is clicked:

     name1
     phone1
 


2nd button click:



     name2
      phone2

What I'd like it to do:

      name1
     phone1
      name2
     phone2

I suspect that the button click either does not save the data or it erases the row before it, but I'm not sure how to do it.



Abirami Varadharajan [Syncfusion]
Replied On April 3, 2017 07:44 AM

Hi Cathleen, 
 
Thank you for updating us. 
 
We have prepared the sample as per your requirement. The sample can be downloaded from the following link. 
 
 
Kindly refer and let us know if your requirement is fulfilled. 
 
Regards, 
Abirami. 


c
Replied On April 3, 2017 10:05 AM

Thanks! It works for me now. Currently, the written excel file saves to ...\Appdata\Local\Packages\... , is there a way to make it go to Desktop automatically?

Mathu Mohan Vijayakumar [Syncfusion]
Replied On April 4, 2017 07:06 AM

Hi Cathleen,  
  
In UWP applications, the following folders can be accessed outside of the app storage 
  • Folders declared in manifest file (eg: KnownFolders)
  • Folders added in the FutureAccessList or MostRecentlyUsedList
  • Folders picked using FolderPicker Class.
 
We have prepared the sample using FolderPicker and FutureAccessList classes. Once the folder is selected , it will write the file without prompting. 
 
  
Kindly refer and let us know if your requirement is fulfilled.  
  
Regards,  
Mathu Mohan V A 


c
Replied On April 6, 2017 01:28 AM

Thanks for all your help!

Abirami Varadharajan [Syncfusion]
Replied On April 7, 2017 12:58 AM

Hi Cathleen, 
 
You are most welcome. 
 
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.

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.

;