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. Image for the cookie policy date

Filename Null Value

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.


10 Replies

AV Abirami Varadharajan Syncfusion Team March 28, 2017 03:35 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. 



C c March 29, 2017 06:35 PM UTC

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?


MM Mathu Mohan Vijayakumar Syncfusion Team March 30, 2017 04:00 PM UTC

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 c March 31, 2017 10:41 AM UTC

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 c April 1, 2017 11:37 AM UTC

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.




AV Abirami Varadharajan Syncfusion Team April 3, 2017 11:44 AM UTC

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 c April 3, 2017 02:05 PM UTC

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?


MM Mathu Mohan Vijayakumar Syncfusion Team April 4, 2017 11:06 AM UTC

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 c April 6, 2017 05:28 AM UTC

Thanks for all your help!


AV Abirami Varadharajan Syncfusion Team April 7, 2017 04:58 AM UTC

Hi Cathleen, 
 
You are most welcome. 
 
Regards, 
Abirami. 


Loader.
Up arrow icon