diff options
Diffstat (limited to 'lib/procurement-items/table/procurement-items-excel-template.tsx')
| -rw-r--r-- | lib/procurement-items/table/procurement-items-excel-template.tsx | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/lib/procurement-items/table/procurement-items-excel-template.tsx b/lib/procurement-items/table/procurement-items-excel-template.tsx new file mode 100644 index 00000000..d72af26a --- /dev/null +++ b/lib/procurement-items/table/procurement-items-excel-template.tsx @@ -0,0 +1,101 @@ +import * as ExcelJS from 'exceljs';
+import { saveAs } from "file-saver";
+
+/**
+ * 품목 데이터 가져오기를 위한 Excel 템플릿 파일 생성 및 다운로드
+ */
+export async function exportProcurementItemTemplate() {
+ // 워크북 생성
+ const workbook = new ExcelJS.Workbook();
+ workbook.creator = 'Procurement Item Management System';
+ workbook.created = new Date();
+
+ // 워크시트 생성
+ const worksheet = workbook.addWorksheet('품목');
+
+ // 컬럼 헤더 정의 및 스타일 적용
+ worksheet.columns = [
+ { header: '품목코드', key: 'itemCode', width: 15 },
+ { header: '품목명', key: 'itemName', width: 30 },
+ { header: '재질', key: 'material', width: 20 },
+ { header: '규격', key: 'specification', width: 25 },
+ { header: '단위', key: 'unit', width: 10 },
+ { header: '활성화여부', key: 'isActive', width: 12 },
+ ];
+
+ // 헤더 스타일 적용
+ const headerRow = worksheet.getRow(1);
+ headerRow.font = { bold: true };
+ headerRow.fill = {
+ type: 'pattern',
+ pattern: 'solid',
+ fgColor: { argb: 'FFE0E0E0' }
+ };
+ headerRow.alignment = { vertical: 'middle', horizontal: 'center' };
+
+ // 테두리 스타일 적용
+ headerRow.eachCell((cell) => {
+ cell.border = {
+ top: { style: 'thin' },
+ left: { style: 'thin' },
+ bottom: { style: 'thin' },
+ right: { style: 'thin' }
+ };
+ });
+
+ // 샘플 데이터 행 추가
+ const sampleRow = worksheet.addRow({
+ itemCode: 'ITEM001',
+ itemName: '강관',
+ material: 'SS400',
+ specification: '50x50x2.3T',
+ unit: 'EA',
+ isActive: 'Y'
+ });
+
+ // 샘플 행 스타일 적용
+ sampleRow.eachCell((cell) => {
+ cell.fill = {
+ type: 'pattern',
+ pattern: 'solid',
+ fgColor: { argb: 'FFF5F5F5' }
+ };
+ cell.border = {
+ top: { style: 'thin' },
+ left: { style: 'thin' },
+ bottom: { style: 'thin' },
+ right: { style: 'thin' }
+ };
+ });
+
+ // 설명 행 추가
+ const descriptionRow = worksheet.addRow([
+ '※ 품목코드: 필수, 중복 불가',
+ '※ 품목명: 필수',
+ '※ 재질: 선택사항',
+ '※ 규격: 선택사항',
+ '※ 단위: 선택사항 (예: EA, M, KG)',
+ '※ 활성화여부: Y(활성) 또는 N(비활성)'
+ ]);
+
+ descriptionRow.font = { italic: true, color: { argb: 'FF666666' } };
+ descriptionRow.eachCell((cell) => {
+ cell.fill = {
+ type: 'pattern',
+ pattern: 'solid',
+ fgColor: { argb: 'FFFFE0E0' }
+ };
+ });
+
+ // 워크시트 설정
+ worksheet.views = [
+ { state: 'frozen', ySplit: 1 } // 헤더 행 고정
+ ];
+
+ // 파일 저장
+ const buffer = await workbook.xlsx.writeBuffer();
+ const blob = new Blob([buffer], {
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
+ });
+ saveAs(blob, 'procurement_items_template.xlsx');
+}
|
