Merge commit '235f4bdb2966461271e0b703c4bdfed23834ffea' into iipbs/wr/form_fuction
This commit is contained in:
@@ -14,6 +14,9 @@ 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, headerNum:number=0):Promise<JSON | undefined> =>{
|
||||
// Create A File Reader HTML5
|
||||
const reader = new FileReader();
|
||||
@@ -28,10 +31,13 @@ export const filePicked=(oFile: File, headerNum:number=0):Promise<JSON | undefin
|
||||
}
|
||||
const wb = XLSX.read(data, { type: 'binary' });
|
||||
let jsonXls: JSON | undefined;
|
||||
|
||||
//TODO 시트가 2개이상일 경우 마지막 시트의 데이터만 표출됨
|
||||
// Loop Over Each Sheet
|
||||
wb.SheetNames.forEach(function (sheetName) {
|
||||
// Obtain The Current Row As CSV
|
||||
const sheet = wb.Sheets[sheetName];
|
||||
|
||||
if (sheet) {
|
||||
jsonXls = XLSX.utils.sheet_to_json(sheet, { range: headerNum }) as unknown as JSON;
|
||||
} else {
|
||||
|
||||
@@ -6,14 +6,22 @@ const dropZoneConfig = {
|
||||
maxSize: 1024 * 1024 * 4,
|
||||
multiple: true,
|
||||
};
|
||||
|
||||
|
||||
interface FileUploadProps {
|
||||
files: File[]; // 파일 배열
|
||||
setFiles: (files: File[] | null) => void; // 파일 배열 세터
|
||||
fileTypes?: string; // 옵션 (파일 확장자 문자열)
|
||||
}
|
||||
|
||||
export const FileUpload =
|
||||
(({ ...props }) => {
|
||||
({ files, setFiles, fileTypes }: FileUploadProps) => {
|
||||
return (
|
||||
<FileUploader
|
||||
value={props.files}
|
||||
onValueChange={props.setFiles}
|
||||
value={files}
|
||||
onValueChange={setFiles}
|
||||
dropzoneOptions={dropZoneConfig}
|
||||
acceptName={props?.fileTypes}
|
||||
acceptName={fileTypes}
|
||||
className="relative bg-background rounded-lg p-2"
|
||||
>
|
||||
<FileInput
|
||||
@@ -23,18 +31,18 @@ export const FileUpload =
|
||||
<div className="flex items-center justify-center flex-col p-8 w-full ">
|
||||
<CloudUpload className='text-gray-500 w-10 h-10' />
|
||||
<p className="mb-1 text-sm text-gray-500 dark:text-gray-400">
|
||||
<span className="font-semibold">Click to upload</span>
|
||||
or drag and drop
|
||||
<span className="font-semibold">클릭 후 업로드 </span>
|
||||
혹은 파일을 드래그 해주세요
|
||||
</p>
|
||||
<p className="text-xs text-gray-500 dark:text-gray-400">
|
||||
{!props?.fileTypes?"SVG, PNG, JPG, GIF":props?.fileTypes}
|
||||
{!fileTypes?"SVG, PNG, JPG, GIF":fileTypes}
|
||||
</p>
|
||||
</div>
|
||||
</FileInput>
|
||||
<FileUploaderContent>
|
||||
{props.files &&
|
||||
props.files.length > 0 &&
|
||||
props.files.map((file:File, i:number) => (
|
||||
{files&&
|
||||
files.length > 0 &&
|
||||
files.map((file:File, i:number) => (
|
||||
<FileUploaderItem key={i} index={i}>
|
||||
<Paperclip className="h-4 w-4 stroke-current" />
|
||||
<span>{file.name}</span>
|
||||
@@ -43,4 +51,4 @@ export const FileUpload =
|
||||
</FileUploaderContent>
|
||||
</FileUploader>
|
||||
)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user