To use this script in Google Drive:
- In your spreadsheet, click Tools->Script Editor.
- Paste the contents of Code.gs into the editor.
- Save.
- Select "Allow" when Google asks about permissions.
- Reload your spreadsheet.
You should now see a new file menu option, "Export".
Hi,
I have a problem related to multiple pdf generation within my script.
I can generate and register a pdf file from my sheet on my drive using the following code lines :
These lines create a pdf file from my sheet "as it is" at the moment I start my script.
Then I took this code and puted it in a loop to generate multiple pdf files for different customer using the same sheet
Between every pdf file generation my script modifies one cell ("A1")
In other cells I have formulas refering to "A1" that should update their values.
// Access the sheet from which I generate PDF FILE
var FFACGEN= document.getSheetByName("FACGEN")
// Browsing threw a list of customer
for (var i=0;i<10;i++){
// I put the number of the customer into cell A1
FFACGEN.getRange("A1").setValue(i);
// Generate and register pdf file using FFACGEN sheet
var theBlob = Document.getBlob().getAs('application/pdf').setName("MyDocument.pdf");
var folder = DriveApp.getFolderById("FolderID");
var newFile = folder.createFile(theBlob);
}
The problem is that the sheet does not update its values before each pdf file is generate.
Result is : All my pdf file are exactly the same :
On the other end, i can see that A1 has been updated on my sheet.
It just does not change the content of the pdf file
Do you know anyway to "force" googlesheet to recalculate all values on a sheet before I generate the pdf file ?
Thank you for your help.
Regards.
LeGueuxF