1金币
参考了论坛其他乱码的解决方案,进行了字体注册,但是仍然乱码- mounted() {
- console.log('win', window)
- this.queryHistoryDate()
- this.queryDept()
- // register the specific custom font
- var fontsObj = window.fonts;
- this.registerCustomFont(fontsObj);
- // add custom font to fontManager
- this.addFontsToFontManager(fontsObj);
- },
复制代码- registerCustomFont(fontsObj) {
- var fonts = {
- normal: fontsObj["simsun.ttf"],
- };
- GC.Spread.Sheets.PDF.PDFFontsManager.registerFont("宋体", fonts);
- },
- addFontsToFontManager(fontsObj) {
- var fonts = {
- normal: fontsObj["MTCORSVA.TTF"],
- };
- GC.Spread.Sheets.PDF.PDFFontsManager.fallbackFont = function (font) {
- var fontInfoArray = font.split(" "),
- fontName = fontInfoArray[fontInfoArray.length - 1];
- if (fontName === "mtcorsva") {
- return fonts.normal;
- }
- };
- },
复制代码- async initSpread(spread) {
- this.spread = spread;//赋值
- var sheet = spread.getActiveSheet();
- // spread.options.backColor = '#eaeaea' // 表格背景色
- // spread.options.grayAreaBackColor = '#eaeaea' // 工作区背景色
- /*spread.options.newTabVisible = false // 不显添加表单
- spread.options.tabStripVisible = false // 不显示底部表名
- spread.options.showVerticalScrollbar = true // y不显示滚动条
- spread.options.showHorizontalScrollbar = true // x不显示滚动条
- spread.options.scrollbarMaxAlign = false // y滚动条可滚动*/
- sheet.suspendPaint();
- sheet.options.allowCellOverflow = true;
- await this.query()//初始化列表数据
- var colInfos = [
- {name: "deptName", displayName: "部门", size: 200},
- {name: "deptLeaders", displayName: "部门负责人", size: 200},
- {name: "year", displayName: "提成年份", size: 120},
- {name: "month", displayName: "提成月份", formatter: "0.00", size: 120},
- {name: "commissionType", displayName: "提成类型", size: 120},
- {name: "saleCommissionStr", displayName: "销售提成", size: 120},
- {name: "serviceCommissionStr", displayName: "服务提成", size: 120},
- {name: "sendStatus", displayName: "发放状态", size: 120},
- ];//表头
- sheet.setDataSource(this.tableData);
- var filter = new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(0, 0, this.tableData.length, 7));
- sheet.rowFilter(filter);
- this.filter = filter;
- sheet.defaults.rowHeight = 28;
- sheet.defaults.locked = true;
- // this.initOutlineColumnFilter(sheet);
- sheet.bindColumns(colInfos);
- // let data = jsonData, fontsObj = fonts;
- // setting printInfo
- this.setPrintInfo(spread);
- spread.resumePaint();
- },
复制代码- exportPDF() {
- this.spread.savePDF(
- function (blob) {
- saveAs(blob, '提成统计.pdf');
- },
- console.log,
- {
- title: '智多星报表',
- author: '智多星科技有限公司',
- subject: '1.0',
- keywords: '',
- creator: 'xiaojxiang'
- });
- },
复制代码
|
最佳答案
查看完整内容
可以给整片区域设置,例如
sheet.getRange(0, 0, 1, 7).font("normal normal 15px simkai")
还有一种更加常规的做法是在我们在线表格编辑器用界面去设置字体,或者是excel设置
|