List to excel

List to excel

gustavosanmartin
Advocate Advocate
550 Views
2 Replies
Message 1 of 3

List to excel

gustavosanmartin
Advocate
Advocate

Hello, how are you, someone could guide me how you can program a lisp to bring a list "X" to excel please. Each sublist row represents one row in excel.

 

(("Z" "1" "105.00" "101" "101") ("H" "2" "105.00" "102" "102") ("S" "3" "105.00" "103" "103"))

 

Thanks

0 Likes
551 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant

You can write it into .csv [= comma-separated values] format, and then if necessary in Excel convert it to .xls[x] format.  In simplest terms, something like this should do it [untested; edit these parts to suit]:

(defun C:WHATEVER (/ yourFile csvString)

  (setq yourFile (open "X:/Your/File/Path/YourFileName.csv" "w"))

  (foreach sublist X

    (setq csvString (car sublist)); start with first item

    (foreach item (cdr sublist); add others, with comma separators

      (setq csvString (strcat csvString "," item))

    ); foreach

    (write-line csvString yourFile)

  ); foreach

  (close yourFile)

); defun

Kent Cooper, AIA
0 Likes
Message 3 of 3

Sea-Haven
Mentor
Mentor

If you want direct start with Getexcel.lsp by Terrycad. It has all the routines inside it to do your task. Yes it is advanced level. But once you work it out will never look back.

 

also this 

 

screenshot394.png

 

 

0 Likes