How to deconstruct a list into spreadsheet

Started by rickyboy, April 13, 2005, 12:17:39 PM

Previous topic - Next topic

rickyboy

Hello everyone,



I have a question regarding the use of expressions returned from newlisp.dll to an Excel spreadsheet (thanks BTW for providing the Excel VBA "glue code" to newlisp.dll).  Everything seems to work great, until I need to assign newlisp list components to cells of a spreadsheet.  Is that possible?  If so, then how?



For instance, say I have defined a function in newlisp called 'my-list-maker'.  Then if I put in cell A1 '(my-list-maker <args>)' and the function call '=newlispeval(A1)' in another cell, I get the printed representation of the list in this cell (which can be rather long, as in my particular application).  It would be nice to be able to say instead '=newlisp_destruct_value_vertically(A1)' and the list components could be put one-by-one in a vertical column starting with the cell containing the function call.  This would be useful, say when one wants to use Excel to graph a list of numbers coming from newlisp.



I wonder if this is possible and I admit much ignorance regarding Excel -- perhaps this is why the solution eludes me.  Thanks for any help!  --Rick
(λx. x x) (λx. x x)

Lutz

#1
What newlisp.dll returns to Excel is always a string. You coulde use macro written in Excel to prase the date and put them in contiguos cells using the Excel statements 'Data/Text to Clumns' or you could design a solution some of the many string/text functions available in Excel.



Perhaps yoru best aproach would be to return a "clean" list from newLISP, i.e: "1 2 3 4 5" and ask in an Excel forum on the Web how to break that string up into cells.



To produce such a string list you would do the following in newLISP:

; imagine you have this result list

(set 'L '(1 2 3 4 5))

; convert it to a string for Excel processing

(join (map string L) " ") => "1 2 3 4 5"

Lutz