# 从电子表格粘贴在角落单元格为空时将不起作用

**URL:** <https://meta.discourse.org/t/pasting-from-spreadsheet-wont-work-if-corner-cell-is-empty/169443>\
**Category:** Bug\
**Created:** [2020年十一月6日 15:14 UTC](https://meta.discourse.org/t/pasting-from-spreadsheet-wont-work-if-corner-cell-is-empty/169443 "2020-11-06T15:14:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rizka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rizka/32/79717_2.png) [@rizka](https://meta.discourse.org/u/rizka)\
**Post date:** [2020年十一月6日 15:14 UTC](https://meta.discourse.org/t/pasting-from-spreadsheet-wont-work-if-corner-cell-is-empty/169443/1 "2020-11-06T15:14:08Z")

</div>

我之前似乎没有报告过这个用户体验问题，但它已经存在多年了。当你从电子表格复制数据以导入 Discourse 表格时，有时会受到影响。复现步骤如下：

1. 在电子表格中输入一些数据。
2. 将其复制并粘贴到 Discourse。
3. 正常工作：✅。

| This | works | perfectly |
| --- | --- | --- |
| What | a | lovely |
| feature | this | is. |

1. 返回电子表格。

2. 清空左上角或右下角的单元格。

3. 再次复制并粘贴到 Discourse。

4. 无法工作：❌。

今天我又遇到了这个问题：我从网页下载了一些数据到 Excel，然后尝试将其粘贴到我们的网站上。有一个简单的变通方法：在空白单元格中填入内容，复制粘贴，然后在 Discourse 端再次清空该单元格。

| | works | perfectly |
| --- | --- | --- |
| What | a | lovely |
| feature | this | is. |

尽管如此，我还是希望这个问题能得到修复，因为每次发生时都会让我困惑几秒钟！说实话，你无法让用户了解如此小众的场景，但当你第一次遇到它时，确实会打乱你的操作节奏。

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2020年十一月6日 18:32 UTC](https://meta.discourse.org/t/pasting-from-spreadsheet-wont-work-if-corner-cell-is-empty/169443/2 "2020-11-06T18:32:21Z")

</div>

这看起来确实是个有效的 bug，我认为我们下周应该把它分配给 @sam。

---

<div class="post-metadata">

**Author:** ![kris.kotlarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kris.kotlarek/32/176919_2.png) [@kris.kotlarek](https://meta.discourse.org/u/kris.kotlarek)\
**Post date:** [2020年十一月13日 03:10 UTC](https://meta.discourse.org/t/pasting-from-spreadsheet-wont-work-if-corner-cell-is-empty/169443/5 "2020-11-13T03:10:44Z")

</div>

感谢您报告该错误，问题已修复，相关改进将包含在下一个版本中。

> <https://github.com/discourse/discourse/pull/11163>
>
> If we paste spreadsheet with the missing label we receive
> \`"	this \\n1	2"\`
> 
> If… we trim whitespace at the beginning then our later calculation to determine if it is a table is incorrect (because we have 1 column in label and 2 columns in data row):
> 
> \`\`\`
> const columns = rows.map((r) =\> r.split("\\t").length);
> const isTable =
> columns.reduce((a, b) =\> a && columns\[0\] === b && b \> 1)
> \`\`\`
> 
> https://meta.discourse.org/t/pasting-from-spreadsheet-wont-work-if-corner-cell-is-empty/169443

演示：

| | a | b |
| --- | --- | --- |
| 1 | 2 | |

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2020年十一月13日 04:07 UTC](https://meta.discourse.org/t/pasting-from-spreadsheet-wont-work-if-corner-cell-is-empty/169443/6 "2020-11-13T04:07:55Z")

</div>


