[Drop-In] Excel Import

Show off your RPG maps, campaigns, and tokens. Share your gaming experiences and stories under General Discussion and save this forum for things you've created that may help others run their own games. Use the subforums when appropriate.

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
User avatar
Sir Flak
Dragon
Posts: 344
Joined: Thu Sep 28, 2006 4:20 pm
Location: Oklahoma, US

[Drop-In] Excel Import

Post by Sir Flak »

I've been working on a framework and wanted to keep the data organized in excel. So I needed a way to quickly copy and paste tabular data into a json on a token. I figured I'd make the solution generic so you all could benefit from it.

Excel by default tab delimits the data and uses newlines to separate rows. You should have a final newline automatically from excel when you paste. Do not delete that newline as it can cause data loss.

Basically you select your table in excel. Copy. Paste it into the dialog. If your data has headers (or not) make sure the box is checked appropriately. You can select which token name you want the table to be placed as well as the variable name.

When you import data with headers it'll make a json array where each row's data has keys. Without headers you get an array of arrays.
Excel Table
Excel Table
Image1.PNG (5.34 KiB) Viewed 1528 times
Import Dialog
Import Dialog
Image2.PNG (54.53 KiB) Viewed 1528 times
Also I added a XLI.table() funciton similar to the table() function. For data without headers and leading with numbers. Its fairly easy to use I made most of the parameters except the table name optional.

XLI.table(string tableName, <int vlookup, string tableLocation>);

if you don't give it a vlookup it'll find the biggest number X in your keys and roll 1dX on the table, sort of like the regular table function. If you don't give it a location it will use currentToken().

Basically you can import properly formatted tables from excel and roll against them easily. The function returns that row's json with your roll substituted for the key.

Example: Below is a table for rolling random colors.
Interpreted as <=10 Red, 11-25 Blue, <=100 Orange
10 Red
25 Blue
100 Orange
XLI.table("XLI_table",1d100, "Lib: XLImport")
Output: [30,"Orange"]
XLI.table("XLI_table",-5, "Lib: XLImport")
Output: [-5,"Red"]

Let me know if you have any issues.

Enjoy!
Attachments
Lib_XLImport.rptok
Library Token v1
(21.45 KiB) Downloaded 86 times

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [Drop-In] Excel Import

Post by wolph42 »

Interesting stuff, though I get the feeling that its very close to this drop-in I created (quite) a while ago, maybe have a look and see if you can scavenge anything interesting from it.

User avatar
Sir Flak
Dragon
Posts: 344
Joined: Thu Sep 28, 2006 4:20 pm
Location: Oklahoma, US

Re: [Drop-In] Excel Import

Post by Sir Flak »

Lols. I definitely did not see that. I'll check yours out.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [Drop-In] Excel Import

Post by wolph42 »

Sir Flak wrote:Lols. I definitely did not see that. I'll check yours out.
Welk in all honesty it was hidden quite well. I just moved it to the drop in section so it can be easier accessed.

Post Reply

Return to “User Creations”