Files
plugins_vue/src/pages/page1/saicComponents/Appendix.vue
T
2024-09-23 15:40:22 +08:00

1587 lines
71 KiB
Vue

<template>
<div>
<a-button-group>
<a-button @click="handleCreateAppendix('CN')">添加附录</a-button>
<!-- <a-button @click="handleCreateAppendix('EN')">添加附录(English)</a-button>-->
</a-button-group>
<!-- <a-button-group>-->
<!-- <a-button @click="handleCreateAppen(0)">附录条一</a-button>-->
<!-- <a-button @click="handleCreateAppen(1)">附录条二</a-button>-->
<!-- <a-button @click="handleCreateAppen(2)">附录条三</a-button>-->
<!-- <a-button @click="handleCreateAppen(3)">附录条四</a-button>-->
<!-- <a-button @click="handleCreateAppen(4)">附录条五</a-button>-->
<!-- </a-button-group>-->
<!-- <a-button-group>-->
<!-- <a-button @click="handleCreateAppenOne(1)">附录无题条二</a-button>-->
<!-- <a-button @click="handleCreateAppenOne(2)">附录无题条三</a-button>-->
<!-- <a-button @click="handleCreateAppenOne(3)">附录无题条四</a-button>-->
<!-- <a-button @click="handleCreateAppenOne(4)">附录无题条五</a-button>-->
<!-- </a-button-group>-->
<a-button-group>
<!-- <a-button @click="handleCreateTable()">插入表格</a-button>-->
<!-- <InsertImageAppendix />-->
<!-- <a-button @click="equationClick">方程式编号</a-button>-->
</a-button-group>
<a-modal v-model="visible" title="添加附录" @ok="handleOk">
<a-form-model
id="components-form-demo-validate-other"
:model="form"
v-bind="formItemLayout"
@submit="handleSubmit"
>
<a-form-item label="附录属性">
<a-radio-group :options="plainOptions" v-model="form.attribute"/>
</a-form-item>
<a-form-item label="附录标题">
<a-input
v-model="form.title"
placeholder="请输入附录标题"
/>
</a-form-item>
</a-form-model>
</a-modal>
</div>
</template>
<script>
const plainOptions = ['规范性', '资料性'];
import InsertImageAppendix from "../components/InsertImageAppendix";
export default {
name: "Appendix",
components: {
InsertImageAppendix
},
data() {
return {
num: 1,
visible: false,
form: {},
plainOptions,
formItemLayout: {
labelCol: {span: 6},
wrapperCol: {span: 14},
},
numData: {
1: 'A',
2: 'B',
3: 'C',
4: 'D',
5: 'E',
6: 'F',
7: 'G',
8: 'H',
9: 'I',
10: 'J',
11: 'K',
12: 'L',
13: 'M',
14: 'N',
15: 'O',
16: 'P',
17: 'Q',
18: 'R',
19: 'S',
20: 'T',
21: 'U',
22: 'V',
23: 'W',
24: 'X',
25: 'Y',
26: 'Z'
}
}
},
methods: {
handleCreateAppendix() {
this.visible = true
this.form = {
title: '',
attribute: '规范性'
}
},
handleOk() {
this.handleCreateAppenClick('CN', this.form)
},
handleCreateAppenClick(lang, data) {
Asc.scope.lang = lang;
Asc.scope.num = this.num;
Asc.scope.title = data.title;
Asc.scope.attribute = data.attribute;
this.ctx.callCommand(() => {
try {
DE.controllers.Toolbar.api.put_AddPageBreak()
const oDocument = Api.GetDocument();
const allElement = oDocument.GetElementsCount()
const oTable = Api.CreateTable(1, 1);
oTable.SetWidth("percent", 100);
oTable.SetTableLayout('fixed');
oTable.SetTableBorderTop("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderBottom("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderLeft("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderRight("single", 0, 0, 255, 255, 255);
oDocument.InsertContent([oTable]);
const parentTableCell = oTable.GetRow(0).GetCell(0);
let oNumbering = null;
let oNumLvl = null;
// 查找numbering,接着上次的编号排
for (let index = 0; index < allElement; index++) {
const element = oDocument.GetElement(index)
if ("table" === element.GetClassType()) {
const text = element.GetTableDescription()
if (text == 'appendix') {
let number = element.GetCell(0, 0).GetContent().GetElement(1);
if (number) {
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
oNumbering = getNumbering;
++Asc.scope.num
}
}
}
}
}
oTable.SetTableDescription("appendix");
if (!oNumbering) {
oNumbering = oDocument.CreateNumbering("numbered");
oNumLvl = oNumbering.GetLevel(0);
} else {
console.log('---------9999999999')
oNumLvl = oNumbering.GetNumbering().GetLevel(0)
}
// DE.controllers.Toolbar.api.put_AddPageBreak()
var oNewDocumentStyle = oDocument.GetStyle("Heading 1");
const oTextPr3 = oNewDocumentStyle.GetTextPr();
oTextPr3.SetFontFamily("黑体");
const oAppendixParagraph = Api.CreateParagraph();
const sFormatString = Asc.scope.lang === "CN" ? "附 录 %1" : "Annex %1.";
oNumLvl.SetCustomType("upperLetter", sFormatString, "left");
const textPr = oNumLvl.GetTextPr();
textPr.SetFontFamily("黑体");
textPr.SetFontSize(21)
textPr.SetStyle(oNewDocumentStyle)
const ParaPr = oNumLvl.GetParaPr();
ParaPr.SetStyle(oNewDocumentStyle)
oAppendixParagraph.SetJc("center");
oAppendixParagraph.SetBold(false);
oAppendixParagraph.SetIndFirstLine(200)
oAppendixParagraph.SetStyle(oNewDocumentStyle)
oAppendixParagraph.SetSpacingAfter(30)
oAppendixParagraph.SetSpacingBefore(Asc.scope.num)
oAppendixParagraph.SetNumbering(oNumLvl);
oAppendixParagraph.AddLineBreak()
const oNormativeText1 = '(' + Asc.scope.attribute + ')'
oAppendixParagraph.AddText(oNormativeText1);
oAppendixParagraph.AddLineBreak()
oAppendixParagraph.SetPosition(-1.4)
const oNormativeText2 = Asc.scope.title
oAppendixParagraph.AddText(oNormativeText2);
// const oNormativeParagraph1 = Api.CreateParagraph();
// oNormativeParagraph1.SetJc("center");
// oNormativeParagraph1.SetSpacingBefore(31)
// oNormativeParagraph1.SetSpacingAfter(30)
// const oNormativeText1 =
// Asc.scope.lang === "CN" ? '(' + Asc.scope.attribute + ')' : "(Normative annex)";
// oNormativeParagraph1.AddText(oNormativeText1);
//
// const oNormativeParagraph2 = Api.CreateParagraph();
// oNormativeParagraph2.SetJc("center");
// const oNormativeText2 = Asc.scope.lang === "CN" ? Asc.scope.title : "XXX";
// oNormativeParagraph2.AddText(oNormativeText2);
//
oAppendixParagraph.SetFontFamily("黑体");
// oNormativeParagraph1.SetFontFamily("黑体");
// oNormativeParagraph2.SetFontFamily("黑体");
//
oAppendixParagraph.SetFontSize(21);
// oNormativeParagraph1.SetFontSize(21);
// oNormativeParagraph2.SetFontSize(21);
parentTableCell.AddElement(
1,
oAppendixParagraph
);
// parentTableCell.AddElement(
// 2,
// oNormativeParagraph1
// );
// parentTableCell.AddElement(
// 3,
// oNormativeParagraph2
// );
} catch (e) {
console.log(e);
}
});
this.visible = false
},
handleSubmit() {
this.visible = false
},
handleCreateAppen(num) {
window.Asc.scope.guid = window.Asc.plugin.info.guid
Asc.scope.num = num
Asc.scope.numData = this.numData;
this.ctx.callCommand(() => {
try {
// DE.controllers.Toolbar.api.put_ListType(2, 2)
const oDocument = Api.GetDocument()
const num = oDocument.GetAllContentControls()
const allElement = oDocument.GetElementsCount()
let numbering = null
let currentNumbering = null
const CreateParagraph = Api.CreateParagraph()
oDocument.InsertContent([CreateParagraph])
let GetPrevious = CreateParagraph.GetPrevious()
let GetPrevious1 = CreateParagraph.GetPrevious()
for (let index = 0; index < 1000000000; index++) {
let ContentControls = GetPrevious.GetParaPr().GetStyle()
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
break
} else {
GetPrevious = GetPrevious.GetPrevious()
}
}
for (let index = 0; index < 1000000000; index++) {
let ContentControls = GetPrevious1.GetParaPr().GetStyle()
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
break
} else if (GetPrevious1.GetSpacingBefore() == 267) {
const getNumbering = GetPrevious1.GetNumbering()
currentNumbering = getNumbering;
break;
} else if (GetPrevious1.GetSpacingBefore() == 124) {
const getNumbering = GetPrevious1.GetNumbering()
currentNumbering = getNumbering;
break;
} else {
GetPrevious1 = GetPrevious1.GetPrevious()
}
}
CreateParagraph.Delete()
// for (let index = 0; index < allElement; index++) {
// const element = oDocument.GetElement(index)
// if ("paragraph" === element.GetClassType()) {
// const getNumbering = element.GetNumbering()
// if (getNumbering !== null) {
// const text = element.GetSpacingBefore()
// if (GetPrevious.GetSpacingBefore() == 1) {
// if (text == 238) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 2) {
// if (text == 239) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 3) {
// if (text == 240) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 4) {
// if (text == 241) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 5) {
// if (text == 242) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 6) {
// if (text == 243) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 7) {
// if (text == 244) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 8) {
// if (text == 245) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 9) {
// if (text == 246) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 10) {
// if (text == 247) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 11) {
// if (text == 248) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 12) {
// if (text == 249) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 13) {
// if (text == 250) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 14) {
// if (text == 251) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 15) {
// if (text == 252) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 16) {
// if (text == 253) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 17) {
// if (text == 254) {
// currentNumbering = getNumbering;
// break;
// }
// }
// }
// }
// }
if (!numbering) {
if (currentNumbering) {
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.num)
} else {
let oNumbering = oDocument.CreateNumbering('numbered')
numbering = oNumbering.GetLevel(Asc.scope.num)
}
}
const oParagraph = Api.CreateParagraph()
let oNewDocumentStyle = null
if (Asc.scope.num == 0) {
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
oNewDocumentStyle = oDocument.GetStyle("Heading 2");
const oTextPr3 = oNewDocumentStyle.GetTextPr();
oTextPr3.SetFontFamily("黑体");
oParagraph.SetIndLeft(434)
oParagraph.SetSpacingAfter(267)
oParagraph.SetSpacingBefore(267)
} else if (Asc.scope.num == 1) {
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2", "left")
numbering.SetSuff("space");
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
oParagraph.SetIndLeft(434)
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
oNewDocumentStyle = oDocument.GetStyle("Heading 3");
const oTextPr3 = oNewDocumentStyle.GetTextPr();
oTextPr3.SetFontFamily("黑体");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
} else if (Asc.scope.num == 2) {
oParagraph.SetIndLeft(434)
oNewDocumentStyle = oDocument.GetStyle("Heading 4");
const oTextPr3 = oNewDocumentStyle.GetTextPr();
oTextPr3.SetFontFamily("黑体");
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2.%3", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
} else if (Asc.scope.num == 3) {
oParagraph.SetIndLeft(434)
oNewDocumentStyle = oDocument.GetStyle("Heading 5");
const oTextPr3 = oNewDocumentStyle.GetTextPr();
oTextPr3.SetFontFamily("黑体");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2.%3.%4", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
} else if (Asc.scope.num == 4) {
oParagraph.SetIndLeft(434)
oNewDocumentStyle = oDocument.GetStyle("Heading 6");
const oTextPr3 = oNewDocumentStyle.GetTextPr();
oTextPr3.SetFontFamily("黑体");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2.%3.%4.%5", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
}
oParagraph.SetNumbering(numbering)
// oParagraph.SetSpacingAfter(267)
oParagraph.SetStyle(oNewDocumentStyle);
// if (GetPrevious.GetSpacingBefore() == 1) {
// oParagraph.SetSpacingBefore(238, true)
// } else if (GetPrevious.GetSpacingBefore() == 2) {
// oParagraph.SetSpacingBefore(239, true)
// } else if (GetPrevious.GetSpacingBefore() == 3) {
// oParagraph.SetSpacingBefore(240, true)
// } else if (GetPrevious.GetSpacingBefore() == 4) {
// oParagraph.SetSpacingBefore(241, true)
// } else if (GetPrevious.GetSpacingBefore() == 5) {
// oParagraph.SetSpacingBefore(242, true)
// } else if (GetPrevious.GetSpacingBefore() == 6) {
// oParagraph.SetSpacingBefore(243, true)
// } else if (GetPrevious.GetSpacingBefore() == 7) {
// oParagraph.SetSpacingBefore(244, true)
// } else if (GetPrevious.GetSpacingBefore() == 8) {
// oParagraph.SetSpacingBefore(245, true)
// } else if (GetPrevious.GetSpacingBefore() == 9) {
// oParagraph.SetSpacingBefore(246, true)
// } else if (GetPrevious.GetSpacingBefore() == 10) {
// oParagraph.SetSpacingBefore(247, true)
// } else if (GetPrevious.GetSpacingBefore() == 11) {
// oParagraph.SetSpacingBefore(248, true)
// } else if (GetPrevious.GetSpacingBefore() == 12) {
// oParagraph.SetSpacingBefore(249, true)
// } else if (GetPrevious.GetSpacingBefore() == 13) {
// oParagraph.SetSpacingBefore(250, true)
// } else if (GetPrevious.GetSpacingBefore() == 14) {
// oParagraph.SetSpacingBefore(251, true)
// } else if (GetPrevious.GetSpacingBefore() == 15) {
// oParagraph.SetSpacingBefore(252, true)
// } else if (GetPrevious.GetSpacingBefore() == 16) {
// oParagraph.SetSpacingBefore(253, true)
// } else if (GetPrevious.GetSpacingBefore() == 17) {
// oParagraph.SetSpacingBefore(254, true)
// } else if (GetPrevious.GetSpacingBefore() == 18) {
// oParagraph.SetSpacingBefore(255, true)
// } else if (GetPrevious.GetSpacingBefore() == 19) {
// oParagraph.SetSpacingBefore(256, true)
// }
// oParagraph.SetSpacingBefore(237)
oParagraph.SetFontFamily('黑体')
oParagraph.SetFontSize(21)
oParagraph.SetColor(0, 0, 0);
oParagraph.SetBold(false);
oDocument.InsertContent([oParagraph])
} catch (error) {
console.error(error)
}
}, false)
},
handleCreateAppenOne(num) {
window.Asc.scope.guid = window.Asc.plugin.info.guid
Asc.scope.num = num
Asc.scope.numData = this.numData;
this.ctx.callCommand(() => {
try {
// DE.controllers.Toolbar.api.put_ListType(2, 2)
const oDocument = Api.GetDocument()
const num = oDocument.GetAllContentControls()
const allElement = oDocument.GetElementsCount()
let numbering = null
let currentNumbering = null
const CreateParagraph = Api.CreateParagraph()
oDocument.InsertContent([CreateParagraph])
let GetPrevious = CreateParagraph.GetPrevious()
let GetPrevious1 = CreateParagraph.GetPrevious()
for (let index = 0; index < 1000000000; index++) {
let ContentControls = GetPrevious.GetParaPr().GetStyle()
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
break
} else {
GetPrevious = GetPrevious.GetPrevious()
}
}
for (let index = 0; index < 1000000000; index++) {
let ContentControls = GetPrevious1.GetParaPr().GetStyle()
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
break
} else if (GetPrevious1.GetSpacingBefore() == 267) {
const getNumbering = GetPrevious1.GetNumbering()
currentNumbering = getNumbering;
break;
} else if (GetPrevious1.GetSpacingBefore() == 124) {
const getNumbering = GetPrevious1.GetNumbering()
currentNumbering = getNumbering;
break;
} else {
GetPrevious1 = GetPrevious1.GetPrevious()
}
}
CreateParagraph.Delete()
// for (let index = 0; index < allElement; index++) {
// const element = oDocument.GetElement(index)
// if ("paragraph" === element.GetClassType()) {
// const getNumbering = element.GetNumbering()
// if (getNumbering !== null) {
// const text = element.GetSpacingBefore()
// if (GetPrevious.GetSpacingBefore() == 1) {
// if (text == 238) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 2) {
// if (text == 239) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 3) {
// if (text == 240) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 4) {
// if (text == 241) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 5) {
// if (text == 242) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 6) {
// if (text == 243) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 7) {
// if (text == 244) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 8) {
// if (text == 245) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 9) {
// if (text == 246) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 10) {
// if (text == 247) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 11) {
// if (text == 248) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 12) {
// if (text == 249) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 13) {
// if (text == 250) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 14) {
// if (text == 251) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 15) {
// if (text == 252) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 16) {
// if (text == 253) {
// currentNumbering = getNumbering;
// break;
// }
// } else if (GetPrevious.GetSpacingBefore() == 17) {
// if (text == 254) {
// currentNumbering = getNumbering;
// break;
// }
// }
// }
// }
// }
if (!numbering) {
if (currentNumbering) {
numbering = currentNumbering.GetNumbering().GetLevel(Asc.scope.num)
} else {
let oNumbering = oDocument.CreateNumbering('numbered')
numbering = oNumbering.GetLevel(Asc.scope.num)
}
}
const oParagraph = Api.CreateParagraph()
let oNewDocumentStyle = null
if (Asc.scope.num == 0) {
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
// oParaPr.SetIndFirstLine(-110);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
oNewDocumentStyle = oDocument.GetStyle("Normal");
oParagraph.SetIndLeft(366)
oParagraph.SetSpacingAfter(267)
oParagraph.SetSpacingBefore(267)
} else if (Asc.scope.num == 1) {
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
oParagraph.SetIndLeft(434)
oNewDocumentStyle = oDocument.GetStyle("Normal");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
} else if (Asc.scope.num == 2) {
oParagraph.SetIndLeft(434)
oNewDocumentStyle = oDocument.GetStyle("Normal");
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2.%3", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
} else if (Asc.scope.num == 3) {
oParagraph.SetIndLeft(434)
oNewDocumentStyle = oDocument.GetStyle("Normal");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2.%3.%4", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
} else if (Asc.scope.num == 4) {
oParagraph.SetIndLeft(434)
oNewDocumentStyle = oDocument.GetStyle("Normal");
oParagraph.SetSpacingAfter(127)
oParagraph.SetSpacingBefore(124)
numbering.SetCustomType('decimal', Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1.%2.%3.%4.%5", "left")
numbering.SetSuff("space");
let oParaPr = numbering.GetParaPr();
oParaPr.SetIndFirstLine(-410);
let oTextPr = numbering.GetTextPr();
oTextPr.SetFontFamily("黑体");
}
oParagraph.SetNumbering(numbering)
// oParagraph.SetSpacingAfter(267)
oParagraph.SetStyle(oNewDocumentStyle);
// if (GetPrevious.GetSpacingBefore() == 1) {
// oParagraph.SetSpacingBefore(238, true)
// } else if (GetPrevious.GetSpacingBefore() == 2) {
// oParagraph.SetSpacingBefore(239, true)
// } else if (GetPrevious.GetSpacingBefore() == 3) {
// oParagraph.SetSpacingBefore(240, true)
// } else if (GetPrevious.GetSpacingBefore() == 4) {
// oParagraph.SetSpacingBefore(241, true)
// } else if (GetPrevious.GetSpacingBefore() == 5) {
// oParagraph.SetSpacingBefore(242, true)
// } else if (GetPrevious.GetSpacingBefore() == 6) {
// oParagraph.SetSpacingBefore(243, true)
// } else if (GetPrevious.GetSpacingBefore() == 7) {
// oParagraph.SetSpacingBefore(244, true)
// } else if (GetPrevious.GetSpacingBefore() == 8) {
// oParagraph.SetSpacingBefore(245, true)
// } else if (GetPrevious.GetSpacingBefore() == 9) {
// oParagraph.SetSpacingBefore(246, true)
// } else if (GetPrevious.GetSpacingBefore() == 10) {
// oParagraph.SetSpacingBefore(247, true)
// } else if (GetPrevious.GetSpacingBefore() == 11) {
// oParagraph.SetSpacingBefore(248, true)
// } else if (GetPrevious.GetSpacingBefore() == 12) {
// oParagraph.SetSpacingBefore(249, true)
// } else if (GetPrevious.GetSpacingBefore() == 13) {
// oParagraph.SetSpacingBefore(250, true)
// } else if (GetPrevious.GetSpacingBefore() == 14) {
// oParagraph.SetSpacingBefore(251, true)
// } else if (GetPrevious.GetSpacingBefore() == 15) {
// oParagraph.SetSpacingBefore(252, true)
// } else if (GetPrevious.GetSpacingBefore() == 16) {
// oParagraph.SetSpacingBefore(253, true)
// } else if (GetPrevious.GetSpacingBefore() == 17) {
// oParagraph.SetSpacingBefore(254, true)
// } else if (GetPrevious.GetSpacingBefore() == 18) {
// oParagraph.SetSpacingBefore(255, true)
// } else if (GetPrevious.GetSpacingBefore() == 19) {
// oParagraph.SetSpacingBefore(256, true)
// }
// oParagraph.SetSpacingBefore(237)
oParagraph.SetFontFamily('宋体')
oParagraph.SetFontSize(21)
oParagraph.SetColor(0, 0, 0);
oParagraph.SetBold(false);
oDocument.InsertContent([oParagraph])
} catch (error) {
console.error(error)
}
}, false)
},
handleCreateTable() {
Asc.scope.numData = this.numData;
this.ctx.callCommand(() => {
try {
const oDocument = Api.GetDocument();
const CreateParagraph = Api.CreateParagraph()
oDocument.InsertContent([CreateParagraph])
const allElement = oDocument.GetElementsCount()
let GetPrevious = CreateParagraph.GetPrevious()
for (let index = 0; index < 1000000000; index++) {
let ContentControls = GetPrevious.GetParaPr().GetStyle()
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
break
} else {
GetPrevious = GetPrevious.GetPrevious()
}
}
CreateParagraph.Delete()
const oTable = Api.CreateTable(4, 7);
oTable.SetWidth("percent", 100);
oTable.SetTableLayout('fixed');
oTable.SetTableCellMarginRight(0.2 * (1440 / 2.54));
oTable.SetTableCellMarginTop(0.2 * (1440 / 2.54));
oTable.SetTableCellMarginLeft(0.2 * (1440 / 2.54));
oTable.SetTableCellMarginBottom(0.2 * (1440 / 2.54));
oTable.SetTableBorderTop("single", 9, 0, 0, 0, 0);
oTable.SetTableBorderBottom("single", 9, 0, 0, 0, 0);
oTable.SetTableBorderLeft("single", 9, 0, 0, 0, 0);
oTable.SetTableBorderRight("single", 9, 0, 0, 0, 0);
oTable.SetTableBorderInsideV("single", 6, 0, 0, 0, 0);
oTable.SetTableBorderInsideH("single", 6, 0, 0, 0, 0);
const oRowsCount = oTable.GetRowsCount();
oDocument.InsertContent([oTable]);
for (let i = 0; i < oRowsCount; i++) {
const oCellsCount = oTable.GetRow(i).GetCellsCount();
for (let j = 0; j < oCellsCount; j++) {
const cellEle = oTable
.GetRow(i)
.GetCell(j)
.GetContent()
.GetElement(0);
cellEle.SetSpacingAfter(10)
cellEle.SetFontSize(18)
cellEle.SetColor(0, 0, 0);
// 表头
if (i === 0) {
oTable
.GetRow(i)
.GetCell(j)
.SetCellBorderTop("single", 0, 0, 255, 255, 255);
oTable
.GetRow(i)
.GetCell(j)
.SetCellBorderRight("single", 0, 0, 255, 255, 255);
oTable
.GetRow(i)
.GetCell(j)
.SetCellBorderBottom("single", 0, 0, 255, 255, 255);
oTable
.GetRow(i)
.GetCell(j)
.SetCellBorderLeft("single", 0, 0, 255, 255, 255);
// cellEle.SetFontFamily("宋体");
} else if (i === 1) {
oTable
.GetRow(i)
.GetCell(j)
.SetCellBorderTop("single", 9, 0, 0, 0, 0);
// oTable
// .GetRow(i)
// .GetCell(j)
// .SetCellBorderRight("single", 6, 0, 0, 0, 0);
oTable
.GetRow(i)
.GetCell(j)
.SetCellBorderBottom("single", 9, 0, 0, 0, 0);
// oTable
// .GetRow(i)
// .GetCell(j)
// .SetCellBorderLeft("single", 6, 0, 0, 0, 0);
// cellEle.SetFontFamily("宋体");
} else {
// cellEle.SetFontFamily("宋体");
}
cellEle.SetFontSize(18);
}
}
// const oParagraph = oDocument.Document.GetCurrentParagraph(
// undefined,
// undefined,
// { CheckDocContent: true }
// );
const newParagraph = Api.CreateParagraph();
// newParagraph.SetParagraphWx(oParagraph);
var oRow = oTable.GetRow(0);
oRow.MergeCells();
const oCell = oTable.GetRow(0).GetCell(0);
const oInlineLvlSdt = Api.CreateInlineLvlSdt();
// oInlineLvlSdt.SetAlias("smtc.table");
if (GetPrevious.GetSpacingBefore() == 1) {
oInlineLvlSdt.SetAlias("smtc.table1");
} else if (GetPrevious.GetSpacingBefore() == 2) {
oInlineLvlSdt.SetAlias("smtc.table2");
} else if (GetPrevious.GetSpacingBefore() == 3) {
oInlineLvlSdt.SetAlias("smtc.table3");
} else if (GetPrevious.GetSpacingBefore() == 4) {
oInlineLvlSdt.SetAlias("smtc.table4");
} else if (GetPrevious.GetSpacingBefore() == 5) {
oInlineLvlSdt.SetAlias("smtc.table5");
} else if (GetPrevious.GetSpacingBefore() == 6) {
oInlineLvlSdt.SetAlias("smtc.table6");
} else if (GetPrevious.GetSpacingBefore() == 7) {
oInlineLvlSdt.SetAlias("smtc.table7");
} else if (GetPrevious.GetSpacingBefore() == 8) {
oInlineLvlSdt.SetAlias("smtc.table8");
} else if (GetPrevious.GetSpacingBefore() == 9) {
oInlineLvlSdt.SetAlias("smtc.table9");
} else if (GetPrevious.GetSpacingBefore() == 10) {
oInlineLvlSdt.SetAlias("smtc.table10");
} else if (GetPrevious.GetSpacingBefore() == 11) {
oInlineLvlSdt.SetAlias("smtc.table11");
} else if (GetPrevious.GetSpacingBefore() == 12) {
oInlineLvlSdt.SetAlias("smtc.table12");
} else if (GetPrevious.GetSpacingBefore() == 13) {
oInlineLvlSdt.SetAlias("smtc.table13");
} else if (GetPrevious.GetSpacingBefore() == 14) {
oInlineLvlSdt.SetAlias("smtc.table14");
} else if (GetPrevious.GetSpacingBefore() == 15) {
oInlineLvlSdt.SetAlias("smtc.table14");
} else if (GetPrevious.GetSpacingBefore() == 16) {
oInlineLvlSdt.SetAlias("smtc.table16");
} else if (GetPrevious.GetSpacingBefore() == 17) {
oInlineLvlSdt.SetAlias("smtc.table17");
} else if (GetPrevious.GetSpacingBefore() == 18) {
oInlineLvlSdt.SetAlias("smtc.table18");
} else if (GetPrevious.GetSpacingBefore() == 19) {
oInlineLvlSdt.SetAlias("smtc.table19");
}
let oNumbering = null,
oNumLvl = null;
// 获取全部控件,找到smtc.table,从而得到编号
const AllControl = oDocument.GetAllContentControls();
for (let i = 0; i < AllControl.length; i++) {
if (GetPrevious.GetSpacingBefore() == 1) {
if (AllControl[i].GetAlias() === "smtc.table1") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 2) {
if (AllControl[i].GetAlias() === "smtc.table2") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 3) {
if (AllControl[i].GetAlias() === "smtc.table3") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 4) {
if (AllControl[i].GetAlias() === "smtc.table4") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 5) {
if (AllControl[i].GetAlias() === "smtc.table5") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 6) {
if (AllControl[i].GetAlias() === "smtc.table6") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 7) {
if (AllControl[i].GetAlias() === "smtc.table7") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 8) {
if (AllControl[i].GetAlias() === "smtc.table8") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 9) {
if (AllControl[i].GetAlias() === "smtc.table9") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 10) {
if (AllControl[i].GetAlias() === "smtc.table10") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 11) {
if (AllControl[i].GetAlias() === "smtc.table11") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 12) {
if (AllControl[i].GetAlias() === "smtc.table12") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 13) {
if (AllControl[i].GetAlias() === "smtc.table13") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 14) {
if (AllControl[i].GetAlias() === "smtc.table14") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 15) {
if (AllControl[i].GetAlias() === "smtc.table15") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 16) {
if (AllControl[i].GetAlias() === "smtc.table16") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 17) {
if (AllControl[i].GetAlias() === "smtc.table17") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 18) {
if (AllControl[i].GetAlias() === "smtc.table18") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
} else if (GetPrevious.GetSpacingBefore() == 19) {
if (AllControl[i].GetAlias() === "smtc.table19") {
const tableContent = AllControl[i]
.GetElement(0)
.GetParentTableCell()
.GetContent();
const count = tableContent.GetElementsCount();
for (let j = 0; j < count; j++) {
const ele = tableContent.GetElement(j);
if (
ele &&
ele.GetClassType() === "paragraph" &&
ele.GetNumbering() &&
ele.GetNumbering().GetLevelIndex() === 0
) {
oNumLvl = ele.GetNumbering();
break;
}
}
}
}
}
if (!oNumLvl) {
oNumbering = oDocument.CreateNumbering("numbered");
oNumLvl = oNumbering.GetLevel(0);
const sFormatString = "表" + Asc.scope.numData[GetPrevious.GetSpacingBefore()] + ".%1";
oNumLvl.SetCustomType("decimal", sFormatString, "center");
}
var textPr = oNumLvl.GetTextPr();
textPr.SetFontFamily("黑体");
textPr.SetFontSize(21)
const CNParagraph = Api.CreateParagraph();
CNParagraph.SetJc("center");
CNParagraph.AddText("企业技术标准类别及代号");
CNParagraph.SetFontSize(21);
CNParagraph.SetFontFamily("黑体");
CNParagraph.SetSpacingAfter(0)
CNParagraph.AddInlineLvlSdt(oInlineLvlSdt);
CNParagraph.SetNumbering(oNumLvl);
oCell.AddElement(1, CNParagraph);
// 表格注
const oLastRow = oTable.GetRow(oTable.GetRowsCount() - 1);
oLastRow.MergeCells();
oLastRow.SetHeight("atLeast", 540);
} catch (e) {
console.log(e);
}
}, false);
},
equationClick() {
Asc.scope.numData = this.numData;
// this.isTrue = !this.isTrue
this.ctx.callCommand(() => {
try {
const oDocument = Api.GetDocument();
const oParagraph = Api.CreateParagraph();
oDocument.InsertContent([oParagraph]);
let Previous = oParagraph.GetPrevious()
const CreateParagraph = Api.CreateParagraph()
oDocument.InsertContent([CreateParagraph])
let GetPrevious = CreateParagraph.GetPrevious()
let numIndex
for (let index = 0; index < 1000000000; index++) {
let ContentControls = GetPrevious.GetParaPr().GetStyle()
if (ContentControls && ContentControls.GetName() == 'Heading 1') {
numIndex = GetPrevious.GetSpacingBefore()
break;
} else {
GetPrevious = GetPrevious.GetPrevious()
}
}
CreateParagraph.Delete()
// Previous.Delete()
if (Previous) {
Previous.SetJc('right')
var oParagraph2 = Previous.Copy();
const oTable = Api.CreateTable(2, 1);
oTable.SetWidth("percent", 100);
oTable.SetTableLayout('fixed');
oTable.SetTableCellMarginRight(0.2 * (1440 / 2.54));
oTable.SetTableCellMarginTop(0.2 * (1440 / 2.54));
oTable.SetTableCellMarginLeft(0.2 * (1440 / 2.54));
oTable.SetTableCellMarginBottom(0.2 * (1440 / 2.54));
oTable.SetTableBorderTop("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderBottom("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderLeft("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderRight("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderInsideV("single", 0, 0, 255, 255, 255);
oTable.SetTableBorderInsideH("single", 0, 0, 255, 255, 255);
if (numIndex == 1) {
oTable.SetTableDescription("Empty table1");
} else if (numIndex == 2) {
oTable.SetTableDescription("Empty table2");
} else if (numIndex == 3) {
oTable.SetTableDescription("Empty table3");
} else if (numIndex == 4) {
oTable.SetTableDescription("Empty table4");
} else if (numIndex == 5) {
oTable.SetTableDescription("Empty table5");
} else if (numIndex == 6) {
oTable.SetTableDescription("Empty table6");
} else if (numIndex == 7) {
oTable.SetTableDescription("Empty table7");
} else if (numIndex == 8) {
oTable.SetTableDescription("Empty table8");
} else if (numIndex == 9) {
oTable.SetTableDescription("Empty table9");
} else if (numIndex == 10) {
oTable.SetTableDescription("Empty table10");
} else if (numIndex == 11) {
oTable.SetTableDescription("Empty table11");
} else if (numIndex == 12) {
oTable.SetTableDescription("Empty table12");
} else if (numIndex == 13) {
oTable.SetTableDescription("Empty table13");
} else if (numIndex == 14) {
oTable.SetTableDescription("Empty table14");
} else if (numIndex == 15) {
oTable.SetTableDescription("Empty table15");
} else if (numIndex == 16) {
oTable.SetTableDescription("Empty table16");
} else if (numIndex == 17) {
oTable.SetTableDescription("Empty table17");
} else if (numIndex == 18) {
oTable.SetTableDescription("Empty table18");
} else if (numIndex == 19) {
oTable.SetTableDescription("Empty table19");
}
oDocument.InsertContent([oTable]);
const oCell = oTable.GetRow(0).GetCell(0);
const oCell1 = oTable.GetRow(0).GetCell(1);
const oParagraph1 = Api.CreateParagraph();
const allElement = oDocument.GetElementsCount()
let numbering = null
let currentNumbering = null
for (let index = 0; index < allElement; index++) {
const element = oDocument.GetElement(index)
if ("table" === element.GetClassType()) {
const text = element.GetTableDescription()
if (numIndex == 1) {
if (text == 'Empty table1') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 2) {
if (text == 'Empty table2') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 3) {
if (text == 'Empty table3') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 4) {
if (text == 'Empty table4') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 5) {
if (text == 'Empty table5') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 6) {
if (text == 'Empty table6') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 7) {
if (text == 'Empty table7') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 8) {
if (text == 'Empty table8') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 9) {
if (text == 'Empty table9') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 10) {
if (text == 'Empty table10') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 11) {
if (text == 'Empty table11') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 12) {
if (text == 'Empty table12') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 13) {
if (text == 'Empty table13') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 14) {
if (text == 'Empty table14') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 15) {
if (text == 'Empty table15') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 16) {
if (text == 'Empty table16') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 17) {
if (text == 'Empty table17') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 18) {
if (text == 'Empty table18') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
} else if (numIndex == 19) {
if (text == 'Empty table19') {
let number = element.GetCell(0, 1).GetContent().GetElement(0);
const getNumbering = number.GetNumbering()
if (getNumbering !== null) {
currentNumbering = getNumbering;
}
}
}
}
}
if (!numbering) {
if (currentNumbering) {
numbering = currentNumbering.GetNumbering().GetLevel(0)
} else {
let oNumbering = oDocument.CreateNumbering('numbered')
numbering = oNumbering.GetLevel(0)
const sFormatString = "..................(" + Asc.scope.numData[numIndex] + ".%1)";
numbering.SetCustomType("decimal", sFormatString, "left");
}
}
const paraPr = numbering.GetParaPr()
paraPr.SetJc('right')
const textPr = numbering.GetTextPr()
textPr.SetVertAlign('baseline')
textPr.SetSmallCaps(false);
textPr.SetFontSize(21);
textPr.SetFontFamily("黑体");
oParagraph1.SetNumbering(numbering)
oParagraph2.GetParaPr().SetJc('right')
oParagraph2.AddText(' ')
oParagraph2.SetSpacingAfter(10)
oParagraph2.SetSpacingBefore(9)
oCell.AddElement(0, oParagraph2)
oCell1.AddElement(0, oParagraph1)
oCell.GetContent().GetElement(0).GetParaPr().SetJc('right')
oCell.GetContent().GetElement(0).GetParaPr().SetIndRight(800)
oCell.SetWidth("percent", 130);
oCell1.SetWidth("percent", 65);
oCell.SetVerticalAlign("center");
oCell1.SetVerticalAlign("center");
oCell.GetContent().GetElement(1).Delete()
oCell1.GetContent().GetElement(1).Delete()
}
Previous.Delete()
oParagraph.Delete()
} catch (e) {
console.log(e);
}
})
},
},
};
</script>