1金币
设计的这个ssjson ,无法复制新sheet ,麻烦帮忙看下,在附近里 用的你们提供的demo里
<template>
<div id="app">
<gc-spread-sheets-designer :styleInfo='styleInfo' :config='config' :spreadOptions='spreadOptions' @designerInitialized='designerInitialized'>
</gc-spread-sheets-designer>
</div>
</template>
<script>
import '@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css';
import '@grapecity/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css';
import * as GC from '@grapecity/spread-sheets';
import "@grapecity/spread-sheets-print";
import "@grapecity/spread-sheets-shapes";
// import "@grapecity/spread-sheets-slicers";
import '@grapecity/spread-sheets-pivot-addon';
import "@grapecity/spread-sheets-tablesheet";
// import "@grapecity/spread-sheets-io";
import '@grapecity/spread-sheets-resources-zh';
GC.Spread.Common.CultureManager.culture("zh-cn");
import '@grapecity/spread-sheets-designer-resources-cn';
import "./custom.css";
import * as ExcelIO from '@grapecity/spread-excelio';
//Apply License
//GC.Spread.Sheets.LicenseKey = 'sjs-distribution-key';
//ExcelIO.LicenseKey = 'sjs-distribution-key';
//GC.Spread.Sheets.Designer.LicenseKey = 'designer-component-distribution-key';
import { Designer } from '@grapecity/spread-sheets-designer-vue';
import ssjson from './report'
export default {
name: 'App',
data: function () {
var config = GC.Spread.Sheets.Designer.DefaultConfig;
config.commandMap = {
Welcome: {
title: "Welcome",
text: "Welcome",
iconClass: "ribbon-button-welcome",
bigButton: "true",
commandName: "Welcome",
execute: async (context, propertyName, fontItalicChecked) => {
alert("Welcome to new designer.");
},
},
};
config.ribbon[0].buttonGroups.unshift({
label: "NewDesigner",
thumbnailClass: "welcome",
commandGroup: {
children: [
{
direction: "vertical",
commands: ["Welcome"],
},
// This is custom button ----------------end-------------
],
},
});
return {
styleInfo: { height: "98vh", width: '100%' },
config: config,
spreadOptions: {
sheetCount: 2,
},
ssjsonObj: ssjson,
designer: null,
test:{"$schema":"http://json-schema.org/draft-04/schema#","properties":{"recordNo":{"dataFieldType":"text","type":"string"},"entrustNo":{"dataFieldType":"text","type":"string"},"sampleNo":{"dataFieldType":"text","type":"string"},"sampleName":{"dataFieldType":"text","type":"string"},"testingBasis":{"dataFieldType":"text","type":"string"},"judgmentBasis":{"dataFieldType":"text","type":"string"}},"type":"object"}
};
},
methods: {
designerInitialized(value) {
this.designer = value;
this.designer.setData("treeNodeFromJson", JSON.stringify(this.test));
this.designer.setData("oldTreeNodeFromJson", JSON.stringify(this.test));
const workbook = this.designer.getWorkbook();
let jsonObj = this.ssjsonObj;
workbook.fromJSON(jsonObj)
workbook.suspendPaint();
let sheet = workbook.getActiveSheet();
let rowCount = sheet.getRowCount();
var columnCount = sheet.getColumnCount();
console.log(888, rowCount)
console.log(9999, columnCount)
var fromRange = [new GC.Spread.Sheets.Range(-1, -1, -1, -1)];
var toRange = [new GC.Spread.Sheets.Range(0, 0, rowCount, columnCount)];
workbook.addSheet(1);
var newSheet = workbook.getSheet(1);
let newName = newSheet.name();
console.log(1111111, newName)
workbook.commandManager().execute(
{
cmd: "clipboardPaste",
sheetName: newName,
fromSheet: sheet,
fromRanges: fromRange,
pastedRanges: toRange,
isCutting: false,
clipboardText: "",
pasteOption: GC.Spread.Sheets.ClipboardPasteOptions.all
}
);
workbook.resumePaint();
}
}
}
</script>
<style>
</style>
|
最佳答案
查看完整内容
您好,注意到您的代码中是新建了一个Sheet2并通过clipboardPaste指令去进行整个sheet内容的复制粘贴,这边需要特别注意一下,您需要将复制区域大小和粘贴区域大小相同即:
其次,您期望的是对整个sheet进行复制粘贴,为什么不直接通过copySheet指令来进行复制粘贴呢,因为上面的指令复制只会复制内容,对于行高列宽是不会复制的
|