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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do you display the excel sheet on your phone?

Thread ID:





120967 Oct 29,2015 09:44 PM UTC Oct 30,2015 08:32 AM UTC Xamarin.Forms 1
Tags: XlsIO
David Jacobo
Asked On October 29, 2015 09:44 PM UTC

I am using the code sample from http://help.syncfusion.com/xamarin/xlsio/getting-started

I have button that when I click on it, it calls method below.  Nothing happens, I know that its hitting the method because i set a breakpoint.
I am testing with Xamarin Android Player, would that be the issue?

        public void OnClicked(object sender, EventArgs e)
            //Instantiate excel engine
            ExcelEngine excelEngine = new ExcelEngine();
            //Excel application
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;

            //A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            //The new workbook will have 1 worksheet
            IWorkbook workbook = application.Workbooks.Create(1);

            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];

            sheet.Range["A1"].Text = "Hello World!";

            workbook.Version = ExcelVersion.Excel2013;

            //Saving workbook as stream
            MemoryStream stream = new MemoryStream();

            //Closing workbook

            //Disposing excel engine


Dilli Babu Nandha Gopal [Syncfusion]
Replied On October 30, 2015 08:32 AM UTC

Hi David

Thank you for contacting Syncfusion support.

In Xamarin.Forms, workbook can be saved as stream using XlsIO. This stream can be saved as an Excel file by invoking Save method of ISave which is a user-defined interface. The following code example illustrates how to save an Excel file from  a stream in Xamarin.Forms.

Code example:

ExcelEngine excelEngine = new ExcelEngine();

IApplication application = excelEngine.Excel;

application.DefaultVersion = ExcelVersion.Excel2013;

string resourcePath = "SampleBrowser.Samples.XlsIO.Template.Sample.xlsx";

Assembly assembly = typeof(App).GetTypeInfo().Assembly;

Stream fileStream = assembly.GetManifestResourceStream(resourcePath);

//Opens the workbook.

IWorkbook workbook = application.Workbooks.Open(fileStream);

MemoryStream stream = new MemoryStream();




//Save the stream into xlsx file

Xamarin.Forms.DependencyService.Get<ISave>().Save("sample.xlsx","application/msexcel", stream);

public interface ISave


Task Save(string filename, string contentType, MemoryStream stream);


class SaveAndroid: ISave


public async Task Save(string fileName, String contentType, MemoryStream stream)


string root = null;

if (Android.OS.Environment.IsExternalStorageEmulated)


root = Android.OS.Environment.ExternalStorageDirectory.ToString();



root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

Java.IO.File myDir = new Java.IO.File(root + "/Syncfusion");


Java.IO.File file = new Java.IO.File(myDir, fileName);

if (file.Exists()) file.Delete();



FileOutputStream outs = new FileOutputStream(file);





catch (Exception e)



if (file.Exists())


Android.Net.Uri path = Android.Net.Uri.FromFile(file);

string extension = Android.Webkit.MimeTypeMap.GetFileExtensionFromUrl(Android.Net.Uri.FromFile(file).ToString());

string mimeType = Android.Webkit.MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension);

Intent intent = new Intent(Intent.ActionView);

intent.SetDataAndType(path, mimeType);

Forms.Context.StartActivity(Intent.CreateChooser(intent, "Choose App"));



We will update this information in the documentation.


Dilli babu.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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