From 7e9fb08e97df4f04e4d364384a35706c9537500f Mon Sep 17 00:00:00 2001 From: truthwing Date: Thu, 24 Apr 2025 14:40:53 +0900 Subject: [PATCH 1/2] =?UTF-8?q?children=20=EC=95=88=20=EB=84=A3=EB=8A=94?= =?UTF-8?q?=20=EA=B2=BD=EC=9A=B0=EB=8F=84=20=EB=82=98=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/business_components/src/ui/table/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index ae4960a03..60c457544 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -13,7 +13,7 @@ type UiTableProps = { onPageChange: (page: number) => void; className?: string; resetPageNo?: boolean; - children: React.ReactNode | undefined; + children?: React.ReactNode | undefined; } type UiHeadProps = { @@ -52,9 +52,12 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr : <>}
+ {children?children: {children ? children : } + } + {tableData.length > 0 ? tableData?.map((el: { [key: string]: any}, index) => ( From f115999101688446dfb2c5e496d7ca5960aff6ad Mon Sep 17 00:00:00 2001 From: truthwing Date: Thu, 24 Apr 2025 14:53:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=97=91=EC=85=80=20json=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/excel_download/index.tsx | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/packages/common/business_components/src/ui/excel_download/index.tsx b/packages/common/business_components/src/ui/excel_download/index.tsx index d1370b95c..48341bc12 100644 --- a/packages/common/business_components/src/ui/excel_download/index.tsx +++ b/packages/common/business_components/src/ui/excel_download/index.tsx @@ -1,16 +1,44 @@ import * as XLSX from 'xlsx'; type ExcelDownloadProps = { - data : JSON | JSON[]; - fileName : string; - sheetNameArray : string[]; + data: JSON | JSON[]; + fileName: string; + sheetNameArray: string[]; } -export const downloadExcel = ({ data, fileName = new Date().getTime().toString()+'.xlsx', sheetNameArray = ["Sheet1"] }: ExcelDownloadProps) => { - const worksheet = XLSX.utils.json_to_sheet(Array.isArray(data) ? data : [data]); - const workbook = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(workbook, worksheet, sheetNameArray[0]); - //let buffer = XLSX.write(workbook, { bookType: "xlsx", type: "buffer" }); - //XLSX.write(workbook, { bookType: "xlsx", type: "binary" }); - XLSX.writeFile(workbook, fileName+'.xlsx'); - }; \ No newline at end of file +export const downloadExcel = ({ data, fileName = new Date().getTime().toString() + '.xlsx', sheetNameArray = ["Sheet1"] }: ExcelDownloadProps) => { + const worksheet = XLSX.utils.json_to_sheet(Array.isArray(data) ? data : [data]); + const workbook = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(workbook, worksheet, sheetNameArray[0]); + //let buffer = XLSX.write(workbook, { bookType: "xlsx", type: "buffer" }); + //XLSX.write(workbook, { bookType: "xlsx", type: "binary" }); + XLSX.writeFile(workbook, fileName + '.xlsx'); +}; +export const filePicked=(oFile: File) =>{ + // Create A File Reader HTML5 + const reader = new FileReader(); + + // Ready The Event For When A File Gets Selected + reader.onload = function (e) { + const data = e.target?.result; + if (!data) { + console.error("Failed to read file: e.target.result is null"); + return; + } + const wb = XLSX.read(data, { type: 'binary' }); + // Loop Over Each Sheet + wb.SheetNames.forEach(function (sheetName) { + // Obtain The Current Row As CSV + const sheet = wb.Sheets[sheetName]; + if (sheet) { + const jsonXls = XLSX.utils.sheet_to_json(sheet); + console.log(jsonXls); + } else { + console.error(`Sheet "${sheetName}" is undefined.`); + } + }); + }; + + // Tell JS To Start Reading The File.. You could delay this if desired + reader.readAsBinaryString(oFile); +} \ No newline at end of file