Spreadsheet
Namespace: Wisej.Web.Ext.Syncfusion2
Assembly: Wisej.Web.Ext.Syncfusion2 (4.1.0.0)
The Spreadsheet component is used to organize and analyze data in tabular format. It has a built-in calculation library that supports most commonly used formulas.
- C#
- VB.NET
public class Spreadsheet : ej2Base
Public Class Spreadsheet
Inherits ej2Base
Constructors
Spreadsheet()
Constructs a new instance of the Spreadsheet class.
Example:
The following example creates a spreadsheet that shows a list of rows in the first sheet, configured through the Options object.
var spreadsheet = new Spreadsheet();
spreadsheet.Options.showFormulaBar = true;
spreadsheet.Options.sheets = new[]
{
new { name = "Sales", ranges = new[] { new { dataSource = sales } } }
};
spreadsheet.Dock = DockStyle.Fill;
this.Controls.Add(spreadsheet);
Spreadsheet(options)
Constructs a new instance of the Spreadsheet class.
| Name | Type | Description |
|---|---|---|
| options | Object | Initial set of options. |
Example:
The following example creates a spreadsheet without the ribbon, with one sheet that contains a list of products and a wider first column.
var spreadsheet = new Spreadsheet(new
{
showRibbon = false,
sheets = new[]
{
new
{
name = "Products",
columns = new[] { new { width = 180 } },
ranges = new[]
{
new
{
dataSource = new[]
{
new { Product = "Chai", Price = 18.0, Stock = 39 },
new { Product = "Chang", Price = 19.0, Stock = 17 }
}
}
}
}
}
});
spreadsheet.Dock = DockStyle.Fill;
this.Controls.Add(spreadsheet);
Methods
Open(stream, password, sheetIndex, sheetPassword)
Opens the Excel file in the specified FileStream in the spreadsheet.
| Parameter | Type | Description |
|---|---|---|
| stream | FileStream | The FileStream with the content of the file. The name of the file is read from Name. |
| password | String | The password used to open a protected workbook. The default is an empty string, for a file without a password. |
| sheetIndex | Int32 | The index of the sheet to open. The default is 0. |
| sheetPassword | String | The password of the protected sheet. The default is an empty string, for a sheet without a password. |
The content of stream , from its current position, is encoded as a base64 data URL and passed to the open function in the browser together with the name of the file, the passwords and the index of the sheet. The stream is not closed.
The EJ2 Spreadsheet imports the files using the open service specified in the openUrl option. The supported file types are .xlsx, .xls and .csv.
Example:
The following example opens a workbook stored in the application folder, and a workbook protected by a password.
this.spreadsheet1.Options.openUrl = "/api/Spreadsheet/Open";
using (var stream = File.OpenRead(Application.MapPath("Data/Sales.xlsx")))
{
this.spreadsheet1.Open(stream);
}
using (var stream = File.OpenRead(Application.MapPath("Data/Payroll.xlsx")))
{
this.spreadsheet1.Open(stream, password: "payroll2024");
}