Skip to content

Commit

Permalink
Remove SheetJS (#3223)
Browse files Browse the repository at this point in the history
Remove sheetjs
  • Loading branch information
amanmahajan7 committed May 9, 2023
1 parent efe0d6c commit bb45620
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@
"rome": "^12.0.0",
"typescript": "~5.0.2",
"vite": "^4.3.5",
"vitest": "^0.31.0",
"xlsx": "^0.18.5"
"vitest": "^0.31.0"
},
"peerDependencies": {
"react": "^18.0",
Expand Down
5 changes: 1 addition & 4 deletions website/demos/CommonFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Column, SortColumn } from '../../src';
import { textEditorClassname } from '../../src/editors/textEditor';
import type { Direction } from '../../src/types';
import type { Props } from './types';
import { exportToCsv, exportToXlsx, exportToPdf } from './exportUtils';
import { exportToCsv, exportToPdf } from './exportUtils';

const toolbarClassname = css`
display: flex;
Expand Down Expand Up @@ -356,9 +356,6 @@ export default function CommonFeatures({ direction }: Props) {
<ExportButton onExport={() => exportToCsv(gridElement, 'CommonFeatures.csv')}>
Export to CSV
</ExportButton>
<ExportButton onExport={() => exportToXlsx(gridElement, 'CommonFeatures.xlsx')}>
Export to XSLX
</ExportButton>
<ExportButton onExport={() => exportToPdf(gridElement, 'CommonFeatures.pdf')}>
Export to PDF
</ExportButton>
Expand Down
14 changes: 0 additions & 14 deletions website/demos/exportUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ export async function exportToCsv<R, SR>(
downloadFile(fileName, new Blob([content], { type: 'text/csv;charset=utf-8;' }));
}

export async function exportToXlsx<R, SR>(
gridElement: ReactElement<DataGridProps<R, SR>>,
fileName: string
) {
const [{ utils, writeFile }, { head, body, foot }] = await Promise.all([
import('xlsx'),
getGridContent(gridElement)
]);
const wb = utils.book_new();
const ws = utils.aoa_to_sheet([...head, ...body, ...foot]);
utils.book_append_sheet(wb, ws, 'Sheet 1');
writeFile(wb, fileName);
}

export async function exportToPdf<R, SR>(
gridElement: ReactElement<DataGridProps<R, SR>>,
fileName: string
Expand Down

0 comments on commit bb45620

Please sign in to comment.