frank10 Posted June 11, 2020 Posted June 11, 2020 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?
Subz Posted June 11, 2020 Posted June 11, 2020 Have you tried using the _Excel_RangeCopyPaste function to paste clipboard data?
frank10 Posted June 11, 2020 Author Posted June 11, 2020 (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 June 11, 2020 by frank10
frank10 Posted June 11, 2020 Author Posted June 11, 2020 (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 June 11, 2020 by frank10
Nine Posted June 11, 2020 Posted June 11, 2020 (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 June 11, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
frank10 Posted June 11, 2020 Author Posted June 11, 2020 Thank you Nine, it works well! For copying the rendered table to clipboard, I choose JS commands, like selectNodeContents.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now