diff --git a/src/modules/mileage/xlsx-export.ts b/src/modules/mileage/xlsx-export.ts index dd413f2..18ee534 100644 --- a/src/modules/mileage/xlsx-export.ts +++ b/src/modules/mileage/xlsx-export.ts @@ -20,9 +20,9 @@ function mileageCell(v: MonitoringVehicle, kind: 'today' | 'total'): string | nu if (kind === 'today') { // 当日未对接但有历史累计,视作今日 0;只有完全无数据才标「未对接」 if (!v.isDataSynced && v.totalKm == null) return '未对接'; - return Math.max(0, Math.round(v.dailyKm || 0)); + return Math.max(0, v.dailyKm || 0); } - return v.totalKm != null ? Math.round(v.totalKm) : '未对接'; + return v.totalKm != null ? v.totalKm : '未对接'; } export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportContext): void { @@ -57,6 +57,13 @@ export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportCont ws['!freeze'] = { xSplit: 0, ySplit: 1 } as never; + for (let r = 1; r < data.length; r++) { + for (const c of [7, 8]) { + const ref = XLSX.utils.encode_cell({ r, c }); + if (ws[ref]?.t === 'n') ws[ref].z = '0.##########'; + } + } + // 表头样式(在客户端 SheetJS 社区版仅基本样式生效) for (let c = 0; c < HEADERS.length; c++) { const ref = XLSX.utils.encode_cell({ r: 0, c });