I want to copy one sheet in the Spreadsheet file into a new Spreadsheet file.
The sheet that I want to copy contains formulas, I want to just copy the value to a new Spreadsheet file.
I have made the script like this:
function makecopyto() {
const folderId = '1Y7RmeF9sluTndSUr2KQT8wlOL9oUkLVU';
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName('Sheet1');
const newSsName = sheet.getRange('Sheet2!F1').getValue().toString();
const resource = {
title: newSsName,
mimeType: MimeType.GOOGLE_SHEETS,
parents: [{ id: folderId }]
};
const fileJson = Drive.Files.insert(resource);
const targetSs = SpreadsheetApp.openById(fileJson.id);
const targetSheet = sheet.copyTo(targetSs);
}
But the results are not appropriate.
Best Answer
If my understanding is correct, how about this modification? Please think of this answer as just one of several answers. In this modification, I used the following flow.
Modified script:
References:
If I misunderstood your question and this was not the result you want, I apologize.