Is it possible - and if yes, how? - to open two different Excel files with Robot Framework and copy from one Excel to the other?
What I know up to now is how to copy inside one Excel file:
ExcelLibrary.Open Excel Document ${FileName} doc_id=doc_id
${val} = ExcelLibrary.Read Excel Cell 1 1
ExcelLibrary.Write Excel Cell 2 1 ${val}
ExcelLibrary.Save Excel Document ${FileName}
but there is no selector for the Excel file if there are two files.
CodePudding user response:
Yes it is possible. If you check the keyword documentation of Switch Current Excel Document, you can quite easily get the idea. You'll have as many Excel documents open as you wish but only one of them is active at the time, so the keywords only interact with the active one.
In your case it would be something like
Open Excel Document ${FileName} doc_id=doc_id
Open Excel Document ${FileName2} doc_id=doc_id2
${val} = Read Excel Cell 1 1
Switch Current Excel Document doc_id2
Write Excel Cell 2 1 ${val}
Save Excel Document ${FileName2}
Notice that if you are working on large set of data and the data is readily available in the first document (no cross-copying required), it usually is more efficient to copy everything you need in one go. Rather than having two documents open at the same time, you'd take everything needed from the first document, close it down and then paste everything to the secondary document in one go.