Copy Cells from Excel to a notepad using xlrd

Asked by Asadullah Baig

How to copy the cell value from excel to notepad using xlrd. I am able to print the value in SIKULI IDE but need help in copy & paste to notepad
----
import xlrd

book = xlrd.open_workbook("C:\Sikuli\Test0501.xls")
sh = book.sheet_by_index(0)
openApp ("notepad.exe")
print sh.col(0)[1].value

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

...
openApp ("notepad.exe")
wait(3) # to get the editor window ready and focused
paste( str(sh.col(0)[1].value) )
type(Key.ENTER) # to add a newline

Why don't you write directly into a file using the Python features?

f = open("some_file.txt", "w")
f.write(str(sh.col(0)[1].value))
f.close()

Revision history for this message
Asadullah Baig (asad-baig) said :
#2

Thanks for the quick response and resolving the issue.