私はスプレッドシートからデータを取り込み、関連する部品を配列に入れて新しいスプレッドシートに書き戻しています。データはGoogleフォームから送信されています。誰もがすべての質問の入力をしているわけではありませんので、ヌルではない質問のみを取っています。どのように私の配列の長さが可変になるGoogle ScriptのinsertSheetは文字列オブジェクトを受け付けていませんか?
私はそれを最も邪魔なステップに奪いました、シートを挿入する部分にはまっています、それは1の反復でうまく動作しますが、ループでそれを行うとエラーが発生します。
for (j=2; j <= 3 ; j++)// I have 23 iterations, but I stopped at 2 for now
{
var cellLocation = new String ("B" + j + ":AC" + j);
Logger.log("J is " + j + "Cell location " + cellLocation);
var workingRange = buySheet.getRange(cellLocation);
var customer = workingRange.getValues(); //this produces a range of the row
Logger.log("Range is " + workingRange.getA1Notation() + " data is " + customer[0][0]);
//At first I thought it was the range- so I broke everything out into the tiniest step
var nameCustomer = new String(customer[0][0]);
Logger.log("nameCustomer is " + nameCustomer);
//this correctly prints out the names as strings- through 23 iterations
var create = buySheet.insertSheet(nameCustomer);
//this is a sheet object with the customers name- fails after the first iteration, and creates sheets with blank names -
}
これは、私が使用しています参照です:https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#insertSheet(String)
を、私はこの1つの争点を解決するために、この後のすべてをコメントアウトしています。私はループの外側で文字列をインスタンス化しようとしました。私はログを投稿することができます。私は実際のデータを使用していますので、人々の名前をぼかす必要があります。
これは最初のラウンドで機能し、手動で文字列を入力すると機能します。