找回密码
 立即注册

QQ登录

只需一步,快速开始

闲着

最新发帖
Wilson.Zhang
超级版主   /  发表于:6 天前
11#
您好!测试了下,可以通过<style>标签引入样式生效,如下图所示。需要您提供一个能够复现问题的完整demo,仅复现问题即可,不用携带不便公开的代码和数据。
1727334653699.png195594786.png
回复 使用道具 举报
闲着
注册会员   /  发表于:6 天前
12#
Wilson.Zhang 发表于 2024-9-26 15:11
您好!测试了下,可以通过标签引入样式生效,如下图所示。需要您提供一个能够复现问题的完整demo,仅复现问 ...
  1. <template>
  2.   <div id="custom-form">
  3.     <el-button icon="el-icon-folder-opened" size="mini" type="warning" @click="save">导出</el-button>
  4.     <el-button icon="el-icon-folder-opened" size="mini" type="warning" @click="save1">测试</el-button>
  5.     <gc-spread-sheets-designer class="sample-spreadsheets"
  6.                                :config='config'
  7.                                @designerInitialized="designerInitialized">
  8.     </gc-spread-sheets-designer>
  9.   </div>
  10. </template>

  11. <script>

  12.   import GC from "@grapecity/spread-sheets";
  13.   import '@grapecity/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css'
  14.   import '@grapecity/spread-sheets-designer-resources-cn'
  15.   import '@grapecity/spread-sheets-designer-vue'
  16.   import '@grapecity/spread-sheets/styles/gc.spread.sheets.excel2016colorful.css'
  17.   import '@grapecity/spread-sheets-io';
  18.   import '@grapecity/spread-sheets-pdf';
  19.   import '@grapecity/spread-sheets-print';
  20.   import * as ExcelIO from "@grapecity/spread-excelio";
  21.   GC.Spread.Common.CultureManager.culture("zh-cn");

  22.   export default {
  23.     name: 'App',
  24.     data: () => ({
  25.       spread: null,
  26.       sheet: null,
  27.       header: null,
  28.       config: null,
  29.       edit:false,
  30.       table: [],
  31.       zylbData: {},
  32.       projectData: {},
  33.       loading: true,
  34.       backLoading: false,
  35.     }),
  36.     methods: {
  37.       save() {
  38. // 创建ExcelIO实例
  39.         let excelIo = new GC.Spread.Excel.IO();

  40. // 导出工作簿
  41.         var serializationOption = {
  42.           includeBindingSource: true, // 将绑定源包含在将工作簿转换为 JSON 时,默认值为 false
  43.           ignoreStyle: true, // 在将工作簿转换为 JSON 时忽略样式,默认值为 false
  44.           ignoreFormula: true, // 在将工作簿转换为 JSON 时忽略公式,默认值为 false
  45.           saveAsView: true, // 在将工作簿转换为 JSON 时包含格式化结果,默认值为 false
  46.           rowHeadersAsFrozenColumns: true, // 在将工作簿转换为 JSON 时将行标题视为冻结列,默认值为 false
  47.           columnHeadersAsFrozenRows: true, // 在将工作簿转换为 JSON 时将列标题视为冻结行,默认值为 false
  48.           includeAutoMergedCells: true // 在将工作簿转换为 JSON 时包含自动合并的单元格到实际合并的单元格中
  49.         }
  50.         var json = JSON.stringify(this.spread.toJSON(serializationOption));

  51.         excelIo.save(json, function(blob) {
  52.             // 使用FileSaver保存文件
  53.             saveAs(blob, 'exportedFile.xlsx');
  54.           }, function(e) {
  55.           if (e.errorCode === 1) {
  56.             alert(e.errorMessage);
  57.           }
  58.         })
  59.       },
  60.       save1(){
  61.         var lxs = ['ZXL-PROJ','ZXL-WBSC','KTJ-WBL','FGS-WBL'];
  62.         console.log(lxs.indexOf('KTJ-WBL'))
  63.       },
  64.       designerInitialized (value) {
  65.         this.designer = value;
  66.         this.spread = this.designer.getWorkbook(); //获取表格
  67.         this.spread.suspendPaint();
  68.         this.spread.options.newTabVisible = false; //关闭新建sheet页 按钮
  69.         this.spread.options.scrollbarShowMax  = true; // 显示的滚动条是否基于表单中的完整列数和行数
  70.         this.spread.options.scrollbarMaxAlign  = true; // 滚动条是否与活动表单的最后一行和一列对齐
  71.         this.spread.options.allowUserResize= true;//是否允许用户调整列和行的大小
  72.         document.getElementsByClassName('gc-ribbon-bar')[0].style.display='none'; //隐藏上面开始(字体。。。) 等设计器的 Excel 功能

  73.         let sheet = this.spread.getSheet(0)

  74.         let option = {allowResizeRows: true, allowResizeColumns: true,};//设置可以调整行高和列宽
  75.         sheet.options.protectionOptions = option;
  76.         sheet.options.isProtected = true;//开启表单保护模式

  77.         // //spreadJs的提示信息保护框屏蔽
  78.         // this.spread.unbind(GC.Spread.Sheets.Events.InvalidOperation + ".GC_Designer_Events");
  79.         // //修改spreadJs保护框的提示信息
  80.         // sheet.bind(GC.Spread.Sheets.Events.InvalidOperation, function (e, info) {
  81.         //   alert("Message (" + info.message + ")");
  82.         // });

  83.         // 启用列宽拖拽功能

  84.         sheet.addSpan(0, 0, 2, 17);
  85.         sheet.setValue(0, 0, '单位维保类项目前置论证方案');
  86.         sheet.addSpan(2, 0, 2, 4);
  87.         sheet.setValue(2, 0, '项目分类');
  88.         sheet.addSpan(2, 4, 2, 2);
  89.         sheet.setValue(2, 4, '项目一级分类');
  90.         sheet.addSpan(2, 6, 2, 2);
  91.         sheet.addSpan(2, 8, 2, 2);
  92.         sheet.setValue(2, 8, '项目二级分类');

  93.         sheet.addSpan(8, 0, 2, 3);
  94.         sheet.setValue(8, 0, '项目预计估算成本(万元)');
  95.         sheet.addSpan(8, 3, 2, 4);
  96.         sheet.setFormula(8, 3, '=ROUND(J9+N9,0)');
  97.         sheet.addSpan(8, 7, 2, 2);
  98.         sheet.setValue(8, 7, '外部成本');
  99.         sheet.addSpan(8, 9, 2, 2);
  100.         sheet.addSpan(8, 11, 2, 2);
  101.         sheet.setValue(8, 11, '分公司内部劳务');
  102.         sheet.addSpan(8, 13, 2, 10);

  103.         //自定义添加提示信息
  104.         var cnResource = GC.Spread.Common.CultureManager.getResources("zh-cn")
  105.         cnResource.Sheets.Exp_InvalidOperationInProtect = "槽糕,出错了1!"
  106.         cnResource.Sheets.Exp_PasteChangeMergeCell = "槽糕,出错了2!"
  107.         GC.Spread.Common.CultureManager.addCultureInfo("zh-cn", null, cnResource);
  108.         var res = GC.Spread.Sheets.Designer.getResources();
  109.         res.title = "xx 设计器";
  110.         console.log(JSON.stringify(cnResource))
  111.         // sheet.options.isProtected = false;
  112.         this.spread.resumePaint();
  113.       },
  114.       handleCloseModal(){
  115.         this.edit = false
  116.       }
  117.     }
  118.   }
  119. </script>
  120. <style scoped>
  121.   .custom-form-row {
  122.     display: flex;
  123.     flex-direction: row;
  124.     margin-bottom: 8px;
  125.   }

  126.   .sample-tutorial {
  127.     position: relative;
  128.     height: 100%;
  129.     overflow: auto;
  130.   }

  131.   .sample-spreadsheets-container {
  132.     width: calc(100%);
  133.     height: 700px;
  134.     overflow: auto;
  135.     float: left;
  136.   }

  137.   .sample-spreadsheets {
  138.     width: 100%;
  139.     height: 560px;
  140.   }

  141.   .sample-loading {
  142.     display: block;
  143.     position: absolute;
  144.     background-color: #eceaf1;
  145.     z-index: 99999;
  146.     opacity: 0.8;
  147.     margin-left: 45%;
  148.     margin-top: 10%;
  149.   }

  150.   .custom-margin-fix {
  151.     margin-left: 8px;
  152.   }
  153.   /deep/.gc-sjsdesigner-dialog{
  154.        position: absolute !important;
  155.        z-index: 99999 !important;
  156.        opacity: 18 !important;
  157.        color: chartreuse !important;
  158.        border: chartreuse !important;
  159.      }
  160.   .gc-sjsdesigner-dialog{
  161.     position: absolute !important;
  162.     z-index: 99999 !important;
  163.     opacity: 18 !important;
  164.     color: chartreuse !important;
  165.     border: chartreuse !important;
  166.     background-color: chartreuse;
  167.   }
  168. </style>
复制代码
回复 使用道具 举报
Wilson.Zhang
超级版主   /  发表于:6 天前
13#

收到demo,测验后向您同步结论。
回复 使用道具 举报
Wilson.Zhang
超级版主   /  发表于:5 天前
14#
您好!您提供的代码片段中引用了您项目工程内部的资源,我们将其注释后未能复现问题。您方便提供一个能复现问题的可运行demo吗?这样能保证咱们运行的文件一致,便于分析问题。
回复 使用道具 举报
Wilson.Zhang
超级版主   /  发表于:3 天前
15#
您好!或者您尝试下通过document获取DOM元素,对DOM元素设置相应的style属性,看看能否满足需要。
回复 使用道具 举报
12
您需要登录后才可以回帖 登录 | 立即注册
返回顶部