Creating a Table then Adding Two Filters and Exporting to Excel
Our sample projects and report templates can help you learn the basics of working with our products.This example demonstrates how to create table, add filters and export it to excel file. First, create new dashboard:
Next, create new table element and add columns to table
After that, add filters:
Now, create an export function using
Finally, create a button to call
In the screenshot below you can see the result of the sample code:

<script type="text/javascript">
// Creating new dashboard
var report = Stimulsoft.Report.StiReport.createNewDashboard();
var dashboard = report.pages.getByIndex(0);
...
Then, load and reg data:
...
// Load and add reg data
var dataSet = new Stimulsoft.System.Data.DataSet();
dataSet.readXmlFile("../dashboard/Demo.xml");
report.regData("Demo", "Demo", dataSet);
report.dictionary.synchronize();
...
Next, create new table element and add columns to table
...
// Create new table element
var tableElement = new Stimulsoft.Dashboard.Components.Table.StiTableElement();
tableElement.left = 100;
tableElement.top = 100;
tableElement.width = 500;
tableElement.height = 500;
tableElement.backColor = Stimulsoft.System.Drawing.Color.lightGray;
tableElement.name = "Example";
dashboard.components.add(tableElement);
// Add column to table
var productIDСolumns = new Stimulsoft.Dashboard.Components.Table.StiDimensionColumn();
productIDСolumns.expression = "Products.ProductID";
tableElement.columns.add(productIDСolumns);
var productNameСolumns = new Stimulsoft.Dashboard.Components.Table.StiDimensionColumn();
productNameСolumns.expression = "Products.ProductName";
tableElement.columns.add(productNameСolumns);
var unitPriceСolumns = new Stimulsoft.Dashboard.Components.Table.StiDimensionColumn();
unitPriceСolumns.expression = "Products.UnitPrice";
tableElement.columns.add(unitPriceСolumns);
...
After that, add filters:
...
// Add filter to table
var productIDFilter = new Stimulsoft.Data.Engine.StiDataFilterRule();
productIDFilter.condition = Stimulsoft.Data.Engine.StiDataFilterCondition.BeginningWith;
productIDFilter.path = "Products.ProductID";
productIDFilter.value = "1";
tableElement.dataFilters.add(productIDFilter);
// Add filter to table
var unitPriceFilter = new Stimulsoft.Data.Engine.StiDataFilterRule();
unitPriceFilter.condition = Stimulsoft.Data.Engine.StiDataFilterCondition.EndingWith;
unitPriceFilter.path = "Products.UnitPrice";
unitPriceFilter.value = "1";
tableElement.dataFilters.add(unitPriceFilter);
...
Now, create an export function using
exportDocumentAsync():
...
function onExportToExcelClick() {
// Export to Excel
report.exportDocumentAsync((data) => {
Stimulsoft.System.StiObject.saveAs(data, report.reportName + ".xlsx", "application/vnd.ms-excel");
}, Stimulsoft.Report.StiExportFormat.Excel2007);
}
</script>
Finally, create a button to call
onExportToExcelClick() action:
<input type="submit" value="Export to Excel" onclick="onExportToExcelClick()" />In the screenshot below you can see the result of the sample code:
