Jump to content

Recommended Posts

Posted

I have a JS that creates an array of objects from which it creates an HTML table and with CSS it colors some background color td.
I need to get the same table in autoit to write it to Excel WITH BGcolor too.

If I had only the raw table I could transform it to an array and paste it to Excel, BUT then I'll miss all the color background that I need to recalculate into Autoit. And if I will change the JS code (removing or rearranging  columns or the color logic, I have to rewrite Autoit code too...)

So, is there a way to get actual HTML td data with colors and paste them to Excel directly?

Posted (edited)

Good suggestion! Manually selecting table and pasting into excel it preserves the colors! So it could be possible to automate this way.

I tried this, after manually copying the table in the clipboard:

Making a manual copy of the table with ctrl-c, I used this code to paste the clipboard:

local $copied = _Excel_RangeCopyPaste($oWB_KW.Worksheets( "Analisi_"), Default , "C8" )  
ConsoleWrite($copied & " err:" & @error & " ext:" & @extended & @CRLF)

But I get this error:

0 err:4 ext:-2147352567

If I paste it with ctrl-v excel get it right!

Anyway, without manually selecting the table, should I use a var containing the table innerHTML, using ClipPut to paste it to clipboard and then paste it to Excel?

Edited by frank10
Posted (edited)

table HTML code from WD_driver is like:

$table = '{"value":"\u003Ctable class=\"hilite\" id=\"highlight\" style=\"width: 99%;\">\u003Ctbody>\u003C/tbody>\u003Ctr>\u003Ccolgroup>\u003Ccol style=\"width: 2%;\">\u003Ccol style=\"width: 15%;\">\u003Ccol style=\"width: 8%;\">\u003C/colgroup>\u003Ccolgroup class=\"colgray\">\u003Ccol style=\"width: 8%;\">\u003Ccol style=  ....

so, it has inline style css in it. Strangely it has also that Unicode \u003C instead of "<".

But excel does not interpret it correctly... I copied the html code to clipboard like:

<table class=\"hilite\" id=\"highlight\" style=\"width: 99%;\"><tbody></tbody><tr><colgroup><col style=\"width: 2%;\"><col style=\"width: 15%;\"><col .......

and it pasted it like a text cell (infact the var is a string...)!! So the table must be copied in the clipboard rendered by the browser... how programmatically?

Edited by frank10
Posted (edited)

@frank10  I was able to replicate your issue.  To solve it, I did have to use the COM object like this :

#include <Excel.au3>

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookNew($oExcel, 1)
Local $oTarget = $oWorkbook.Activesheet
$oTarget.cells (8, 3).select ; select C8 cell to paste to
$oTarget.Paste () ; paste everything

Working for me...

Edited by Nine

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...