您好,采用您给出的代码之后,发现还是无法按照预期执行:
- const designer = new GC.Spread.Sheets.Designer.Designer(document.getElementById("gc-designer-container"));
- const spread = designer.getWorkbook();
- const sheet = spread.getActiveSheet();
- spread.options.scrollByPixel = true;
- spread.options.scrollbarShowMax = true;
- spread.options.scrollbarMaxAlign = true;
- spread.options.allowExtendPasteRange = true;
- function fromJSONFn () {
- try {
- let sheet = spread.getActiveSheet();
- const row = sheet.getViewportTopRow(1,1)
- const col = sheet.getViewportLeftColumn(1,1)
- //获取偏移值
- const topRowOffset = sheet.getViewportTopRowOffset();
- const leftColumnOffset = sheet.getViewportLeftColumnOffset();
- spread.suspendPaint();
- spread.suspendEvent();
- spread.fromJSON(spread.toJSON())
- // 模拟定位到fromJSON前的单元格
- spread.getActiveSheet().showCell(row,col,GC.Spread.Sheets.VerticalPosition.top, GC.Spread.Sheets.HorizontalPosition.left)
- spread.resumeEvent();
- spread.resumePaint();
- // 模拟定位到fromJSON前的单元格的偏移量,需注意要放在paint之后执行
- spread.getActiveSheet().scroll(topRowOffset,leftColumnOffset);
- } catch (err) {
- console.log(err);
- }
- }
复制代码 调用fromJSONFn();页面还是未符合跳转预期
|