使用 Robot Framework 同时打开两个 Excel 工作表

Open two Excel sheets simultaneously with Robot Framework

这可能吗?如果可能,怎么做? - 要使用 Robot Framework 打开两个不同的 Excel 文件并从一个 Excel 复制到另一个?

目前我所知道的是如何在一个Excel文件中复制:

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}

但是如果有两个文件,Excel 文件没有选择器。

是的,这是可能的。如果您查看 Switch Current Excel Document 的关键字文档,您可以很容易地理解这个想法。您可以打开任意数量的 Excel 个文档,但当时只有一个文档处于活动状态,因此关键字仅与活动文档交互。

在你的情况下它会是这样的

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}

请注意,如果您正在处理大量数据并且数据在第一个文档中很容易获得(不需要交叉复制),则一次性复制您需要的所有内容通常效率更高。与其同时打开两个文档,不如从第一个文档中获取所需的所有内容,将其关闭,然后一次性将所有内容粘贴到第二个文档中。