I have some data that spread across multiple worksheets and I want manipulate data by each sheets separately. Basically I want to load , read and run some validations agains each sheets programatically. Could you please give some documentations or samples how to load and read worksheet data individuall?
<button id="button1" (click)="loadData()">Load Data</button>
<button id="button2" (click)="readData()">Read Data</button>
<button id="button3" (click)="applyValidation()">Apply Validation</button>
loadData() {
this.spreadsheetObj.sheets[1].ranges[0].dataSource = [].concat(grossPay());
this.spreadsheetObj.sheets[2].ranges[0].dataSource = [].concat(GDPData());
}
readData() {
// Used to get a row data from the data source with updated cell value.
this.spreadsheetObj.getData("CarSalesReport!A1:B2").then(data => console.log('getData - ', data));
// Used to get a row data from the data source with updated cell value.
var rowData = this.spreadsheetObj.getRowData(0,0);
console.log('getRowData - ', rowData);
}
applyValidation() {
this.spreadsheetObj.addDataValidation({ type: 'List', operator: 'LessThan', value1: '100,200,300', ignoreBlank: false }, 'F2:F30');
this.spreadsheetObj.addDataValidation({ type: 'WholeNumber', operator: 'EqualTo', value1: '30000', ignoreBlank: false }, 'F31:F31');
this.spreadsheetObj.addInvalidHighlight('F31:F31');
}
|
Hi Janakiraman,
Thank you for the sample. However in your sample by clicking on "Load data" does not seems load the data into datasheet. Could you please
public sheet1Data: Object[] = getDefaultData();
public sheet2Data: Object[] = [];
public sheet3Data: Object[] = [];
<e-sheet name="CarSalesReport">
<e-ranges>
<e-range [dataSource]="sheet1Data"></e-range>
</e-ranges>
</e-sheet>
<e-sheet name="DataLoaded1">
<e-ranges>
<e-range [dataSource]="sheet2Data"></e-range>
</e-ranges>
</e-sheet>
<e-sheet name="DataLoaded2">
<e-ranges>
<e-range [dataSource]="sheet3Data"></e-range>
</e-ranges>
</e-sheet>
loadData() {
this.sheet1Data = orderDetails();
this.sheet2Data = grossPay();
this.sheet3Data = GDPData();
} |
Hi Janakiraman ,
Thanks you for the example. However in my use case I generate worksheets dynamically. So I don't have luxury to bind dataSource as in <e-range [dataSource]="sheet3Data"></e-range>
Could you please have a look at attached my sample code . In my example basically what I want is
onLoadMeta() {
this.spreadsheetObj.insertSheet([{
index: 1,
name: 'Inserted Sheet',
ranges: [{ dataSource: this.worksheets }],
columns: [{ width: 150 }, { width: 110 }, { width: 110 }, { width: 85 }, { width: 85 }, { width: 85 }, { width: 85 },
{ width: 85 }]
}]);
}
|
Hi Janakiraman,
Any update on this?
loadData() {
this.spreadSheetInstance.clear({ type: "Clear All", range: "A1:AA100" });
this.spreadSheetInstance.updateRange({dataSource: orderDetails(), startCell: "A1"}, this.spreadSheetInstance.activeSheetIndex + 1);
this.spreadSheetInstance.refresh();
}
|