对表格中某一单元格设置name,初始化完成时可以通过name的RefersToRange修改值。但是在el-date-picker的change事件中,通过相同的方法修改单元格的值时失败。 代码如下,mixin_handleExcelDate()在el-date-picker的change事件中调用,无法修改BAO_GAO_RI_QI_1和JIAN_CE_RI_QI_1名称所定义的单元格的值,无报错,不走catch的代码
async mixin_handleExcelCalc() {
this.mixin.wpsLoading = true
try {
await this.mixin.jssdk.ready()
const app = this.mixin.jssdk.Application
this.mixin_handleExcelDate()
} catch (error) {
this.mixin.wpsLoading = false
console.log(error)
}
},
async mixin_handleExcelDate() { // 打开excel后,需处理报告日期和检测日期,form和excel内书签值联动
const app = this.mixin.jssdk.Application
const activeSheet = await app.ActiveWorkbook.ActiveSheet
const names = await activeSheet.Names
const name1 = await names.Item('BAO_GAO_RI_QI_1')
const BAO_GAO_RI_QI_1 = await name1.RefersToRange
const name2 = await names.Item('JIAN_CE_RI_QI_1')
const JIAN_CE_RI_QI_1 = await name2.RefersToRange
if (this.form.reportDate && BAO_GAO_RI_QI_1) { // 设置文本
BAO_GAO_RI_QI_1.Value = this.form.reportDate
}
if (this.form.detectionDate && JIAN_CE_RI_QI_1) { // 设置文本
JIAN_CE_RI_QI_1.Value = this.form.detectionDate
}
},