如何编写将电子表格及其值

如何编写将电子表格及其值

本文介绍了如何编写将电子表格及其值(而不是公式)的备份副本写入存档文件夹的脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Google应用程序脚本的新手,我一直在寻找一种备份工作表的方法.我目前正在使用.

I am new to google app scripts and I have been looking for a way to back up a sheet. I am currently using.

DriveApp.getFileById("146qFnrQoNPBcDhV6QB0bscHFp8TquXJoAC1qg‌_esy4E").makeCopy("D‌ailyArchive" + Date()+"backup");

DriveApp.getFileById("146qFnrQoNPBcDhV6QB0bscHFp8TquXJoAC1qg‌​_esy4E").makeCopy("D‌​ailyArchive" + Date() + " backup");

问题在于它需要进行每日备份,并且这些备份与原始备份一样正在更新,我只想对值进行备份,所以我有一个存档.在我的工作表中,我是从监狱花名册中导入数据. http://www.kitsapgov.com/sheriff/incustody/jailwebname.xml

The problem is its making a daily backup and those backups are updating just like the original and I just want to make a backup of the values so I have a archive. In my sheet I am importing data from a jail roster. http://www.kitsapgov.com/sheriff/incustody/jailwebname.xml

推荐答案

这对于一张纸非常简单(您可以将其调整为几张纸)

Here something quite simple for one sheet (you can adapt it for several sheets)

  var source = SpreadsheetApp.getActiveSpreadsheet();
  var data = source.getActiveSheet().getDataRange();
  var cible = SpreadsheetApp.create(source.getName()+" backup");
  cible.getActiveSheet().getRange(data.getA1Notation()).setValues(data.getValues());
  Logger.log(cible.getId());
  Logger.log(cible.getUrl());

这篇关于如何编写将电子表格及其值(而不是公式)的备份副本写入存档文件夹的脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 00:17