-
set the
Text
property to "Create a Workbook". -
attach an event handler to the
Button
control’sClicked
event.
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.
You will create a simple workbook and save it as an Excel output stream.
Create a Xamarin.Forms application project.
Add a Button
control and…
set the Text
property to "Create a Workbook".
attach an event handler to the Button
control’s Clicked
event.
In XAML:
<Button Text="Create a Workbook" Clicked="Button_Click" />
Open the code-behind and add the following namespaces:
In C#:
using Infragistics.Documents.Excel;
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.
}
Instantiate a Workbook object.
In C#:
Workbook workbook1 = new Workbook();
Add a Worksheet object to the workbook.
In C#:
Worksheet worksheet1 = workbook1.Worksheets.Add("Sheet 1");
Set the first WorksheetCell object’s Value property to 42.
In C#:
worksheet1.Rows[0].Cells[0].Value = 42;
Save the workbook.
In C#:
workbook1.Save(outputStream);
Run the project and click the button.