Reputation: 1964
I'm trying to pass information from a google spreadsheet to a google doc. This is the view of the table:
The first column only shows once and when it's list of items for that category will be shown.
I managed to present this information in a table inside the doc but it's required to show it as text since the minimum height of each table row is still too much.
This information will travel as an array with two columns and I'll iterate thru it. This is what I've tried:
//servicios_numrows_Q -> number of rows for the data
//value_tabla_servicios -> variable that contains the information
for(var t = 0; t < servicios_numrows_Q - 1; t++){
if(body.appendParagraph(value_tabla_servicios[t+1][0]) == ''){ //Am I in a row that hasn't a Category Title?
"\t" + body.appendParagraph(value_tabla_servicios[t+1][1]);
}else
{
body.appendParagraph(value_tabla_servicios[t+1][0]) + "\t"
+ body.appendParagraph(value_tabla_servicios[t+1][1]);
}
}
However, adding a tab only results in each element being shown in a separate line.
Is there a way to show the first and second column in the same line? Adding spaces instead of tab?
Upvotes: 4
Views: 399
Reputation: 201378
If my understanding is correct, how about this answer?
\t
to the top of text using appendParagraph
, please use as follows.
"\t" + body.appendParagraph(value_tabla_servicios[t+1][1]);
is modified to body.appendParagraph("\t" + value_tabla_servicios[t+1][1]);
.body.appendParagraph(value_tabla_servicios[t+1][0]) + "\t" + body.appendParagraph(value_tabla_servicios[t+1][1]);
is modified to body.appendParagraph(value_tabla_servicios[t+1][0] + "\t" + value_tabla_servicios[t+1][1]);
value_tabla_servicios[t+1]
is declared as a variable, the readability of script can be increased."\t"
.When above points are reflected to your script, it becomes as follows. Please think of this as just one of several answers.
for(var t = 0; t < servicios_numrows_Q - 1; t++){
var row = value_tabla_servicios[t+1]; // Added
if (row[0] == ''){ // Modified
body.appendParagraph("\t\t" + row[1]); // Modified
} else {
body.appendParagraph(row[0] + "\t" + row[1]); // Modified
}
}
row[0]
, "\t\t\t"
of body.appendParagraph("\t\t" + row[1])
might be suitable. About this, please check your actual situation.If I misunderstood your question and this was not the direction you want, I apologize. If the error occurs, can you provide a sample Spreadsheet, output you want and your whole script? By this, I would like to confirm it. Of course, please remove your personal information.
Upvotes: 3