From 3687fe98cee4fda9fa67ccd41176fcd58e0440aa Mon Sep 17 00:00:00 2001 From: tore Date: Thu, 3 Sep 2026 19:11:19 +0000 Subject: [PATCH] add export to Excel --- index.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/index.html b/index.html index 45d0cf0..6c571c8 100644 --- a/index.html +++ b/index.html @@ -87,6 +87,7 @@
0 записей +
@@ -193,6 +194,28 @@ function clearHistory() { } } +function exportCsv() { + const history = getHistory(); + if (history.length === 0) { + alert('История пуста — нечего выгружать'); + return; + } + const head = ['Дата', 'Оборудование', 'Срок (мес)', 'Количество (шт)', 'Скидка (%)', 'Сумма (₸)']; + const body = history.map(r => [ + r.date, + r.equipment, + r.months, + r.quantity, + r.discount, + r.total + ].map(v => '"' + String(v ?? '').replace(/"/g, '""') + '"').join(';')); + const csv = '\uFEFF' + [head.join(';'), ...body].join('\n'); + const a = document.createElement('a'); + a.href = URL.createObjectURL(new Blob([csv], { type: 'text/csv; charset=utf-8' })); + a.download = 'istoriya_arendy.csv'; + a.click(); +} + function renderHistory() { const history = getHistory(); const tbody = document.getElementById('historyTable');