相信你是好的。我正在做一個專案,我把資料從一個apk發送到一個google sheet。 事實是,我把整個資料發送到一個作業表,我還把一種轉置的資料發送到其他作業表,所有這些資料都有自定義的ID。
這里有一個例子:
在Test_Sheet。ID Region Place Staff thing1 thing2 thing3 thing4 thing5
在test2表中:
ID thing1
ID thing2
ID thing3
ID thing4
ID thing5
所有作業正常,但我的問題是,當我只有較少的專案時,ID仍然會出現在test2表中,好像所有專案都存在。
ID thing1
ID thing2
ID thing3
ID
ID
ID
下面是代碼:
function doPost(e) {
var ss = SpreadsheetApp.openById('XXXXXXXXXXXX')。
var sh = ss.getSheetByName('Test_Sheet')。
var sh2 = ss.getSheetByName('test2')
//custom ID
var scriptProperties = PropertiesService.getScriptProperties() 。
var counter = scriptProperties.getProperty('counter') || 0。
var formatDate = Utilities. formatDate(new Date(), "GMT 8", "ddMMyy") 。
var zero = (counter < 10) ? '0' : '';
var ID = "T"/span> formatDate zero counter 。
if (counter > 99) counter = 0;
scriptProperties.setProperty('counter', counter) 。
send from apk
var region = e.parameter.region。
var place = e.parameter.place。
var staff = e.parameter.staff。
var thing1= e.parameter.thing1。
var thing2= e.parameter.thing2。
var thing3= e.parameter.thing3。
var thing4= e.parameter.thing4。
var thing5= e.parameter.thing5。
Test_Sheet
sh.appendRow([ID, region, place, staff, thing1, thing2, thing3, thing4, thing4])。
檢驗2
sh2.appendRow([ID, thing1])。
sh2.appendRow([id, thing2])。
sh2.appendRow([id, thing3])。
sh2.appendRow([ID, thing4])。
sh2.appendRow([ID, thing5])。
}
uj5u.com熱心網友回復:
如果問題是新的行被創建,即使這些記錄的ID不存在,那么在寫到作業表之前,首先要確保ID確實存在。因此,在你的代碼中,你應該這樣做:
if( thing1 ) sh2.appendRow( [ID, thing1])
if( thing2 ) sh2.appendRow([ID, thing2] )
/ ... 等等。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/330542.html
標籤:
