We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
腾讯文档复制 excel 表格会出现格式错误。
如针对以下表格:
复制之后的的文本为:
H1 H2\nA\nB C
将该文本复制到 excel 表格后,会呈现下面的样式:
https://docs.qq.com/sheet/DR1p2a2lqTWRRSklE?tab=BB08J2
见问题描述。
相关代码:
https://github.com/WindrunnerMax/TKScript/blob/master/packages/copy/src/modules/docqq.ts
if (selection) { const text = []; const { startColIndex, startRowIndex, endColIndex, endRowIndex } = selection; for (let i = startRowIndex; i <= endRowIndex; i++) { for (let k = startColIndex; k <= endColIndex; k++) { const cell = SpreadsheetApp.workbook.activeSheet.getCellDataAtPosition(i, k); if (!cell) continue; text.push(" ", ((_a = cell.formattedValue) == null ? void 0 : _a.value) || cell.value || ""); } i !== endRowIndex && text.push("\n"); } const str = text.join(""); return /^\s*$/.test(str) ? "" : str; }
问题代码:
text.push(" ", ((_a = cell.formattedValue) == null ? void 0 : _a.value) || cell.value || "");
修改后的代码:
text.push("\t", (((_a = cell.formattedValue) == null ? void 0 : _a.value) || cell.value || "").replace(/\n/g, '\\n'));
经过上面的修改,得到的结果为:
遗留问题:单元格内的换行被转换成了 \\n。
\\n
The text was updated successfully, but these errors were encountered:
没太看懂,你的意思是已经解决了问题吗,直接提个pr就好
Sorry, something went wrong.
另外替换这个 \n 为 \\n 没有必要吧,原本不就是带着换行
\n
No branches or pull requests
问题描述
腾讯文档复制 excel 表格会出现格式错误。
如针对以下表格:
B
复制之后的的文本为:
将该文本复制到 excel 表格后,会呈现下面的样式:
项目所属
相关链接
https://docs.qq.com/sheet/DR1p2a2lqTWRRSklE?tab=BB08J2
预期表现
见问题描述。
解决方案
相关代码:
https://github.com/WindrunnerMax/TKScript/blob/master/packages/copy/src/modules/docqq.ts
问题代码:
修改后的代码:
经过上面的修改,得到的结果为:
遗留问题:单元格内的换行被转换成了
\\n
。The text was updated successfully, but these errors were encountered: