|
|
|
@ -3,9 +3,16 @@ import { IconFileExport } from '@tabler/icons';
|
|
|
|
|
import { Button } from '@mui/material';
|
|
|
|
|
import * as Excel from 'exceljs';
|
|
|
|
|
import saveAs from 'file-saver';
|
|
|
|
|
import { useAlert } from 'react-alert';
|
|
|
|
|
|
|
|
|
|
const ExcelDownload = ({ fileName, gridColumns, excelDatas, isDisabled = true }) => {
|
|
|
|
|
const alert = useAlert();
|
|
|
|
|
|
|
|
|
|
const ExcelDownload = ({ fileName, gridColumns, excelDatas }) => {
|
|
|
|
|
const handleExcelDownload = () => {
|
|
|
|
|
if (!excelDatas || excelDatas.length === 0) {
|
|
|
|
|
alert.show('다운로드할 대상이 없습니다.[데이타 조회후 실행]');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const workbook = new Excel.Workbook();
|
|
|
|
|
const worksheet = workbook.addWorksheet('Sheet'); // sheet 이름이 My Sheet
|
|
|
|
|
/*
|
|
|
|
@ -88,7 +95,14 @@ const ExcelDownload = ({ fileName, gridColumns, excelDatas }) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Button variant="contained" color="primary" size="small" startIcon={<IconFileExport />} onClick={handleExcelDownload}>
|
|
|
|
|
<Button
|
|
|
|
|
disabled={isDisabled}
|
|
|
|
|
variant="contained"
|
|
|
|
|
color="primary"
|
|
|
|
|
size="small"
|
|
|
|
|
startIcon={<IconFileExport />}
|
|
|
|
|
onClick={handleExcelDownload}
|
|
|
|
|
>
|
|
|
|
|
엑셀다운로드
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
@ -97,7 +111,8 @@ const ExcelDownload = ({ fileName, gridColumns, excelDatas }) => {
|
|
|
|
|
ExcelDownload.propTypes = {
|
|
|
|
|
fileName: PropTypes.string.isRequired,
|
|
|
|
|
gridColumns: PropTypes.array.isRequired,
|
|
|
|
|
excelDatas: PropTypes.array.isRequired
|
|
|
|
|
excelDatas: PropTypes.array.isRequired,
|
|
|
|
|
isDisabled: PropTypes.bool.isRequired
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ExcelDownload;
|
|
|
|
|