Message Boards Message Boards

Tip for using Grid and SpanFromLeft and similar

Sometimes struggling to get a properly formatted grid. Where to put the correct SpanFromLeft etc? With Excel it's easy and this is a way I found import it to Mathematica.

with XLS I have (example)

enter image description here

data = Flatten[Import["test.xlsx", "FormattedData"], 
   1] /. {Style[SpanFromLeft, __] -> SpanFromLeft, 
   Style[SpanFromAbove, __] -> SpanFromAbove, 
   Style[SpanFromBoth, __] -> SpanFromBoth, Style[x : _, __] -> x}

Grid[%, Frame -> All]

This generates:

enter image description here

POSTED BY: l van Veen
3 Replies

Interesting, I am curious what type of workflows are you using it for? Possibly when presentations, when you have some other info in a notebook but also would like to include a spanned table there?

POSTED BY: Sam Carrettie

Hi Sam, I use Grid to present data as a dashboard with some controls (Sliders etc). Changing the layout is sometimes a pain and I need to know where to place the Spans etc. So I create an XLS with the merges for the layout together with some dummy data that I can replace with Dynamic functions and so on. So basically this generates the layout of the grid which I can use for my purpose. Specifically at this moment I'm writing a simple dashboard for stock info and create some sliders to set thresholds for some standard indicators (MACD, RSI, STO etc). At the background (scheduled tasks) I download latest stock info and compare it to the thresholds. When it exceeds the threshold I create a signal (sound,mail,sms or whatever).

POSTED BY: l van Veen

Wow, quite unexpected application but I see why grids could be useful there. I'd love to see your dashboard when you finish it.

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract