260205_01_ENH: 페이지 별 엑셀 다운로드 적용

This commit is contained in:
2026-02-05 09:24:19 +09:00
parent 544f3010aa
commit 3e7c2a98df
25 changed files with 2500 additions and 336 deletions

View File

@@ -1,7 +1,7 @@
"use client";
import { useMemo } from "react";
import { PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING } from "@/const/lgConst";
import {useEffect, useMemo} from "react";
import {PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING, LAST_YEAR, PRODUCT_KEY_MAP} from "@/const/lgConst";
import {
type ChartData,
signStyleGapRow,
@@ -12,9 +12,10 @@ import {
import { apiTrendBuy } from "@/config/sample.data";
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
import { formatRowLabel } from "@/lib/lg-dashboard";
import {buildHeader_ProductKeyMap, exportDashboardExcel} from "@/lib/lg-export-excel";
const PurchasePage = () => {
const { isTotal, filterValue } = useLayoutFilter();
const { isTotal, filterValue, registerExcelExporter } = useLayoutFilter();
console.log(filterValue);
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
@@ -36,6 +37,21 @@ const PurchasePage = () => {
};
}, []);
useEffect(() => {
registerExcelExporter(async (payload) => {
const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP);
await exportDashboardExcel({
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(구매율).xlsx`,
sheetName: "구매율",
sections: [
{ title: "구매율", header: excelHeader, rows: apiTrendBuy, rowGap: 1 },
],
});
});
return () => registerExcelExporter(null);
}, [registerExcelExporter]);
return (
<div>
<TopChartTable