I need help when copy sheet to new Spreadsheet. I wanted to paste only values.
I am creating .pdf from a copy of sheet but the CopyTo copy also formula from sheet.
function topdf() {
var foldersave = DriveApp.getFolderById('ID');
var originalSpreadsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Print_sheet_Damir");
var radni_sheet_Damir = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Radni_sheet_Damir");
var name = originalSpreadsheet.getRange("C4").getValue();
var ID = radni_sheet_Damir.getRange("E2").getValue();
var newSpreadsheet = SpreadsheetApp.create("ID_" + ID + "_" + name);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var projectname = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Print_sheet_Damir");
sheet.copyTo((newSpreadsheet), {contentsOnly: true});
newSpreadsheet.getSheetByName('Sheet1').activate();
newSpreadsheet.deleteActiveSheet();
pdf = newSpreadsheet.getBlob();
var file = foldersave.createFile(pdf);
But the following line doesn't work for me:
sheet.copyTo((newSpreadsheet), {contentsOnly: true});