Google电子表格-对待"Ctrl + V"为"Ctrl + Shift + V";
是否有一种方法可以为电子表格定义将 Ctrl + V (常规粘贴)视为 Ctrl + Shift + V (仅粘贴值)?不仅对我自己,而且对任何可以编辑的用户.
Is there a way to define for a spreadsheet that Ctrl + V (regular paste) will be treated as Ctrl + Shift + V (paste values only)? Not only for myself, but for any user that can edit.
原因:所涉及的电子表格中包含数据验证,格式设置和条件格式设置.用户在此电子表格中大量使用 Ctrl + V ,因此这些设置会不断被篡改
Reason: The spreadsheet in question is filled with data validation, formatting and conditional formatting settings. Users use Ctrl + V alot in this spreadsheet, so these settings are constantly being tampered with
我很高兴地宣布,我已经实现了以下尝试达到的目标:
I am happy to update that I have achieved what I tried to achieve as follows:
- 创建模板电子表格的副本,以仅用作设计设置模板.
- 将相关模板表从设计设置模板Ss复制到目标电子表格中(同时保持隐藏状态).使用 Sheet类完成. >
- 从模板工作表到目标工作表复制格式,条件格式设置和数据验证.使用 copyTo类别Range 完成href ="https://developers.google.com/apps-script/reference/spreadsheet/range#copytodestination,-copypastetype,-transplace" a>.
- 从目标电子表格中删除临时(隐藏)工作表.
- Create a copy of the template spreadsheet, to serve solely as a design setting template.
- Copy the relevant template sheet from the design setting template Ss into the destination spreadsheet (while keeping it hidden). This is acomplished using copyTo of class Sheet.
- Copy format, conditional formatting and data validation from template sheet to destination sheet. This is acomplished using copyTo of class Range.
- Deleting the tempalte (hidden) sheet from the destination spreadsheet.
注意:我将此功能包含在库中,因为它可以在数百个电子表格副本中使用.
Note: I included this function inside a library, as this should work in hundreds of spreadsheet copies.
**
**:
function restoreRangeSettings(e) {
// retrieves data validation, conditional formatting and formatting settings from template
var editedSs = e.source;
var editedRange = editedSs.getActiveRange();
var editedSh = editedRange.getSheet().getName();
var templateSs = SpreadsheetApp.openById('10zVclYTCEOEwskUID4vxSPxKR_tb3RaR76eG7TfxLUE');
var templateSh = templateSs.getSheetByName(editedSh);
var copiedSh = templateSh.copyTo(editedSs).hideSheet();
var templateRange = editedSs.getSheetByName(copiedSh.getName()).getRange(editedRange.getA1Notation());
templateRange.copyTo(editedRange, SpreadsheetApp.CopyPasteType.PASTE_FORMAT, false);
templateRange.copyTo(editedRange, SpreadsheetApp.CopyPasteType.PASTE_CONDITIONAL_FORMATTING, false);
templateRange.copyTo(editedRange, SpreadsheetApp.CopyPasteType.PASTE_DATA_VALIDATION, false);
editedSs.deleteSheet(copiedSh);
}
我严重依赖提供的答案这里.
I relied heavily on the answer provided here.
ziganotschka ,谢谢您的帮助!