Hi Pooja,
Q1)How can we calculate MaxRowCount and MaxColColumn count corresponding to the data?
There is no direct method available for the required functionality but you may use toJSON method and create your function which provide the last nonempty rows and column. Please refer to the following code snippet and attached sample that demonstrates the same.
function _getLastNonEmptyRow(sheet) {
let rows = Object.keys(sheet.toJSON().data.dataTable);
//the largest Row index is available at the last of the array
return 1 + +rows[rows.length - 1];
}
function _getLastNonEmptyCol(sheet) {
let json = sheet.toJSON();
let dataTable = Object.keys(json.data.dataTable);
let nonEmptyColIndex = -1;
dataTable.forEach((row) => {
let rowArray = Object.keys(json.data.dataTable[row]);
rowArray.forEach((col) => {
nonEmptyColIndex = Math.max(nonEmptyColIndex, col);
});
});
sample:https://codesandbox.io/s/spreadjs-custom-formula-reference-forked-q1ms9?file=/src/index.js:634-1172
Q2) How can we add new row in spread js 13?
You may use addRows method for the required functionality. Please refer to the following snippet.
activesheet.addRows(rowIndex, noOfRowTobeAdded)
addRows:https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~addRows.html
Q3) How can we hide rows corresponding to some logic?
You may use setRowVisble method for the required functionality. Please refer to the following code snippet.
sheet.setRowVisible(index,false)
setRowVisible: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~setRowVisible.html
Q4) How can we show the graphic data on spread load?
You may use sheet.charts.add() method for the required functionality. Also, make sure you import the charts library before using the charts methods. Please refer to the following code snippet.
sheet.charts.add('Chart1', GC.Spread.Sheets.Charts.ChartType.columnClustered, 0, 100, 400, 300, "A1:D4");
ChartsDemo: https://www.grapecity.com/spreadjs/demos/features/charts/basic-chart/purejs
How can we export templates containing graphics/charts?
you may use excelIO for exporting the sheet. Please refer to the following code snippet and attached demo.
//import excel file to SpreadJS json
excelIo.open(excelFile, function (json) {
var workbookObj = json;
workbook.fromJSON(workbookObj);
}, function (e) {
// process error
console.log(e);
});
//export SpreadJS json to excel file
excelio.save(json, function (blob) {
//do whatever you want with blob
//such as you can save it
}, function (e) {
//process error
console.log(e);
});
importExportDemo: https://www.grapecity.com/spreadjs/demos/features/workbook/excel-import-export/purejs
How can we enable and make grouping working in Spread?
You may use out line feature for the required functionality. Please refer to the following code snippet and demo that demonstrate the same.
var sheet = spread.getActiveSheet();
sheet.rowOutlines.group(1, 10);
sheet.columnOutlines.group(1, 5);
Grouping Demo: https://www.grapecity.com/spreadjs/demos/features/worksheet/outline/basic-group/purejs
Regards
Avinash