Merge commit 'fb307527b6837120e52301298041595bb4ee924b' into iipbs/wr/dev
iipbs_wr / build (push) Waiting to run

This commit is contained in:
truthwing
2025-04-24 15:28:52 +09:00
3 changed files with 47 additions and 38 deletions
@@ -14,7 +14,7 @@ export const downloadExcel = ({ data, fileName = new Date().getTime().toString()
//XLSX.write(workbook, { bookType: "xlsx", type: "binary" });
XLSX.writeFile(workbook, fileName + '.xlsx');
};
export const filePicked=(oFile: File) =>{
export const filePicked=(oFile: File, headerNum:number=0) =>{
// Create A File Reader HTML5
const reader = new FileReader();
@@ -31,7 +31,7 @@ export const filePicked=(oFile: File) =>{
// Obtain The Current Row As CSV
const sheet = wb.Sheets[sheetName];
if (sheet) {
const jsonXls = XLSX.utils.sheet_to_json(sheet);
const jsonXls = XLSX.utils.sheet_to_json(sheet, {range:headerNum});
console.log(jsonXls);
} else {
console.error(`Sheet "${sheetName}" is undefined.`);
@@ -12,41 +12,53 @@ interface TableUpperProps {
const HeadMakeColSpan = ({ upHeadList }: { upHeadList: TableUpperProps[] }) => {
const maxRow = upHeadList.reduce((max, head) => Math.max(max, head.row || 0), 0);
return (
<>
{Array.from({ length: maxRow + 1 }, (_, rowIndex) => (
<TableRow key={rowIndex+ " headerRow"} className="bg-gray-50">
if(maxRow == 0){
return (
<>
<TableRow className="bg-gray-50">
{upHeadList.map((head: TableUpperProps) => {
if (head.row === rowIndex) {
return (
<TableHead
key={head.id}
colSpan={head.colSpan || 1}
rowSpan={head.rowSpan || 1}
style={{ whiteSpace: 'pre-line' }}
className="bg-gray-50"
>
{head.title}
</TableHead>
);
}else{
return (
<TableHead
key={head.id}
colSpan={head.colSpan || 1}
rowSpan={head.rowSpan || 1}
style={{ whiteSpace: 'pre-line' }}
className="bg-gray-50"
>
{head.title}
</TableHead>
);
}
})}
return (
<TableHead
key={head.id}
colSpan={head.colSpan || 1}
rowSpan={head.rowSpan || 1}
style={{ whiteSpace: 'pre-line' }}
className="bg-gray-50"
>
{head.title}
</TableHead>
);
})}
</TableRow>
))}
</>
);
</>
);
}else{
return (
<>
{Array.from({ length: maxRow + 1 }, (_, rowIndex) => (
<TableRow key={rowIndex+ " headerRow"} className="bg-gray-50">
{upHeadList.map((head: TableUpperProps) => {
if (head.row === rowIndex) {
return (
<TableHead
key={head.id}
colSpan={head.colSpan || 1}
rowSpan={head.rowSpan || 1}
style={{ whiteSpace: 'pre-line' }}
className="bg-gray-50"
>
{head.title}
</TableHead>
);
}
})}
</TableRow>
))}
</>
);
}
}
export { HeadMakeColSpan };
@@ -52,12 +52,9 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
</div> : <></>}
<div className={`card !m-[1.2rem] !p-0r ${className}`}>
<Table variant="secondary">
{children?children:
<TableHeader className="font-bold">
{children ? children : <HeadMakeColSpan upHeadList={headlist} />}
</TableHeader>
}
<TableBody className='text-center'>
{tableData.length > 0 ? tableData?.map((el: { [key: string]: any}, index) => (
<TableRow key={`row-${index}`}>