Skip to content

Instantly share code, notes, and snippets.

@Kasiviswanathan3876
Forked from baobao/GetCSV_part.cs
Created June 7, 2019 19:15
Show Gist options
  • Save Kasiviswanathan3876/61640d75b2267c4bf1be8f2b3bb8b271 to your computer and use it in GitHub Desktop.
Save Kasiviswanathan3876/61640d75b2267c4bf1be8f2b3bb8b271 to your computer and use it in GitHub Desktop.
var sheetId = '拾ってきたいシートIDをいれる';
var shtteName = 'シート1的なシート名'
function getData(id, sheetName)
{
return SpreadsheetApp.openById(id)
.getSheetByName(sheetName)
.getDataRange()
.getValues();
}
function doGet()
{
var data = getData(sheetId, shtteName);
var csv = '';
for(var i = 0; i < data.length; i++) {
csv += data[i].join(',') + "\r\n";
}
return ContentService.createTextOutput(csv);
}
// CSVを取得するサンプルコード
var url = "https://script.google.com/macros/s/******************/exec";
// 結果のCSV格納変数
var csv = "";
using (var request = UnityWebRequest.Get(url))
{
Debug.Log($"SEND!!! : {url}");
yield return request.SendWebRequest();
// 通信エラーチェック
if (request.isNetworkError)
{
Debug.Log(request.error);
}
else
{
if (request.responseCode == 200)
{
// UTF8文字列として取得する
csv = request.downloadHandler.text;
Debug.Log($"Load Suuccess : {csv}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment