Persist photos in Excel export/import
- Add Photo column to export (base64 data URL) - Read Photo column on import and restore flag.photoData
This commit is contained in:
@@ -642,6 +642,9 @@ document.getElementById('file-input').addEventListener('change', async (e) => {
|
|||||||
if (!String(name).trim()) continue;
|
if (!String(name).trim()) continue;
|
||||||
const flag = addFlag(String(name).trim(), String(number).trim());
|
const flag = addFlag(String(name).trim(), String(number).trim());
|
||||||
|
|
||||||
|
const photo = row.Photo || row.photo || '';
|
||||||
|
if (String(photo).startsWith('data:')) flag.photoData = String(photo);
|
||||||
|
|
||||||
let lat = parseFloat(row.Latitude || row.latitude || row.위도);
|
let lat = parseFloat(row.Latitude || row.latitude || row.위도);
|
||||||
let lng = parseFloat(row.Longitude || row.longitude || row.경도);
|
let lng = parseFloat(row.Longitude || row.longitude || row.경도);
|
||||||
if (!isNaN(lat) && !isNaN(lng)) {
|
if (!isNaN(lat) && !isNaN(lng)) {
|
||||||
@@ -686,10 +689,11 @@ document.getElementById('export-btn').addEventListener('click', () => {
|
|||||||
Number: f.number, Name: f.name,
|
Number: f.number, Name: f.name,
|
||||||
Status: f.placed ? 'Placed' : 'Unplaced',
|
Status: f.placed ? 'Placed' : 'Unplaced',
|
||||||
Latitude: f.lat ?? '', Longitude: f.lng ?? '', Address: f.address ?? '',
|
Latitude: f.lat ?? '', Longitude: f.lng ?? '', Address: f.address ?? '',
|
||||||
|
Photo: f.photoData ?? '',
|
||||||
}));
|
}));
|
||||||
const wb = XLSX.utils.book_new();
|
const wb = XLSX.utils.book_new();
|
||||||
const ws = XLSX.utils.json_to_sheet(rows);
|
const ws = XLSX.utils.json_to_sheet(rows);
|
||||||
ws['!cols'] = [{ wch: 12 }, { wch: 20 }, { wch: 10 }, { wch: 12 }, { wch: 12 }, { wch: 60 }];
|
ws['!cols'] = [{ wch: 12 }, { wch: 20 }, { wch: 10 }, { wch: 12 }, { wch: 12 }, { wch: 60 }, { wch: 30 }];
|
||||||
XLSX.utils.book_append_sheet(wb, ws, 'Flags');
|
XLSX.utils.book_append_sheet(wb, ws, 'Flags');
|
||||||
XLSX.writeFile(wb, 'flag_export.xlsx');
|
XLSX.writeFile(wb, 'flag_export.xlsx');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user