Sheet file working with gid

932 views
Skip to first unread message

Samuel

unread,
Aug 3, 2018, 1:39:20 AM8/3/18
to GAM for G Suite
Hi,

I'm currently uploading to Google Sheets a csv file with the command :
gam user myu...@domain.tld update drivefile id abcdef12345 localfile test.csv newfilename "My test"

My Workbook abcdef12345 is correctly updated but the gid of the sheet changes each time

So, is it possible to always update the same sheet in the workbook ?
Otherwise how can I retrieve the sheet gid ?

Thanks

Samuel

unread,
Aug 6, 2018, 1:14:12 AM8/6/18
to GAM for G Suite
I finally found a workaround

I still upload my csv with GAM (3 different workbooks), then in a fourth workbook I use a script run at the opening

Here is my code to get the gid :

function getId(){
 
var datasets = {0:{ type:'plan', id: 'abcdef123445', cell: 1},1:{type:'bloc', id: 'ghijk6789', cell: 2},2:{ type:'matiere',id: 'lmnopq123465', cell: 3}};
 
 
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('MAIN');
   
 
for(var i=0;i<Object.keys(datasets).length;i++){
   
var gid = SpreadsheetApp.openById(datasets[i]['id']).getSheetId().toString();
   
Logger.log(datasets[i]['type']+' --> '+ datasets[i]['id']+' --> '+ gid);
   
/*var cell = sheet.getRange(datasets[i]['cell'],2);
    cell.setValue(gid);*/

   
var dataRange = sheet.getRange(datasets[i]['cell'],2,1,2);
   
var values = [[datasets[i]['id'],gid]];
    dataRange
.setValues(values);
   
}
}

+KimNilsson

unread,
Aug 6, 2018, 9:41:06 AM8/6/18
to GAM for G Suite
Cool.

Stepping back to the first post, is this really necessary?

newfilename "My test"

Do you have to set a new file name when uploading into the same file?

/Kim

Samuel

unread,
Aug 7, 2018, 1:18:53 AM8/7/18
to GAM for G Suite
Hi,

if I don't put the newfilename parameter :
- on first run the workbook name equals the csv filename
- on second run the tab name equals the csv filename

It's for having a good naming in my files

Kim Nilsson

unread,
Aug 7, 2018, 3:02:28 AM8/7/18
to Google Apps Manager
Ah, interesting.
But, doesn't that mean that your three spreadsheets end up with lots of sheets with the same name, or do you actually change the name on every upload? Like auto-set the date, or something. 

Samuel Sobrino

unread,
Aug 7, 2018, 3:27:13 AM8/7/18
to google-ap...@googlegroups.com
I only have one sheet per spreadsheet, but the gid change each time, thats why I was looking for a way to get the gid or always update the same gid

Le mar. 7 août 2018 à 09:02, Kim Nilsson <there.is.no...@gmail.com> a écrit :
Ah, interesting.
But, doesn't that mean that your three spreadsheets end up with lots of sheets with the same name, or do you actually change the name on every upload? Like auto-set the date, or something. 

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/e37CIxMI-_w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/CAGPzzFsiBSq5gu0RD90TPKs6ebGmZ7NVyOazzi8AOvjSwZXK%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages