[1.1.1] copy contents of excel cell to webpage --- use module xlrd and paste

Asked by Rob Ward on 2017-03-24

I've watched the tutorials, but I noticed there is no obvious way to copy the text contents of an Excel cell to a web page.

In some ways this might actually end up being a recorded macro, as opposed to a programmed one, as I have well over 1000 separate records from excel to be entered into a web page one at a time.

There seems to be two issues here, the first being that it is not obvious to me how to copy existing text from the IDE console. Sure, I could use Ctrl-C as this is a Windows based program, but I was hoping that I could use something in Sikuli to facilitate this. Also, I was hoping I could use the graphic capture to choose and park text without having to switch windows fore and back between Excel and my browser during the execution of the macro.

The other thing I was hoping was if there was a way to go through an Excel spreadsheet with the macro, row by row, but it seems that I might be limited to duplicating the macro repeatedly to go down "sections" of rows at a time. The conditional repeat is very close to what I need, but it doesn't seem to have the ability to do more than one row at a time without writing the macro for every line. Correct me if I'm wrong, but the graphics are locked in location by X & Y coordinates, meaning I would have to write each row independently.

Lastly, I'm using the newest release, on your recommendation, and while experimenting with writing a macro, the IDE console disappeared after I selected an image. The java symbol (the coffee cup) disappeared, and although the command window was still up, access to the IDE console was no where to be seen. My guess is that it crashed but I was unable to restart the program because the command program was still running. I didn't locate it in the task manager (Windows 7) so the only choice I had was reboot to get the console back. It might be useful to add a "console only" restart.

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-03-25
Last reply:
2017-03-26
Mike (maestro+++) said : #1

SikuliX uses visual recognition features to locate screen fields and then uses keypresses etc to process data. The obvious approach is therefore to mimic how you would do this manually - locate the first spreadsheet field, Cntr-C, activate the web page, locate the web page field, Cntrl-V, activate the spreadsheet, move the highlight to the next cell of interest using the arrow keys, rinse and repeat.

You don't seem to like that - for reasons not explained. You can use other approaches apart from SikuliX. Have a look at Automate The Boring Stuff With Python by Al Sweigart

RaiMan (raimund-hocke) said : #2

no need to copy anything using the visual approach.

there is a Python module xlrd bundled with SikuliX, that allows to open Excel sheets and access cell content.
see: faq 2208

In any case use latest SikuliX 1.1.1 (http://sikulix.com)

Rob Ward (rward1953) said : #3

Actually I am very aware of how to cut and paste, but the issue is that my project requires the transfer of well over a thousand records, involving at least 5 cells each, to be transferred to a website that only receives one record at a time.

My quandary is that I don't want to be endless cutting and pasting records that I may be able to use a macro for.

To move through the separate records (ie-1 thru "1000") without being located into one row with a macro was what I was hoping to find. It appears that more research is necessary on my end, which I can accept, and that there may be more to this than "Ctrl-C and Ctrl-V" in a macro that can be repeated until interrupted.

I honestly thought this would be a simple situation, but it appears this is not the case. Time for me to do some more reading and head scratching. I'm open to further suggestions if you have them, as I am a novice coder.

Rob Ward (rward1953) said : #4

BTW, did you notice that I had a problem writing to SikuliX with a test macro?

The console disappeared in the middle of my writing of a macro, and I was unable tolocate or restart the console without restarting Windows 7. The "Command" section was still running, making it impossible to restart the program without a restart.

I am aware this could be operator error, but there appeared to be no way to locate or restart the IDE console from within windows, even with the task manager, which might cause others some annoyance in the future.

RaiMan (raimund-hocke) said : #5

your solution is mentioned in my comment #2.

rather easy without much head scratching ;-)

Rob Ward (rward1953) said : #6

Does xlrd work with Office 2010 or later versions? Or should I be using xlsxwriter or openpyxl to open the spreadsheets?

It's not immediately obvious from the download page.

RaiMan (raimund-hocke) said : #7

Just try what suits you best

Can you help with this problem?

Provide an answer of your own, or ask Rob Ward for more information if necessary.

To post a message you must log in.