简体   繁体   English

Google脚本帮助:将没有源链接的数据透视表复制到新工作表

[英]Google Script help: copy pivot table without source linkage to a new sheet

any help here would be appreciated! 这里的任何帮助将不胜感激!

Currently I have a sheet "latest scorecard" that contain 3 pivot tables and the sheet gets updated weekly. 目前,我有一个工作表“最新记分卡”,其中包含3个数据透视表,并且工作表每周更新一次。

I want to write a script that will make a clone of "latest Scorecard" tab, paste only the values and format (ex. conditional formatting) and rename the tab as current date. 我想编写一个脚本来克隆“最新记分卡”选项卡,仅粘贴值和格式(例如条件格式),然后将选项卡重命名为当前日期。 The idea is when the "latest scorecard " tab get refreshed weekly, we can have a backup sheet on previous weeks data. 这个想法是,当“最新记分卡”标签每周刷新一次时,我们可以为前几周的数据准备一个备份表。

The script I get so far is able to make a clone and rename the copied sheet as current date, (BUT IT INCLUDES LINKAGE OF THE "SOURCE"). 到目前为止,我得到的脚本能够进行克隆,并将复制的工作表重命名为当前日期(但包括“源”的链接)。 Can someone advise how to edit the script in order to only paste value and format instead of the whole pivot table source linkage. 有人可以建议如何编辑脚本以便仅粘贴值和格式,而不粘贴整个数据透视表源链接。

here is my script 这是我的剧本

/*create scorecard clone*/
function cloneGoogleSheet() {

var ss = SpreadsheetApp.getActiveSpreadsheet();

var tz = ss.getSpreadsheetTimeZone();

var newDate= new Date();

var sheet = ss.getSheetByName('Latest Scorecard').copyTo(ss); 

var stringDate = Utilities.formatDate(newDate, tz, 'MM-dd-yy');

/* Make the new sheet active and rename to current date*/

ss.setActiveSheet(sheet).showSheet();

ss.renameActiveSheet(stringDate);

ss.moveActiveSheet(6);

}

Thank you so much! 非常感谢!

I have it resolved thank you. 我解决了,谢谢。 I am posting the script that works here. 我正在发布在这里有效的脚本。

function cloneGoogleSheet() {

var ss = SpreadsheetApp.getActiveSpreadsheet();
var tz = ss.getSpreadsheetTimeZone();
var date = new Date();
var sheet = ss.getSheetByName('Latest Scorecard').getDataRange();
var newsheet = ss.insertSheet('New Sheet');
var stringDate = Utilities.formatDate(date , tz, 'MM-dd-yy');

/*copy the scorecard pivot table to a newsheet and make it static without copying the pivot table source*/  
sheet.copyTo(newsheet.getRange('A1'), {contentsOnly:true}); /*copy only content over to newsheet first*/
var newsheet_id = newsheet.getDataRange().getGridId();
sheet.copyFormatToRange(newsheet_id, 1, 26, 1, 30); /*then copy the format over to newsheet to break the source link*/

/* Make the new sheet active and rename to current date*/
ss.setActiveSheet(newsheet).showSheet(); 
ss.renameActiveSheet(stringDate);
ss.moveActiveSheet(6);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自动将表格复制到不带公式的新表格中(Google表格脚本) - Automatic copy table to a new Sheet without formula (Google Sheets script) 用于创建数据透视表过滤器的 Google 表单脚本 - Google sheet script to create filter of pivot table 使用谷歌工作表脚本时,如何将电子表格的工作表复制到另一个电子表格中而不创建新的工作表副本? - How to copy spreadsheet's sheet into another spreadsheet without creating a new sheet copy when using google sheet script? Google Sheets 脚本帮助请求:将选中的行从多个工作表复制到新工作表 - Google Sheets Script Help Request: Copy check boxed rows from multiple sheets to new sheet 谷歌工作表脚本将工作表复制到带有值而不是公式的新选项卡 - Google Sheet Script to copy a a sheet to a new tab with values and not formulas 用于从源单元格中独立复制值的 Google 工作表脚本 - Google sheet script to copy a value indipendently from the source cell Google Apps脚本在新窗口中打开Goog​​le表格的副本 - Google Apps Script to Open copy of Google Sheet in new window 将源工作表中的数据与目标工作表进行比较,并使用 Google Apps 脚本将缺失的行复制到目标工作表 - Compare data in source sheet with target sheet and copy missing rows to target sheet with Google Apps Script 谷歌工作表脚本 - 在将工作表复制到新文件后,将新工作表 ID 写回单元格 - google sheet script - writing back new sheet ID to cell, after copy sheet to new file 使用 Google 脚本的数据透视表 - Pivot table with Google Script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM