fix: 修复 input-excel 在二维数据模式下 plainText 属性不生效问题 (#7065)

This commit is contained in:
吴多益 2023-06-09 14:55:20 +08:00 committed by GitHub
parent afada192bb
commit 30a42fdd3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -270,8 +270,25 @@ export default class ExcelControl extends React.PureComponent<
if (parseMode === 'array') {
worksheet.eachRow((row: any, rowNumber: number) => {
const values = row.values;
let values = row.values;
values.shift(); // excel 返回的值是从 1 开始的0 节点永远是 null
if (plainText) {
values = values.map((item: any) => {
if (item instanceof Object) {
if (item.hyperlink) {
if (item.hyperlink.startsWith('mailto:')) {
return item.hyperlink.substring(7);
}
return item.hyperlink;
} else if (item.result) {
return item.result;
} else if (item.richText) {
return this.richText2PlainString(item);
}
}
return item;
});
}
result.push(values);
});
return result;
@ -305,9 +322,7 @@ export default class ExcelControl extends React.PureComponent<
} else if (cell.type === ExcelValueType.Formula) {
value = cell.value.result;
} else if (cell.type === ExcelValueType.RichText) {
value = cell.value.richText
.map((item: any) => item.text)
.join('');
value = this.richText2PlainString(cell.value);
} else if (cell.type === ExcelValueType.Error) {
value = '';
}