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.

Reference to an other sheet in formula

See original GitHub issue

Hi, I have a problem using formula and Sheet reference.

I am using this :


sheet.getCell('A2').dataValidation = {
          type: 'list',
          allowBlank: true,
          formulae: ['Company.A2:A500'],
          showInputMessage: true,
          promptTitle: 'Company',
          prompt: 'In which company the user is in.',
};

And when I generate the XLSX and open the file with libre office I get ‘company.a2:A500’ in data validation and it don’t work.

I guess there is a bug in Sheet name handling, at some point you seems to put some data in lowercase.

If you have a patch I take it please! 😃

PS: I did try this too, and it gives the same behavior

sheet.getCell('A2').value = {
        formula: 'Company.A10',
        value: '',
};

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
kaykayehnncommented, Oct 29, 2021

I couldn’t get formulas linking to other worksheets to work, but I managed to work around this via the Defined names functionality, as @GregoryNEUT helpfully suggested.

Here is a short snippet illustrating this, in case anyone finds their way to this thread

// Define a named range of cells in the remote worksheet
let cellRangeName = "myCellRange";
for (let i = 2; i <= rowCount; i++) {
  // We set all cells to the same name, which creates a named range
  remoteSheet.getCell(`A${i}`).name = cellRangeName;
}

// ...

// Use the named range in my current sheet formula
sheet.fillFormula(`B2:B${rowCount}`, `${cellRangeName}*2`, () => 0);
2reactions
abhishek-rajcommented, Mar 8, 2018

I faced the same issue, went through the most part of the code of exceljs trying to fix it, seems it correctly generates the xml.

I corrected it by using (!) instead of (.)

Eg.

sheet.getCell(‘A2’).dataValidation = { type: ‘list’, allowBlank: true, formulae: [‘Company!A2:A500’], showInputMessage: true, promptTitle: ‘Company’, prompt: ‘In which company the user is in.’, };

Excel just shows a . but we need to use ! instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel reference to another sheet or workbook (external ...
To reference a cell or range of cells in another worksheet in the same workbook, put the worksheet name followed by an exclamation...
Read more >
Excel Reference Another Sheet | CustomGuide
1. Click the cell where you want to insert the reference. 2. Type = to start building the reference. 3. Select the worksheet...
Read more >
How to Reference Another Sheet or Workbook in Excel (with ...
Type the following formula in the current sheet (where you need the result): =Sum( Enter the formula to the point where you need...
Read more >
Excel Reference to Another Sheet - WallStreetMojo
So, to reference an Excel cell or range of cells from another sheet, we need to get a worksheet name first, i.e., Sheet1,...
Read more >
Create an external reference (link) to a cell range in another ...
Select the cell or cells where you want to create the external reference. Type = (equal sign). Switch to the source workbook, and...
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