本帖最后由 Dusong 于 2022-1-27 16:33 编辑
- <div class="blockcode"><blockquote> /**
- * 打印excel
- */
- handlePreviewExcel() {
- const json = this.spread.toJSON({ ignoreStyle: true });
- console.log(json.version);
- for (var pro in json.sheets) {
- var sheet = json.sheets[pro];
- if (sheet.floatingObjects) {
- for (var i = 0; i < sheet.floatingObjects.length; i++) {
- sheet.floatingObjects[i].typeName = sheet.floatingObjects[i].floatingObjectType;
- }
- }
- }
- const fileName = this.policyName;
- new excelIo.IO().save(
- json,
- function (blob: any) {
- FileSaver.saveAs(blob, fileName);
- },
- function (e: any) {
- console.error(e);
- },
- );
- }
复制代码- const img = ('data:image/png;base64,' + result.data.img).replace(/\s+/g, '');
- const img1 = new Image();
- img1.src = img;
- img1.onload = () => {
- ...
- const picture = sheet.pictures.add(
- imgName,
- img,
- x < 0 ? 0 : x.toFixed(0) - 0,
- y < 0 ? 0 : y.toFixed(0) - 0,
- imgWidth,
- imgHeight,
- );
- }
复制代码
|
|