-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit with exceljs export, data functions, helper functions,…
… validation functions, and workbook functions - Added initial README with example - Added GitHub actions - Added changeset config
- Loading branch information
0 parents
commit 6de322d
Showing
16 changed files
with
3,658 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
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,21 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: latest | ||
cache: "pnpm" | ||
|
||
- run: pnpm install --frozen-lockfile | ||
- run: pnpm run lint && pnpm run build |
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,36 @@ | ||
name: Publish | ||
on: | ||
workflow_run: | ||
workflows: [CI] | ||
branches: [main] | ||
types: [completed] | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
publish: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: latest | ||
cache: "pnpm" | ||
|
||
- run: pnpm install --frozen-lockfile | ||
- name: Create Release Pull Request or Publish | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
publish: pnpm run release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
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 @@ | ||
node_modules | ||
dist | ||
.DS_Store |
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,4 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Connect K12 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,79 @@ | ||
# @connectk12/exceljs | ||
|
||
This library provides a convenient way interact with Excel spreadsheet files. It contains of the following: | ||
- Workbook functions to open and export Excel workbooks | ||
- Data functions to help update cells, find rows of data, find data groups (multiple rows) for an entity, find the subsequent data group, etc. | ||
- Validation functions to validate whether the Excel workbook matches an expected template with column headers, etc. | ||
- Helper functions to handle typical scenarios that require matching data from various sources (sanitizeText, colLetterToNumber, etc.) | ||
|
||
# Special thanks | ||
The project code uses the NPM package [@zurmokeeper/exceljs](@zurmokeeper/exceljs) v4.4.7 and exports it. The @zurmokeeper/exceljs package is forked from [@exceljs/exceljs](https://github.com/exceljs/exceljs) v4.3.0. | ||
|
||
Sincere thanks to all the developers of the @exceljs/exceljs and @zurmokeeper/exceljs project. | ||
|
||
@connectk12/exceljs specifically uses @zurmokeeper/exceljs because of its capability in opening workbooks that are password-protected, as well as other bug fixes and features, since @exceljs/exceljs was no longer being supported by the team. | ||
|
||
## Installation | ||
|
||
To install the library, run the following command: | ||
|
||
```bash | ||
npm install @connectk12/exceljs | ||
``` | ||
|
||
## Usage | ||
|
||
This library contains the [@zurmokeeper/exceljs](@zurmokeeper/exceljs) library, so feel free to use the library as you would with the original library. The library also contains additional functions to help with common Excel tasks. | ||
|
||
```javascript | ||
import ExcelJS from '@connectk12/exceljs'; | ||
``` | ||
|
||
|
||
## Documentation | ||
|
||
For detailed information on the available methods from @zurmokeeper/exceljs, please refer to the [@zurmokeeper/exceljs documentation](https://github.com/zurmokeeper/excelize) or [@exceljs/exceljs documentation](https://github.com/exceljs/exceljs). | ||
|
||
|
||
## Get Started | ||
|
||
Here are some examples to get you started: | ||
|
||
### Example 1: Open Excel workbook, update cell, export workbook | ||
```javascript | ||
import ExcelJS from '@connectk12/exceljs'; | ||
import { updateCell } from '@connectk12/exceljs'; | ||
``` | ||
|
||
Notes: Regarding getting a worksheet from a workbook: | ||
- Use `workbook.worksheets[n]` to get the nth worksheet in order, or `workbook.getWorksheet("Sheet 1")` to get the worksheet by name | ||
- `workbook.getWorksheet(1)` returns the worksheet at index 1, which is not always the first worksheet | ||
|
||
Inside an async function: | ||
```javascript | ||
const workbook = await openWorkbook({ workbookPathname: 'path/to/workbook.xlsx' }); | ||
|
||
// Get the first worksheet | ||
const worksheet = workbook.worksheets[0] | ||
|
||
// Get the first row and cell | ||
const row = worksheet.getRow(1); | ||
const cell = row.getCell(1); | ||
|
||
// Update the cell with a value | ||
updateCell(cell, 'Hello, World!'); | ||
|
||
// Export the workbook | ||
const workbook = await exportWorkbook({ | ||
workbook, | ||
outputPathname: 'path/to/exported/workbook.xlsx' | ||
}); | ||
``` | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/connectk12/exceljs). | ||
|
||
## License | ||
|
||
This library is licensed under the [MIT License](https://opensource.org/licenses/MIT). |
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,22 @@ | ||
{ | ||
"name": "@connectk12/exceljs", | ||
"license": "MIT", | ||
"version": "0.0.1", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsup src/index.ts --format cjs,esm --dts", | ||
"release": "pnpm run build && changeset publish", | ||
"lint": "tsc" | ||
}, | ||
"dependencies": { | ||
"@zurmokeeper/exceljs": "^4.4.7" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.27.7", | ||
"@types/node": "^22.0.0", | ||
"tsup": "^8.2.3", | ||
"typescript": "^5.5.4" | ||
} | ||
} |
Oops, something went wrong.