-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from estie-inc/staging-22
Staging changes
- Loading branch information
Showing
15 changed files
with
237 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,8 @@ jobs: | |
cd examples/nextjs | ||
npm ci | ||
npm run build | ||
- run: | | ||
cd examples/nodejs | ||
npm ci | ||
npm run build | ||
npm run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
rust/target | ||
rust/pkg | ||
/nodejs/ | ||
/web/ | ||
|
||
**/node_modules | ||
**/*.xlsx | ||
|
@@ -8,3 +9,4 @@ rust/pkg | |
**/dist | ||
|
||
docs/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.xlsx | ||
node_modules/ | ||
main.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
Color, | ||
DocProperties, | ||
Format, | ||
FormatAlign, | ||
Workbook, | ||
} from "wasm-xlsxwriter"; | ||
import * as fs from "fs"; | ||
|
||
/** | ||
* Demo function that create a xlsx buffer from a header array and data rows | ||
* | ||
* @param {string[]} header - Sheet header strings | ||
* @param {(string | number)[][]} rows - Array of arrays containing sheet rows | ||
* @returns {Buffer} Excel file data | ||
*/ | ||
function writeExcel(header: string[], rows: (string | number)[][]): Buffer { | ||
// Create a new Excel file object. | ||
const workbook = new Workbook(); | ||
|
||
// Set a doc property | ||
const props = new DocProperties().setCompany("Test, Inc."); | ||
workbook.setProperties(props); | ||
|
||
// Add a worksheet with name to the workbook. | ||
const worksheet = workbook.addWorksheet(); | ||
worksheet.setName("Export"); | ||
|
||
// Create some formats to use in the worksheet. | ||
const headerStyle = new Format(); | ||
headerStyle | ||
.setAlign(FormatAlign.Top) | ||
.setTextWrap() | ||
.setBackgroundColor(Color.red()); | ||
|
||
// Write sheet header | ||
worksheet.writeRowWithFormat(0, 0, header, headerStyle); | ||
|
||
// Write sheet data | ||
worksheet.writeRowMatrix(1, 0, rows); | ||
|
||
// Autofit columns | ||
worksheet.autofit(); | ||
|
||
// Freeze header | ||
worksheet.setFreezePanes(1, 0); | ||
|
||
// Add autofilter to header | ||
worksheet.autofilter(0, 0, rows.length, header.length - 1); | ||
|
||
// Return buffer with xlsx data | ||
const uint8Array = workbook.saveToBufferSync(); | ||
return Buffer.from(uint8Array); | ||
} | ||
|
||
const buf = writeExcel( | ||
["Name", "Age", "City"], | ||
[ | ||
["John", 30, "New York"], | ||
["Jane", 25, "Los Angeles"], | ||
] | ||
); | ||
fs.writeFileSync("export.xlsx", buf); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"devDependencies": { | ||
"@types/node": "^22.10.2", | ||
"typescript": "^5.7.2" | ||
}, | ||
"dependencies": { | ||
"wasm-xlsxwriter": "file:../.." | ||
}, | ||
"scripts": { | ||
"build": "tsc main.ts", | ||
"start": "node main.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters