Skip to content

Commit

Permalink
Change npm dependency to exceljs fork
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Aug 2, 2023
1 parent d14448e commit c228e7f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion dist/Workbook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FsWorkbook } from "./FsSpreadsheet/FsWorkbook.js";
import { addFsWorksheet, addJsWorksheet } from "./Worksheet.js";
import { Excel } from "./fable_modules/Fable.Exceljs.1.3.6/ExcelJs.fs.js";
import { Excel } from "./fable_modules/Fable.Exceljs.1.5.0/ExcelJs.fs.js";
import { disposeSafe, getEnumerator } from "./fable_modules/fable-library.4.1.3/Util.js";

export function toFsWorkbook(jswb) {
Expand Down
24 changes: 11 additions & 13 deletions dist/Xlsx.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { PromiseBuilder__Delay_62FBFDE1, PromiseBuilder__Run_212F1D4B } from "./fable_modules/Fable.Promise.3.2.0/Promise.fs.js";
import { Excel } from "./fable_modules/Fable.Exceljs.1.3.6/ExcelJs.fs.js";
import { Excel } from "./fable_modules/Fable.Exceljs.1.5.0/ExcelJs.fs.js";
import { promise } from "./fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js";
import { startAsPromise } from "./fable_modules/fable-library.4.1.3/Async.js";
import { toJsWorkbook, toFsWorkbook } from "./Workbook.js";
import { singleton } from "./fable_modules/fable-library.4.1.3/AsyncBuilder.js";
import { class_type } from "./fable_modules/fable-library.4.1.3/Reflection.js";

export class Xlsx {
Expand All @@ -12,24 +10,24 @@ export class Xlsx {
static fromXlsxFile(path) {
return PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => {
const wb = new Excel.Workbook();
return startAsPromise(wb.xlsx.readFile(path)).then(() => {
return wb.xlsx.readFile(path).then(() => {
const fswb = toFsWorkbook(wb);
return Promise.resolve(fswb);
});
}));
}
static fromXlsxStream(stream) {
return singleton.Delay(() => {
return PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => {
const wb = new Excel.Workbook();
return singleton.Bind(wb.xlsx.read(stream), () => singleton.Return(toFsWorkbook(wb)));
});
return wb.xlsx.read(stream).then(() => (Promise.resolve(toFsWorkbook(wb))));
}));
}
static fromBytes(bytes) {
return singleton.Delay(() => {
return PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => {
const wb = new Excel.Workbook();
const uint8 = new Uint8Array(bytes);
return singleton.Bind(wb.xlsx.load(uint8.buffer), () => singleton.Return(toFsWorkbook(wb)));
});
return wb.xlsx.load(uint8.buffer).then(() => (Promise.resolve(toFsWorkbook(wb))));
}));
}
static toFile(path, wb) {
const jswb = toJsWorkbook(wb);
Expand All @@ -40,11 +38,11 @@ export class Xlsx {
return jswb.xlsx.write(stream);
}
static toBytes(wb) {
return singleton.Delay(() => {
return PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => {
const jswb = toJsWorkbook(wb);
const buffer = jswb.xlsx.writeBuffer();
return singleton.Return(buffer);
});
return Promise.resolve(buffer);
}));
}
}

Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "3.2.2+caf21db",
"description": "Minimal spreadsheet creation and manipulation using exceljs io.",
"type": "module",
"main": "npmpkg/Xlsx.js",
"main": "dist/Xlsx.js",
"files": [ "dist", "package.json" ],
"scripts": {
"clean-test": "cd tests/FsSpreadsheet.Tests/js & dotnet fable clean --extension .js --yes",
"pretest": "npm run clean-test && dotnet fable tests/FsSpreadsheet.Tests -o tests/FsSpreadsheet.Tests/js",
Expand Down Expand Up @@ -32,6 +33,6 @@
"mocha": "^10.2.0"
},
"dependencies": {
"exceljs": "^4.3.0"
"@nfdi4plants/exceljs": "0.1.0"
}
}
4 changes: 2 additions & 2 deletions src/FsSpreadsheet.Exceljs/FsSpreadsheet.Exceljs.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fable.Exceljs" Version="1.5.0" />
<PackageReference Include="Fable.Exceljs" Version="1.6.0" />
<PackageReference Include="Fable.Promise" Version="3.2.0" />
</ItemGroup>

Expand All @@ -45,7 +45,7 @@

<PropertyGroup>
<NpmDependencies>
<NpmPackage Name="exceljs" Version="gte 4.3.0 lt 5.0.0" ResolutionStrategy="Max" />
<NpmPackage Name="@nfdi4plants/exceljs" Version="gte 0.1.0 lt 1.0.0" ResolutionStrategy="Max" />
</NpmDependencies>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions tests/JS/TestFiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Never open these test files and save them with libre office or microsoft excel. They will automatically standardize the files to their favored format, making them all uniform and working with both OpenXml and Exceljs.

0 comments on commit c228e7f

Please sign in to comment.