Posted 5 December 2019, 12:40 am EST
Hi Jeff,
The dev team has looked at the issue and informed us that there is no good solution to optimize the performance of clearing considering the large number of cells.
However, they have suggested the following two workarounds that you could use:
- you could invoke suspendDirty method when clear command is executed, the clearing operation only costs 13s
var clearCommand = GC.Spread.Sheets.Commands.clear;
var oldExecute = clearCommand.execute;
clearCommand.execute = function (context, options) {
var sheet = context.getSheetFromName(options.sheetName);
sheet.suspendDirty();
var result = oldExecute.apply(this, arguments);
sheet.resumeDirty();
return result;
};
- You could invoke setDataSource method with a dummy small data source when clear command is executed, the clearing operation only costs 1.5s
var clearCommand = GC.Spread.Sheets.Commands.clear;
var oldExecute = clearCommand.execute;
clearCommand.execute = function (context, options) {
var sheet = context.getSheetFromName(options.sheetName);
var dummyDataSource = new GC.Spread.Sheets.Bindings.CellBindingSource({
company: {},
customer: {},
date: new Date(),
number: "00000",
receiverCustomer: {},
records: []
});
sheet.setDataSource(dummyDataSource);
var result = oldExecute.apply(this, arguments);
return result;
};
Without the above workarounds, the clearing operation costs 22s.
Further, could you please let us know about your use case that why you need to clear all the data. Also please note that clearing all the data in this way also clears the data source.
Regards
Sharad