excel export
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import * as XLSX from 'xlsx';
|
||||
import type { FoodOrderReportItem } from '../types/Types';
|
||||
|
||||
export const exportFoodOrderReportExcel = (items: FoodOrderReportItem[]) => {
|
||||
const rows = items.map((item) => ({
|
||||
غذا: item.food.title || '-',
|
||||
تعداد: item.count,
|
||||
قیمت: item.price,
|
||||
'جمع کل': item.totalPrice,
|
||||
}));
|
||||
|
||||
const worksheet = XLSX.utils.json_to_sheet(rows);
|
||||
const workbook = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, 'گزارش فروش غذا');
|
||||
|
||||
const fileName = `food-order-report-${new Date().toISOString().slice(0, 19).replace(/[:T]/g, '-')}.xlsx`;
|
||||
XLSX.writeFile(workbook, fileName);
|
||||
};
|
||||
Reference in New Issue
Block a user