在Google表格中导入JSON格式的数据

编程入门 行业动态 更新时间:2024-10-23 10:26:59
本文介绍了在Google表格中导入JSON格式的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在成员/朋友@Tanaike的帮助下,我们能够开发代码以从JSON列表中导入数据,但价格"中的数据会被删除.字段按如下方式导入'16 .4700000000',而我只想导入'之后的前两位数字.的"16.47".

with the help of member / friend @Tanaike we were able to develop a code to import the data from a JSON list, but the data in the "price" field is imported as follows '16 .4700000000 'and I would like to import only the first 2 digits after the' . ' getting "16.47".

您能帮我完成这项任务吗?

could you help me on this mission?

这是我正在使用的当前代码:

this is the current code I am using:

// Call the Bling API var response = UrlFetchApp.fetch("bling.br/Api/v2/produtos/json&apikey=APIKEY?imagem=S&estoque=S"); //Logger.log(response.getContentText()); // Parse the JSON reply var json = response.getContentText(); var data = JSON.parse(json); // Aquisição de dados. var values = data.retorno.produtos.map(({produto: {codigo, gtin, descricao, preco, situacao}}) => [codigo, gtin, descricao, preco, situacao]); var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("produtos"); sheet.getRange(/*sheet.getLastRow() + */ 2, 1, values.length, values[0].length).setValues(values); ```

推荐答案

这是我其中一个项目的代码段,我在其中设置了数字格式以及边框和背景.

Here is a snippet from one of my projects where I set the number format as well as borders and background.

sheet.getRange(summaryAnnRetsFirstRow, 1, summaryAnnRetsLen, 4).setValues(summaryAnnRets); sheet.getRange(summaryAnnRetsFirstRow,2, summaryAnnRetsLen, 2).setNumberFormat("$#,##0;$(#,##0)"); sheet.getRange(summaryAnnRetsFirstRow,4, summaryAnnRetsLen, 1).setNumberFormat("0.00%"); sheet.getRange(summaryAnnRetsFirstRow,1, summaryAnnRetsLen, sheet.getLastColumn()).setBorder(true, true, true, true, true, true, 'black', SpreadsheetApp.BorderStyle.SOLID_LIGHT); sheet.getRange(summaryAnnRetsFirstRow,1, summaryAnnRetsLen, sheet.getLastColumn()).setBackground("#bdd4f9");

更多推荐

在Google表格中导入JSON格式的数据

本文发布于:2023-10-12 17:18:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485360.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表格   格式   数据   Google   JSON

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!