Skip to content

Commit 94d563b

Browse files
authored
Testing compatibility of HF with Excel and Sheets (#1537)
* Add test/compatibility subdirectory * Install exceljs lib * Compare evaluation results * Use epsilon to compare numbers * Handle cell errors * Add script that runs all the test files in a loop * Handle null-like values in xlsx files * Update file-import guide in the docs to handle empty cells correctly * Add test:compatibility to npm run test script * Add test/compatibility/README.md file
1 parent dfabda5 commit 94d563b

File tree

505 files changed

+2633
-1599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

505 files changed

+2633
-1599
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ src/interpreter/plugin/3rdparty
1111
*.config.js
1212
karma.*
1313
doc
14+
test/unit/_setupFiles/*.js
1415

1516
# Auto-generated directories
1617
commonjs
@@ -25,4 +26,3 @@ test-jasmine
2526
test-jest
2627
typedoc
2728
typings
28-
test/_setupFiles/*.js

DEV_DOCS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Dev Docs
2+
3+
Random notes and things to know useful for maintainers and contributors.
4+
5+
## Sources of the function translations
6+
7+
HF supports internationalization and provides the localized function names for all built-in languages. When looking for the valid translations for the new functions, try these sources:
8+
- https://support.microsoft.com/en-us/office/excel-functions-translator-f262d0c0-991c-485b-89b6-32cc8d326889
9+
- http://dolf.trieschnigg.nl/excel/index.php

docs/guide/file-import.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To import XLSX files, use a third-party [XLSX parser](https://www.npmjs.com/sear
1616

1717
### Example: Import XLSX files in Node
1818

19-
This example uses [ExcelJS](https://www.npmjs.com/package/exceljs) to import XLSX files into HyperFormula.
19+
This example uses [ExcelJS](https://www.npmjs.com/package/exceljs) to import XLSX files into HyperFormula.
2020

2121
See full example on [GitHub](https://github.com/handsontable/hyperformula-demos/tree/3.0.x/read-excel-file).
2222

@@ -43,18 +43,21 @@ function convertXlsxWorkbookToJavascriptArrays(workbook) {
4343
const workbookData = {};
4444

4545
workbook.eachSheet((worksheet) => {
46+
const sheetDimensions = worksheet.dimensions
4647
const sheetData = [];
4748

48-
worksheet.eachRow((row) => {
49+
for (let rowNum = sheetDimensions.top; rowNum <= sheetDimensions.bottom; rowNum++) {
4950
const rowData = [];
5051

51-
row.eachCell((cell) => {
52+
for (let colNum = sheetDimensions.left; colNum <= sheetDimensions.right; colNum++) {
53+
const cell = worksheet.getCell(rowNum, colNum)
54+
5255
const cellData = cell.formula ? `=${cell.formula}` : cell.value;
5356
rowData.push(cellData);
54-
});
57+
}
5558

5659
sheetData.push(rowData);
57-
});
60+
}
5861

5962
workbookData[worksheet.name] = sheetData;
6063
})

jest.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ module.exports = {
1414
coverageDirectory: "coverage",
1515

1616
// A path to a module which exports an async function that is triggered once before all test suites
17-
globalSetup: '<rootDir>/test/_setupFiles/globalSetup.ts',
17+
globalSetup: '<rootDir>/test/unit/_setupFiles/globalSetup.ts',
1818

1919
// A set of global variables that need to be available in all test environments
2020
globals: {
2121
"ts-jest": {
22-
"tsconfig": "./test/tsconfig.json"
22+
"tsconfig": "./test/unit/tsconfig.json"
2323
}
2424
},
2525

@@ -32,16 +32,16 @@ module.exports = {
3232

3333
// The paths to modules that run some code to configure or set up the testing environment after each test
3434
setupFilesAfterEnv: [
35-
'<rootDir>/test/_setupFiles/bootstrap.ts',
36-
'<rootDir>/test/_setupFiles/jest/bootstrap.ts'
35+
'<rootDir>/test/unit/_setupFiles/bootstrap.ts',
36+
'<rootDir>/test/unit/_setupFiles/jest/bootstrap.ts'
3737
],
3838

3939
// The test environment that will be used for testing
4040
testEnvironment: "node",
4141

4242
// The glob patterns Jest uses to detect test files
4343
testMatch: [
44-
"<rootDir>/test/**/*spec.(ts|js)"
44+
"<rootDir>/test/unit/**/*spec.(ts|js)"
4545
],
4646

4747
silent: true,

karma.starter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import './test/_setupFiles/bootstrap';
1+
import './test/unit/_setupFiles/bootstrap';
22

33
//@ts-ignore
44
const specArg: string = __karma__.config.spec;
55

66
// require all modules ending in ".spec.ts" from the
77
// './test' directory and all subdirectories
8-
const testsContext = require.context('./test', true, /.spec.ts$/);
8+
const testsContext = require.context('./test/unit', true, /.spec.ts$/);
99
let files = testsContext.keys();
1010

1111
if (specArg) {

0 commit comments

Comments
 (0)