Jump to content

Copy and Paste into Excel


MudawarCad

Recommended Posts

Dear CADTutor,

 

I'm developing this lisp routine to extract data from my dwg file and paste into excel file. Two questions:

 

First question: is it possible to copy my string value output using lisp without having to copy manually everytime and pasting into excel?

 

Second question: how do I paste one string and seperates in different cells in excel? I've used "\t" character but it outputs three spaces and pastes in one cell.

 

Thanks.

Link to comment
Share on other sites

A quick answer

 

This will copy ' --TEXTSTRING-- ' to the clipboard and you can then paste to a spreadsheet from there, this is perhaps the simplest solution though having to manually paste to excel add a little work (can also paste to wherever you want with this, a text editor, word processor, another drawing or wherever.

 

CAD is off today, Sunday, but I think if you create your text string with a tab character in between 'cells' it might paste them into new cells - not something I have done though. Not sure about multiple lines.

 

(vlax-invoke (vlax-get (vlax-get (vlax-create-object "htmlfile") 'ParentWindow) 'ClipBoardData) 'setData "TEXT" --TEXTSTRING-- )

 

 

You could also look at 'paste special' in excel, s there an option to paste CSV (comma separated values), and in that case you can create a temporary CSV file and paste that?

 

 

Working with spreadsheets via AutoCAD.... a but tricky I understand but if you can save your text as a half way, like CSV it become a little easier but you need to do more work.

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

FYI if you don't release "htmlfile" it could so some funky things after multiple copies.

 

;;MP
;;http://www.theswamp.org/index.php?topic=21764.msg263322#msg263322
(defun _GetClipBoardText( / htmlfile result )
  (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'GetData "Text"))
  (vlax-release-object htmlfile)
)

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

 

16 minutes ago, mhupp said:

FYI if you don't release "htmlfile" it could so some funky things after multiple copies.

 

 

Thanks, I'll change the code I copied that form in the morning

 

Link to comment
Share on other sites

Still working on a expanded excel library functions so could do select text then select cell and it will PUT value direct not using clipboard. Stumbled on real nice get cell address. So if say make a list or selection set of text could do a multi PUT.  For multi need extra question go right or down. 

 

Watch this space, very close. This is Acad / Bricscad asking excel to select a range and return the cell range. Big thanks to FIXO code unfortunately no longer with us did lots of excel stuff.

 

image.png.28045a362ace616eaf738d40b9b1271e.png

 

So the get from is done

 

Importing X and Y Coordinates for Custom made blocks from excel. - Autodesk Community - AutoCAD

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-x-and-y-coordinates-for-custom-made-blocks-from-excel/td-p/11373585

 

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

Ok so back to this, Mudawarcad if you can provide a dwg and a matching xls then I will see what I can do. 

 

Need to know the rules like start at cell and go right and down etc for multi entry like rows and columns.

 

Need to look at how your going to pick the text. 

 

Hmm Table to excel direct global function maybe do that first.

 

 

Edited by BIGAL
Link to comment
Share on other sites

Steven P and mhupp, answered my first question and the "\t" did work in these functions. Bigal, sounds very important but for the sake of little time, I'll check it out later. Thanks a lot everyone.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...