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.