엑셀 업로드
async function uploadMembersEnrollmentsExcel(e: any) {
const { files } = e.target;
if (!uploadExcelValidation(files)) return;
try {
const uint8ArrayExcel: Uint8Array = (await excelToUint8Array(files[0])) as Uint8Array;
}
function excelToUint8Array(file: File) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (e: any) => {
const arrayBuffer = e.target.result as ArrayBuffer;
const uint8Array = new Uint8Array(arrayBuffer);
resolve(uint8Array);
};
reader.onerror = (error) => {
reject(error);
};
reader.readAsArrayBuffer(file);
});
}
엑셀 다운로드
function excelDownload(fileName: string, fileContent: Uint8Array) {
const url = window.URL.createObjectURL(new Blob([fileContent]));
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", `${fileName}`);
document.body.appendChild(link);
link.click();
}