[英]Copy cells from excel sheet and paste it to a DB query Sikuli
I am new to Sikuli. 我是Sikuli的新手。 I need to copy data from excel sheets and paste them to a DB query using sikuli script. 我需要从excel工作表中复制数据,然后使用sikuli脚本将其粘贴到数据库查询中。 And how can I iterate among the excel cells to copy and paste the data repeatedly. 以及如何在Excel单元格之间迭代以重复复制和粘贴数据。
These data needs to copied and pasted one after the other. 这些数据需要一个接一个地复制和粘贴。
It might be easier to copy all of the cells at once, then paste them one by one. 一次复制所有单元格,然后将它们一个个粘贴,可能会更容易。
once Sikuli has opened Excel, you could do something like: 一旦Sikuli打开Excel,您可以执行以下操作:
type(Key.HOME, KeyModifier.CTRL) #takes you to cell A1
type("a", KeyModifier.CTRL) #select all
type("c", KeyModifier.CTRL) #copy to clipboard
fromExcel = Env.GetClipboard().strip() #get clipboard contents into Sikuli, without leading or trailing white space
cells = fromExcel.split("/n") #split each cell into list on newline
#go to the destination app, maybe using App.open("nameOfYourApp") if it's not open yet, or App.focus("nameOfYourApp") if it is already open
for cell in cells: #use python to iterate through your list
#navigate to the line or cell where you want to paste
paste(cell)
Would something like that be of help? 这样的事会有帮助吗?
Rather than providing a specific approach let's understand the options you have. 除了提供特定的方法外,让我们了解一下您所拥有的选项。
Note : In all cases you will obviously have to think of how do you bring yourself to the point where you have an open Excel sheet on your screen and how to dispose of it when done. 注意 :在所有情况下,您显然都必须考虑如何将自己带到屏幕上有打开的Excel工作表以及完成后如何处理它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.