question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Shared Formula master must exist above and or left of clone

See original GitHub issue

I want to insert new rows dynamically into my sheet and have them inherit the formula used above.

  const workbook = await readWorkbook('./sample-sheet.xlsx')
  const worksheet = workbook.getWorksheet('Consumables')
  const row = worksheet.getRow(7)

  const column = 'O'
  const value = row.getCell(column).value
  console.log(`current value of ${column}`)
  console.log(value)
  console.log(row.getCell(column).formulaType)

  row.getCell(column).value = {
    sharedFormula: `${column}6`, result: 0
  }

  row.commit()

  await saveWorkbook(workbook, 'export.xlsx')

It logs this error

Error: Shared Formula master must exist above and or left of clone
 .....
......

This works for some columns. So my question is, how do I set a share formula? or better yet, how can I achieve this differently if there’s an alternative

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

4reactions
FraeuleinWildcommented, Feb 4, 2021

I finally realized what causes the error and it is really simple to overcome. Apparently dragging and dropping formulas in the excel template create these “slave-master relationships” that the library can’t handle. The error does not occur if the templates formulas are inserted manually. So instead of writing in Cell A11: “=sum(A1:A10)” and then dragging the formula to cell B11 it is important to manually type in B11 “=sum(B1:B10)”. The formulas generated by dragging and dropping are completely the same, but treated differently internally.

3reactions
taviroquaicommented, May 6, 2020

@joobisb thanks for the info. I left original cells with formula intact and only fill new values/formula on empty cells. It was the only way to get around this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

exceljs/README.md - UNPKG
129, <li><a href="#shared-formula">Shared Formula</a></li> ... want the style objects to be independent, you will need to clone them before assigning them.
Read more >
exceljs-modify - npm Package Health Analysis - Snyk
If you want the style objects to be independent, you will need to clone them before assigning them. Also, by default, when a...
Read more >
How to get computed values from formula cells using ExcelJs ...
How to get computed values from formula cells using ExcelJs. It is returning formula instead of value that I am on seeing on...
Read more >
exceljs - npm
Shared Formula ; Formula Type; Array Formula. Rich Text Value; Boolean Value; Error Value. Config; Known Issues; Release History ...
Read more >
Video: Advanced formulas and references - Microsoft Support
Training: Follow the step-by-step creation of a sample formula, complete with references and functions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found