Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌spreedsheets&;URI.js_Javascript_Google Apps Script_Google Sheets_Uri.js - Fatal编程技术网

Javascript 谷歌spreedsheets&;URI.js

Javascript 谷歌spreedsheets&;URI.js,javascript,google-apps-script,google-sheets,uri.js,Javascript,Google Apps Script,Google Sheets,Uri.js,我想用它在我的google Speedsheet中的一个单元格中获取一个url,但不包含查询部分 原始url-->我想从该url获取 在这个站点之后,我在spreedsheet中添加了示例代码,我可以使用如下函数: function urlPath(url){ return URI(url).path() } 为了获得所需的url,我创建了另一个函数:documents here 但我得到一个错误:TypeError:undefined不是URI的有效参数 你知道我该怎么做吗

我想用它在我的google Speedsheet中的一个单元格中获取一个url,但不包含查询部分

原始url-->我想从该url获取

在这个站点之后,我在spreedsheet中添加了示例代码,我可以使用如下函数:

    function urlPath(url){
  return URI(url).path()
   }
为了获得所需的url,我创建了另一个函数:documents here

但我得到一个错误:TypeError:undefined不是URI的有效参数

你知道我该怎么做吗


谢谢

这不是URI.js问题,而是谷歌应用程序脚本问题。您需要首先将url放入函数中

var ss = SpreadsheetApp.getActiveSpreadsheet();
var url = ss.getActiveSheet().getRange(1,1).getValue();
getRange()函数有几个不同的版本,因此请明智地选择

您必须将值输入函数中,函数才能读取它

作为旁注,我建议使用该函数

Logger.log(url);

在运行函数后澄清您正在做什么。

我通过在任何单元格上使用公式(如
=url\u whitout(A1)
来获取要取消函数的url。好的,我知道当您输入
=url\u whitout(“https:yourURLhere”)
时会发生什么?问题是A1未定义,因此无法从中获取有效的URL。我知道单元格A1有一个URL,但函数正在寻找要传递给它的URL,而不是单元格名称。这就是我建议使用getValue()函数的原因。这并不是真正的问题。。。函数itsef不正确。url正确通过,我使用示例中的其他函数对其进行了测试。不知何故,似乎uri.search对uri.js不再有效
Logger.log(url);