IMPORTXML 更改单元格中的导入格式
我使用 IMPORTXML 公式从网站导入值。
该公式导入一列中包含 4 个单元格的列表。
第三个单元格的值是一个带点的数字,因此它被识别为文本。
我想用逗号更改点,但是当我使用 SUBSTITUTE 函数时,第一个单元格的值被转换,其他三个单元格为空。
这是基本公式:
=IMPORTXML("https://opensea.io/collection/primeapeplanetpap?tab=activity";"//div[contains(@tabindex,'-1')]")
这是带有 SUBSTITUTE 函数的公式:
=SUBSTITUTE(SUBSTITUTE(IMPORTXML("https://opensea.io/collection/primeapeplanetpap?tab=activity";"//div[contains(@tabindex,'-1')]"); "K";"");".";",")*1
如果可能的话,我希望更改第三张纸的格式仅细胞,其他保持原样。
如果有应用程序脚本的解决方案,我也很感兴趣。
预先感谢您的回答
I used the IMPORTXML formula to import values from a website.
The formula imports a list of 4 cells in a column.
The value of the 3rd cell is a number with a dot, so it is recognized as text.
I would like to change the dot by a comma but when I use the SUBSTITUTE function, the value of the first cell is converted and the three other cells are empty.
Here is the basic formula:
=IMPORTXML("https://opensea.io/collection/primeapeplanetpap?tab=activity";"//div[contains(@tabindex,'-1')]")
Here is the formula with the SUBSTITUTE function:
=SUBSTITUTE(SUBSTITUTE(IMPORTXML("https://opensea.io/collection/primeapeplanetpap?tab=activity";"//div[contains(@tabindex,'-1')]"); "K";"");".";",")*1
What I would like if possible is to change the format of the third cell only and leave the others as is.
If there is a solution with App script I'm interested too.
Thanks in advance for your answers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道如何用公式来完成。
这是在该范围的所有单元格中进行更改的简单脚本:
您可以添加自定义菜单“脚本>”清理数字'以从菜单运行该功能:
我刚刚打开您的电子表格,它显示了正确的数字,无需替换:
可能实际答案不是替换值而是更改电子表格的区域设置是否适合 xml 源的设置?
您也可以尝试将所有数字转换为文本,然后再从工作表中获取它们。它可以在
var range = ...
: 之后用一行完成,也许在
range.setValues(values)
:如果您毕竟需要数字的话。
I don't know how it could be done with formula.
Here is the simply script that makes the changes in all the cells of the range:
You can add the custom menu 'Script > Clean numbers' to run the function from the menu:
I just opened your spreadsheet and it shows me correct numbers without replacing:
Probably the actual answer is not replace the values but change regional settings of the Spreadsheet to fit setting of the xml source?
Also you can try convert all the numbers into text before you grab them from the sheet. It can be done with one line right after
var range = ...
:And perhaps at the end after
range.setValues(values)
:If you need numbers after all.