I am a member of GrapeCity's Technical Engagement team and SpreadJS's team has implemented a dataTable function that is used to create the two-way-table: function dataTable(sheet, columnRange, rowRange, colInputCell, rowInputCell, formulaCell)
Here is the entire dataTable function:
function dataTable(sheet, columnRange, rowRange, colInputCell, rowInputCell, formulaCell) {
var colRg = GC.Spread.Sheets.CalcEngine.formulaToRange(sheet, columnRange);
var rowRg = GC.Spread.Sheets.CalcEngine.formulaToRange(sheet, rowRange);
var colCell = GC.Spread.Sheets.CalcEngine.formulaToRange(sheet, colInputCell);
var rowCell = GC.Spread.Sheets.CalcEngine.formulaToRange(sheet, rowInputCell);
var fCell = GC.Spread.Sheets.CalcEngine.formulaToRange(sheet, formulaCell);
for (var i=colRg.col; i<colRg.col + colRg.colCount; i++) {
sheet.setValue(colCell.row, colCell.col, sheet.getValue(colRg.row, i));
for (j=rowRg.row; j<rowRg.row + rowRg.rowCount; j++) {
sheet.setValue(rowCell.row, rowCell.col, sheet.getValue(j, rowRg.col));
var v = sheet.getValue(fCell.row, fCell.col);
sheet.setValue(j, i, v);
}
}
}
Here is an example of how you would create the data table using this function:
function createDataTable() {
var ss = GC.Spread.Sheets.findControl('ss');
var sheet = ss.getActiveSheet();
ss.suspendPaint();
dataTable(sheet, 'G1:K1', 'F2:F6', 'B1', 'B2', 'B4');
ss.resumePaint();
}
Note we also attached a sample showing this to your forum question on the GrapeCity website. Let us know if you have any questions!
Best,
Mackenzie
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…