Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I reference other cells? #2

Open
joshcho opened this issue Oct 4, 2023 · 2 comments
Open

How do I reference other cells? #2

joshcho opened this issue Oct 4, 2023 · 2 comments

Comments

@joshcho
Copy link

joshcho commented Oct 4, 2023

I know the focus is more on development rather than documentation, but I'd love to try this. How do I reference other cells via id?

Also, if you have the bandwidth, would love a zoom-based demo, email me at [email protected]

@joshcho
Copy link
Author

joshcho commented Oct 4, 2023

Nvm, cursor helped me find $coord and $neighbor (but neighbor wasn't quite working). Couldn't find sth like $id though.

Even just screenshots with the formulas shown for the cells would be very useful.

@tripplilley
Copy link

tripplilley commented Jul 28, 2024

@joshcho : The demo spreadsheet in dev/resources/demo-sheet.edn has some (hopefully) useful examples.

I don't know about "by ID", but you can apparently name a cell (see line 16) and then refer to it using ($ "name") (see line 101).

update: looking at src/tesserae/eval.clj:131, there's a let binding that appears to set up various handlers for referencing cells:

  • ($ "name")
  • ($coord ...) (I'm not sure what $coord takes as an arg, maybe [x y] as seen in the .edn file?)
  • ($neighbor ...)
  • ($neighbor-code :up) (try :up, :down, :right, :left?)

I don't (yet) see anything about referencing by :db/id, but I'll update this if I do...

update: Oh, I just re-read your second comment and saw that you already found $coord and $neighbor 🤣. Well, I'll keep updating just the same, in case someone else comes along and needs the pointers into the code.

update: (final?) At this point, I'm willing to say that there is no "blessed" way to refer to a cell by ID, since the ID comes from the underlying data layer (Datalevin) and is technically an implementation detail. Using a name is probably the way to go, if you want a reference that will survive rearrangement of the sheet. I'm not even sure IDs are stable under that circumstance, since I haven't reviewed the code that deeply 😅.

(Please note that I'm making assumptions based on reading the code, and haven't actually installed anything yet 😅)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants