本帖最后由 duduodudu 于 2023-1-4 11:08 编辑
复制excel带下拉选项的空单元格,粘贴到在线编辑器中会有一个空格字符出现,复制wps中的内容,不会出现上述问题。 |
|
尝试使用CopyBlankCell_workaround.html 中的方法去解决但是浏览器不支持(失败)
尝试使用复制后替换的方式,但是失败(英文空格可以)。
for (let irow = textArea.row; irow < textArea.rowCount; irow++) {
for (let icol = textArea.col; icol < textArea.colCount; icol++) {
var cell = sheet.getCell(irow, icol);
var text = cell.text();
// console.log(irow, icol, '文本内容:', text);
if (text.length > 0) {
// 判断字符串是否为空且不能全为空格
if (text.match(/^[ ]*$/)) {
// console.log('字符串为空或全空格', irow, icol, text)
cell.text('');
}
if (text.match(/^[ ]*$/)) {
// console.log('字符串为空或全空格', irow, icol, text)
cell.text('');
}
if (text == ' ') {
cell.text('');
} else if (text == ' ') {
cell.text('');
} else if (text == ' ') {
cell.text('');
} else if (text == ' ') { //中文空格
cell.text('');
}
}
}
}
尤其是合并单元格中,空格去除不了。
需求:把空格去除。
|
|