-
Notifications
You must be signed in to change notification settings - Fork 149
Closed
Labels
BugSomething isn't workingSomething isn't workingFunctionFeature or bug in formula functionFeature or bug in formula functionImpact: MediumPublicRoadmapIssue announced on our public roadmapIssue announced on our public roadmap
Description
Description
Passing a range as the first argument to an OFFSET formula results in an error
For example: ={OFFSET(A1:B1, 0, 0)} ={OFFSET(myRangeOne, 0, 0)}
// expected result in all cases: cellA
const HyperFormula = require('hyperformula');
const options = {
licenseKey: 'gpl-v3',
};
// Success
let hf = HyperFormula.HyperFormula.buildFromArray(
[['cellA', 'cellB', '=OFFSET(A1, 0, 0)']],
options
);
console.log(
'Result1:',
hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
);
// Success
hf = HyperFormula.HyperFormula.buildFromArray(
[['cellA', 'cellB', '={OFFSET(A1, 0, 0):OFFSET(A1, 0, 0)}']],
options
);
console.log(
'Result2:',
hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
);
// BUG: First argument to OFFSET is not a reference
hf = HyperFormula.HyperFormula.buildFromArray(
[['cellA', 'cellB', '={OFFSET(A1:B1, 0, 0)}']],
options
);
console.log(
'Result3:',
hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
);
// Success
hf = HyperFormula.HyperFormula.buildFromArray(
[['cellA', 'cellB', `={'Sheet1'!$A$1:$B$1}`]],
options
);
console.log(
'Result4:',
hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
);
// BUG: Cell range not allowed.
hf.addNamedExpression('myRangeOne', `='Sheet1'!$A$1:$B$1`);
hf.setCellContents(hf.simpleCellAddressFromString('C1', 0), [
[`={myRangeOne}`],
]);
console.log(
'Result5:',
hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
);
// BUG: Cell range not allowed.
// hf.addNamedExpression("myRangeTwo", `={'Sheet1'!$A$1:$B$1}`)
// hf.setCellContents(hf.simpleCellAddressFromString('C1', 0), [[`=myRangeTwo`]] )
// console.log(
// 'Result6:',
// hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
// );
// BUG: First argument to OFFSET is not a reference.
hf.setCellContents(hf.simpleCellAddressFromString('C1', 0), [
[`={OFFSET(myRangeOne, 0, 0)}`],
]);
console.log(
'Result7:',
hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
);Added:
OFSSET formula cannot return range of another sheet
const HyperFormula = require('hyperformula');
let hf = HyperFormula.HyperFormula.buildEmpty( { licenseKey: 'gpl-v3' })
hf.addSheet();
hf.addSheet();
hf.setSheetContent(1, [['expectResult']]);
hf.setSheetContent(0, [['cellA', 'cellB', `={OFFSET('Sheet2'!A1, 0, 0)}`]]);
// BUG: Returned value from wrong sheet (cellA)
console.log(
'Result1:',
hf.getCellValue(hf.simpleCellAddressFromString('C1', 0))
);Video or screenshots
No response
Demo
https://stackblitz.com/edit/stackblitz-starters-xv2m7kwi?file=index.js
HyperFormula version
2.7.1
Your framework
No response
Your environment
node v18.20.3, v23.1.0
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingFunctionFeature or bug in formula functionFeature or bug in formula functionImpact: MediumPublicRoadmapIssue announced on our public roadmapIssue announced on our public roadmap