Version

Creating a Workbook (Infragistics Excel Engine)

Before You Begin

The Infragistics Excel Engine enables you to save data to and load data from Microsoft® Excel®. You can create workbooks and worksheets, input data, and export the data to Excel using the library’s various classes. The Infragistics Excel Engine makes it easy to export the data in your application as an Excel spreadsheet as well as import data from Excel into your application.

What You Will Accomplish

You will create a simple workbook and save it as an Excel output stream.

Follow These Steps

  1. Create a Xamarin.Forms application project.

  1. Add a Button control and…​

    1. set the Text property to "Create a Workbook".

    2. attach an event handler to the Button control’s Clicked event.

    In XAML:

    <Button Text="Create a Workbook" Clicked="Button_Click" />
  1. Open the code-behind and add the following namespaces:

    In C#:

    using Infragistics.Documents.Excel;
  1. Add an event handler for the Button control’s Clicked event if a method stub has not been created for you.

    In C#:

    void Button_Click(object sender, EventArgs e)
    {
        //TODO: Instantiate a Workbook object.
        //TODO: Add a worksheet to the workbook
        //TODO: Add text to the first cell
        //TODO: Save the workbook.
    }
  1. Instantiate a Workbook object.

    In C#:

    Workbook workbook1 = new Workbook();
  1. Add a Worksheet object to the workbook.

    In C#:

    Worksheet worksheet1 = workbook1.Worksheets.Add("Sheet 1");
  1. Set the first WorksheetCell object’s Value property to 42.

    In C#:

    worksheet1.Rows[0].Cells[0].Value = 42;
  1. Save the workbook.

    In C#:

    workbook1.Save(outputStream);
  1. Run the project and click the button.