早上好。
再次,我必须寻求您的帮助。
我正在编写的脚本将执行以下操作:
我设法做的事情有一些缺点,例如:
但是让我最担心的是照片没有被复制。
<?xml version="1.0" encoding="UTF-8"?>
-
<entry
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="http://ttpl001.truspeq.com:8000/sap/opu/odata/SAP/ZRECRUITMENT_TRACKER_APP_SRV/"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns="http://www.w3.org/2005/Atom">
<id>http://ttpl001.truspeq.com:8000/sap/opu/odata/SAP/ZRECRUITMENT_TRACKER_APP_SRV/ZRECRUITMENT_CANDIDATESet(RegNo=1,ProId=1)</id>
<title type="text">ZRECRUITMENT_CANDIDATESet(RegNo=1,ProId=1)</title>
<updated>2018-07-19T20:09:00Z</updated>
<category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="ZRECRUITMENT_TRACKER_APP_SRV.ZRECRUITMENT_CANDIDATE"/>
<link title="ZRECRUITMENT_CANDIDATE" href="ZRECRUITMENT_CANDIDATESet(RegNo=1,ProId=1)" rel="self"/>
<link title="TOSALESDATA" type="application/atom+xml;type=entry" href="ZRECRUITMENT_CANDIDATESet(RegNo=1,ProId=1)/TOSALESDATA" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TOSALESDATA"/>-
<content type="application/xml">-
<m:properties>
<d:RegNo>1</d:RegNo>
<d:ProId>1</d:ProId>
<d:NameOfCan>ROCKY</d:NameOfCan>
<d:Exp>4 YEAR</d:Exp>
<d:CurrentCtc>45000</d:CurrentCtc>
<d:ExpCtc>750000</d:ExpCtc>
<d:NoticePeriod>3 MONTH</d:NoticePeriod>
<d:CurrentLoc>KOLKATA</d:CurrentLoc>
<d:CurrentCom>TCS</d:CurrentCom>
<d:PassportDet>HHHWWQQ77</d:PassportDet>
<d:PhoneNum>77778585</d:PhoneNum>
<d:Email>ROCKYKUMAR@TCS.COM</d:Email>
<d:SkypeId>7745</d:SkypeId>
</m:properties>
</content>
</entry>
编辑20.07.2018
这是代码,这是应该清除单元格中数据验证但出现错误的代码。
function copyAndPaste(){
var app = SpreadsheetApp;
var ss = app.getActiveSpreadsheet().getSheetByName("Source 1");
//Logger.log(ss.getRange(3, 8).getValue())
Logger.log("LastColumn "+ss.getLastColumn());
Logger.log("LastRow "+ss.getLastRow());
Logger.log(ss.getDataRange());
var ssRange = ss.getRange(ss.getLastRow(), ss.getLastColumn()).getA1Notation();
var ssRange_ = "A1:"+ssRange;
var select = ss.getRange(ssRange_)
var destSheet = app.getActiveSpreadsheet().getSheetByName("Paste");
var destRange = destSheet.getRange(destSheet.getLastRow()+1,1);
select.copyTo (destRange, {contentsOnly: true});
select.copyTo (destRange, {contentsOnly: false});
}
答案 0 :(得分:2)
不幸的是,尚无用于在电子表格上检索图像的方法。那么如何解决呢?此解决方法的流程如下。
clearContents()
删除复制的工作表(“粘贴”)上的内容。
function copyAndPaset(){
var app = SpreadsheetApp;
var spreadsheet = app.getActiveSpreadsheet(); // Modified
var ss = spreadsheet.getSheetByName("Source 1");// Modified
var copiedSheet = ss.copyTo(spreadsheet).setName("Paste"); // Added
copiedSheet.clearContents(); // Added
var ssRange = ss.getRange(ss.getLastRow(), ss.getLastColumn()).getA1Notation();
var ssRange_ = "A1:"+ssRange;
var select = ss.getRange(ssRange_)
var destSheet = app.getActiveSpreadsheet().getSheetByName("Paste");
var destRange = destSheet.getRange(destSheet.getLastRow()+1,1);
select.copyTo (destRange, {contentsOnly: true});
select.copyTo (destRange, {contentsOnly: false}); // When this is run, the merged cells are cleared.
}
var copiedSheet = ss.copyTo(spreadsheet).setName("Paste");
相同。因为我认为您可能想放置其他值而不是重复值,所以在复制工作表后我使用了clearContents()
。select.copyTo (destRange, {contentsOnly: false})
时,将清除合并的单元格。如果您需要这种情况,请使用它。如果要保留合并的单元格,请删除此脚本。如果不是您想要的解决方法,对不起。
发生错误是因为destSheet.getLastRow()
和destSheet.getLastColumn()
均为0。getRange(0, 0)
发生错误。因此,我对脚本进行了如下修改。
function copyAndPaset(){
var app = SpreadsheetApp;
var spreadsheet = app.getActiveSpreadsheet(); // Modified
var ss = spreadsheet.getSheetByName("Source 1");// Modified
var copiedSheet = ss.copyTo(spreadsheet).setName("Paste"); // Added
copiedSheet.clearContents(); // Added
var ssRange = ss.getRange(ss.getLastRow(), ss.getLastColumn()).getA1Notation();
var ssRange_ = "A1:"+ssRange;
var select = ss.getRange(ssRange_)
var destSheet = app.getActiveSpreadsheet().getSheetByName("Paste");
var destRange = destSheet.getRange(destSheet.getLastRow()+1,1); // Moved
select.copyTo (destRange, {contentsOnly: true}); // Moved
var destSheetRange = destSheet.getRange(destSheet.getLastRow(), destSheet.getLastColumn()).getA1Notation(); // I added but will get an error
var destSheetRange_ ="A1:"+destSheetRange; // Added
var destRangeClear = destSheet.getRange(destSheetRange_); // Added
destRangeClear.clearDataValidations() // Added
//select.copyTo (destRange, {contentsOnly: false}); // When this is run, the merged cells are cleared.
}