How to deconstruct a list into spreadsheet

Q&A's, tips, howto's
Locked
rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

How to deconstruct a list into spreadsheet

Post by 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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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:

Code: Select all

; 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

Locked