首页 \ 问答 \ 无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)

无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)

我正在创建一个Google脚本来调查电子表格中的数据( 此处问题中的完整代码),并在调用Google脚本时收到此错误: Uncaught Error: The script completed but the returned value is not a supported return type. 谷歌脚本试图返回一个二维数组 - 如何修复该函数,以便它成功地将二维数组传递回下一个Javascript函数?

function handleFormSubmit() {
    var formObject = document.getElementById('text').value;
    google.script.run.withSuccessHandler(createTable).getSportData(formObject);
  }

 /**
 * Adds an html table
 */ 
 function createTable(tableData) {
  console.log("The tableData for createTable() is " + tableData);
  var table = document.createElement('table');
  var tableBody = document.createElement('tbody');

tableData.forEach(function(rowData) {
  var row = document.createElement('tr');

  rowData.forEach(function(cellData) {
    var cell = document.createElement('td');
    cell.appendChild(document.createTextNode(cellData));
    row.appendChild(cell);
  });

  tableBody.appendChild(row);
});

table.appendChild(tableBody);
document.body.appendChild(table);
}

I am creating a Google Script to poll data from a spreadsheet (full code in the question here) and am getting this error when the google script is called: Uncaught Error: The script completed but the returned value is not a supported return type. The google script is trying to return a 2D array - how can I fix the function so that it successfully passes the 2D array back to the next Javascript function?

function handleFormSubmit() {
    var formObject = document.getElementById('text').value;
    google.script.run.withSuccessHandler(createTable).getSportData(formObject);
  }

 /**
 * Adds an html table
 */ 
 function createTable(tableData) {
  console.log("The tableData for createTable() is " + tableData);
  var table = document.createElement('table');
  var tableBody = document.createElement('tbody');

tableData.forEach(function(rowData) {
  var row = document.createElement('tr');

  rowData.forEach(function(cellData) {
    var cell = document.createElement('td');
    cell.appendChild(document.createTextNode(cellData));
    row.appendChild(cell);
  });

  tableBody.appendChild(row);
});

table.appendChild(tableBody);
document.body.appendChild(table);
}

原文:https://stackoverflow.com/questions/40787804
更新时间:2024-05-05 15:05

最满意答案

使用LIKE

select *
from tableA ta
join tableB tb on tb.description like '%' + ta.server_name + '%'

+是SQL Server串联。 ANSI SQL有|| ,而其他人则相反。

扩展版本,在之前/之后添加空格:

select *
from tableA ta
join tableB tb on ' ' + tb.description + ' ' like '% ' + ta.server_name + ' %'

照顾Matt Gibson的测试/最好的例子。


Use LIKE:

select *
from tableA ta
join tableB tb on tb.description like '%' + ta.server_name + '%'

The + is SQL Server concatenation. ANSI SQL has ||, and others have concat instead.

Extended version, add space before/after:

select *
from tableA ta
join tableB tb on ' ' + tb.description + ' ' like '% ' + ta.server_name + ' %'

Takes care of Matt Gibson's test/greatest example too.

相关问答

更多
  • 你不能like Linq加入like使用。 事实上,你不能like Linq like使用,只有像StartsWith , EndsWith或Contains这样的传统字符串方法。 你必须做这样的事情: var query = from f in db.form from n in db.name.Where(x => f.nameField.Contains(x.firstName)) ... You can't use like in a Linq join. In fact, ...
  • @ ChaosPandion关于重新格式化的评论是一个好主意,但也许你需要一些帮助来理解什么是好的格式化。 嗯,这对每个人来说可能都不一样:-)但如果我正在编写你的查询,我会将其格式化如下: SELECT TOP (100) PERCENT a.Id, a.DateCreated, a.DateModified, a.LastUpdatedBy, a.AccomplishmentTypeId, ...
  • 试试这个: SELECT t2.[DATE] ,t1.[VENDOR] ,t1.[UPC] ,t2.[QTY] ,t2.[AMOUNT] FROM [STORESQL].[dbo].[VENDORS] t1 LEFT OUTER JOIN [STORESQL].[dbo].[REPORT] t2 ON t1.UPC=t2.UPC AND DATE='2011-11-8' WHERE VENDOR='119828' 针对DATE的where子句使您的外连接充当 ...
  • 更好地说明理论 What is SQL JOIN ? SQL JOIN is a method to retrieve data from two or more database tables. What are the different SQL JOINs ? There are a total of five JOINs. They are : 1. JOIN or INNER JOIN 2. OUTER JOIN 2.1 LEFT OUTER JOIN or LEFT JOIN ...
  • 如果没有与连接条件匹配的行,则左外连接将连接两个表并为JOIN中的第二个表返回空值。 之后,您只需在WHERE子句中指定一个过滤器,指示您只需要连接表记录为空的记录。 SELECT A.id FROM A LEFT JOIN B ON B.a_id = A.id WHERE B.a_id IS NULL A left outer join will join two tables and return nulls for the second table in the JOIN if there ...
  • 试试这种方式吧。 基本上,您将LEFT JOIN连接到由VehicleTypeCostsBreakdown和VehicleTypeCostsDepots之间的INNER JOIN形成的派生表。 只有当您满足所有条件时,INNER JOIN才会匹配。 SELECT rt.ID, rt.Name, rt.Rate, rt.Colour, vtb.ID AS 'vtbID', vtb.Value, rt.StdID FROM Rates AS rt LEFT OUTER JOIN Veh ...
  • 而不是DISTINCT ,使用GROUP BY 。 见下文: $query_result = mysqli_query($db, "SELECT C.name FROM Category AS C INNER JOIN MarketProduct AS MP ON C.Category_ID = MP.ID_Category WHERE MP.ID_Market ='$id' GROUP BY C.name"); Instead of DISTINCT, use GROUP BY. See below ...
  • 尝试 select * from table1 inner join table2 on src=concat('node/',nid) 编辑 编辑以反映OP的变化 select `nid`, MAX(`timestamp`) as `timestamp`, `title` from `node_revisions` inner join `url_alias` on `src`=concat('node/',`nid`) group by `nid` ORDER BY `timestamp` DESC ...
  • 使用LIKE : select * from tableA ta join tableB tb on tb.description like '%' + ta.server_name + '%' +是SQL Server串联。 ANSI SQL有|| ,而其他人则相反。 扩展版本,在之前/之后添加空格: select * from tableA ta join tableB tb on ' ' + tb.description + ' ' like '% ' + ta.server_name + ' %' ...
  • 选择答案: SELECT O.OptionID,O.OptionName, Count(A.OptionID) AS Total FROM Options as O LEFT JOIN ( SELECT OPTIONID,USERID FROM Answers WHERE QuestionID = 1 ) AS A ON O.OptionID = A.OptionID LEFT JOIN Users as U ON A.UserId = U.UserID GROUP BY O.O ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。