Procházet zdrojové kódy

设置单元格值

dengrui před 3 měsíci
rodič
revize
3ff238fa56
1 změnil soubory, kde provedl 12 přidání a 1 odebrání
  1. 12 1
      src/components/ExcelView/index.vue

+ 12 - 1
src/components/ExcelView/index.vue

@@ -97,6 +97,8 @@ const resetdata = JSON.parse(resData);
 const inName = ref("");
 //loading 变量
 const isMaskShow = ref(false);
+//坐标
+const positionVal = ref({ x: 0, y: 0 });
 //表格初始化默认值
 const resetOb = ref({
   container: "luckysheet", // 设定DOM容器的id
@@ -141,6 +143,9 @@ const resetOb = ref({
   data: null,
   hook: {
     cellMousedown: function (cell, position, sheetIndex) {
+      positionVal.value.x = position.c;
+      positionVal.value.y = position.r;
+      console.log(positionVal.value, "222");
       selectCellValue.value = window.luckysheet.getCellValue(
         position.c,
         position.r,
@@ -211,7 +216,12 @@ const toGetExcelBlob = () => {
     });
   });
 };
-
+//设置单元格值
+const setCellValue = (val) => {
+  setTimeout(() => {
+    luckysheet.setCellValue(positionVal.value.y, positionVal.value.x, val);
+  }, 0);
+};
 //获取此时表格数据
 const confirm = () => emits("confirm", luckysheet.getAllSheets());
 //获取此时表格数据
@@ -278,6 +288,7 @@ defineExpose({
   importExcel,
   getExcelData,
   selectCellValue,
+  setCellValue,
 });
 onMounted(() => {
   if (props.data == null) {