Create Excel file in Xamarin

GemBox.Spreadsheet provides support for .NET Standard 2.0, a cross-platform specification of .NET APIs, which is why it can be used on non-Windows platforms like Linux and macOS, and with the help of Xamarin and Mono, on Android and iOS mobile devices.

With GemBox.Spreadsheet for .NET Standard you can process your spreadsheets (read, write, convert, and edit Excel files) from the native mobile apps.

The following example shows how you can create an Excel file in Xamarin.Forms mobile application.

Excel file generator on a native Android mobile app with Xamarin.Forms
Screenshot of Xamarin Android app that creates an Excel file
<ContentPage xmlns=""

    <StackLayout Padding="50" 
                 Spacing="20" >

        <Label Text="GemBox.Spreadsheet Example"
               Margin="0,0,0,30" />

        <TableView x:Name="table"
                   Intent="Data" >
                    <EntryCell Label="A1"
                               Text="Joe Doe" />

                    <EntryCell Label="A2"
                               Text="Fred Nurk" />

                    <EntryCell Label="A3"
                               Text="Hans Meier" />

                    <EntryCell Label="A4"
                               Text="Ivan Horvat" />

                    <EntryCell Label="A5"
                               Text="Jean Dupont" />

        <ActivityIndicator x:Name="activity" />

        <Button x:Name="button"
                Text="Create workbook"

using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Essentials;
using Xamarin.Forms;
using GemBox.Spreadsheet;

public partial class MainPage : ContentPage
    public MainPage()

    private string CreateWorkbook()
        var workbook = new ExcelFile();
        var worksheet = workbook.Worksheets.Add("Sheet1");

        foreach (var cell in table.Root[0].Cast<EntryCell>())
            worksheet.Cells[cell.Label].Value = cell.Text;

        var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Example.xlsx");


        return filePath;

    private async void Button_Clicked(object sender, EventArgs e)
        button.IsEnabled = false;
        activity.IsRunning = true;

            var filePath = await Task.Run(() => CreateWorkbook());
            await Launcher.OpenAsync(new OpenFileRequest(Path.GetFileName(filePath), new ReadOnlyFile(filePath)));
        catch (Exception ex)
            await DisplayAlert("Error", ex.Message, "Close");

        activity.IsRunning = false;
        button.IsEnabled = true;
Imports System
Imports System.Linq
Imports System.Threading.Tasks
Imports Xamarin.Essentials
Imports Xamarin.Forms
Imports GemBox.Spreadsheet

Partial Public Class MainPage
    Inherits ContentPage

    Public Sub New()
    End Sub

    Private Function CreateWorkbook() As String
        Dim workbook = New ExcelFile()
        Dim worksheet = workbook.Worksheets.Add("Sheet1")

        For Each cell In table.Root(0).Cast(Of EntryCell)()
            worksheet.Cells(cell.Label).Value = cell.Text

        Dim filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Example.xlsx")


        Return filePath
    End Function

    Private Async Sub Button_Clicked(sender As Object, e As EventArgs)
        button.IsEnabled = False
        activity.IsRunning = True

            Dim filePath = Await Task.Run(Function() CreateWorkbook())
            Await Launcher.OpenAsync(New OpenFileRequest(Path.GetFileName(filePath), New ReadOnlyFile(filePath)))
        Catch ex As Exception
            Await DisplayAlert("Error", ex.Message, "Close")
        End Try

        activity.IsRunning = False
        button.IsEnabled = True
    End Sub
End Class

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Spreadsheet yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.