How to copy the cell formula not the value?

Tags: #<Tag:0x00007efc600d8ac8>

How to copy the cell formula not the value, and auto math the row number like the excel?

Hi @gunsel

formula plugin is still in alpha stage of development and it doesn’t support formula refreshment yet.

You can use the getSourceData~ methods to get the formula. Here’s a demo http://jsfiddle.net/ne9mwudv/

@aleksandra_budnik As per your statement, auto math of row number feature is not available. If this is the case then how can we achive that, do you have any idea how to achive that… If that can be possible please explain with an working example.

sorry @ebalasubramanian24

I haven’t found any effective way to do it. The plugin is still missing some logic.

That’s fine…

Just say me one thing is there any event emitted for inserting the row, so that I can use that event to overcome that issue.

Yes, we have the beforeCreateRow event

So, then through setData() method I can feed the formula to a particular cell where I want… Am I right? @aleksandra_budnik

Can you please share me some example for beforeCreateRow() and afterCreateRow()?

Here http://jsfiddle.net/u0eqtsjm/ is an example that loads a formula in cell 0,0 if you add a row in the top position of the table.
I’ve added the setTimeout as without it the formula executes too fast and it returns VALUE error.

1 Like

That’s great… Thank you…!

1 Like

happy to help @ebalasubramanian24:)

@aleksandra_budnik
thanks for you suggestion, that’s very helpful. many thanks!!!

1 Like

Here’s http://jsfiddle.net/m3fh6c5s/21/ an example that you may find useful - it copies a formula instead of a value

Thanks for this example @aleksandra_budnik :slight_smile:

you’re welcome @ebalasubramanian24

:slight_smile:

@aleksandra_budnik can you give me an example for setDataAtRowProp(), Because I tried to feed data to a row with that but it’s not working.

Sure @ebalasubramanian24

here http://jsfiddle.net/b4mxjv8c/ I’m changing Amy to Tom in line 2 for the property name.

Fine… What If I need to change for a range of cells in a row or multiple different cells of a row? How to achive it?

The setDataAtRowProp (for objects) and setDataAtCell (for arrays) run for a single cell, so if you’d like to change data in more than a single cell you need to call the method again with different coordinates.

If the row is really long and using the above methods slows the performance you can also detach the row completely and insert a brand new one (with changed values) in the same place using alter method.

Okay… Fine… Thank you!!!