我在vue中用了相同的方法,可以取到getSelections的信息,但是就是删除不了。
<template>
<div>
<button @click="deleteLeftCells">右侧单元格左移</button>
<div id="excebox" class="excebox"></div>
</div>
</template>
<script>
import Vue from "vue";
import '@grapecity/spread-sheets-resources-zh';
GC.Spread.Common.CultureManager.culture("zh-cn");
import "@grapecity/spread-sheets-vue";
import GC from "@grapecity/spread-sheets";
export default {
mounted() {
const spread = new GC.Spread.Sheets.Workbook(
document.getElementById("excebox"), {
sheetCount: 1 //sheet的页数
}
);
const sheet = spread.getActiveSheet();
sheet.setValue(1, 1, 1);
sheet.setValue(1, 2, 2);
sheet.setValue(1, 3, 3);
sheet.setSelection(1, 2, 1, 1);
this.spread = spread;
},
methods: {
deleteLeftCells() {
this.spread.commandManager().execute({
cmd: "deleteLeftCells",
sheetName: "Sheet1",
selections: this.spread.getActiveSheet().getSelections(),
});
},
},
};
</script>
|