Skip to content

Commit

Permalink
export data completed
Browse files Browse the repository at this point in the history
  • Loading branch information
adedolapoadegboye committed Aug 1, 2024
1 parent e0529eb commit d0ef168
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 158 deletions.
200 changes: 100 additions & 100 deletions public/Examples/example-3D.csv
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
Latitude,Longitude,Altitude
21.1803138,-114.1320062,1050
21.1803246,-114.1320920,1050
21.1803997,-114.1321993,1050
21.1805069,-114.1321564,1050
21.1801821,-114.1320062,1050
21.1803246,-114.1319847,1050
21.1803138,-114.1320276,1050
21.1803782,-114.1320705,1050
21.1807108,-114.1320705,1050
21.1801636,-114.1321349,1050
21.1804426,-114.1319847,1050
21.1803460,-114.1320491,1050
21.1803997,-114.1319203,1050
21.1803889,-114.1320062,1050
21.1803460,-114.1320062,1050
21.1802924,-114.1319418,1050
21.1804748,-114.1321993,1050
21.1801529,-114.1320276,1050
21.1802709,-114.1321778,1050
21.1803246,-114.1320491,1050
21.1803782,-114.1320062,1050
21.1802602,-114.1320920,1050
21.1803031,-114.1320276,1050
21.1802280,-114.1320491,1050
21.1802816,-114.1320062,1050
21.1802924,-114.1319633,1050
21.1803782,-114.1320920,1050
21.1803567,-114.1321349,1050
21.1805606,-114.1320062,1050
21.1803567,-114.1321564,1050
21.1804426,-114.1320920,1050
21.1801314,-114.1320705,1050
21.1802495,-114.1320062,1050
21.1804104,-114.1320705,1050
21.1803675,-114.1320705,1050
21.1802280,-114.1320491,1050
21.1803138,-114.1320062,1050
21.1802280,-114.1321993,1050
21.1804211,-114.1321778,1050
21.1803675,-114.1322422,1050
21.1801422,-114.1321564,1050
21.1803138,-114.1323280,1050
21.1801744,-114.1325212,1050
21.1803246,-114.1321564,1050
21.1804104,-114.1320062,1050
21.1802816,-114.1319847,1050
21.1803782,-114.1320276,1050
21.1802816,-114.1320705,1050
21.1802924,-114.1319203,1050
21.1802280,-114.1320062,1050
21.1803460,-114.1320491,1050
21.1802495,-114.1320491,1050
21.1803138,-114.1320920,1050
21.1803997,-114.1320705,1050
21.1804318,-114.1321564,1050
21.1803889,-114.1320705,1050
21.1804533,-114.1321135,1050
21.1801958,-114.1320062,1050
21.1802924,-114.1321778,1050
21.1803567,-114.1321135,1050
21.1803246,-114.1320062,1050
21.1802602,-114.1320491,1050
21.1803460,-114.1320062,1050
21.1803889,-114.1320491,1050
21.1802924,-114.1320705,1050
21.1803460,-114.1320062,1050
21.1802387,-114.1320491,1050
21.1803675,-114.1320276,1050
21.1802387,-114.1320705,1050
21.1803675,-114.1320276,1050
21.1803782,-114.1320062,1050
21.1803031,-114.1320062,1050
21.1803675,-114.1320491,1050
21.1802495,-114.1320062,1050
21.1802924,-114.1319203,1050
21.1803138,-114.1319847,1050
21.1803138,-114.1320705,1050
21.1802177,-114.1313839,1050
21.1803246,-114.1320062,1050
21.1802065,-114.1320705,1050
21.1803246,-114.1320276,1050
21.1803031,-114.1321135,1050
21.1803567,-114.1320491,1050
21.1802924,-114.1320062,1050
21.1803353,-114.1319847,1050
21.1803460,-114.1320491,1050
21.1805284,-114.1321564,1050
21.1804104,-114.1320920,1050
21.1803997,-114.1321349,1050
21.1800671,-114.1319633,1050
21.1801744,-114.1319847,1050
21.1803246,-114.1320276,1050
21.1802065,-114.1320705,1050
21.1802924,-114.1321135,1050
21.1802602,-114.1319418,1050
21.1801207,-114.1319418,1050
21.1802495,-114.1319418,1050
21.1801314,-114.1320491,1050
21.1802924,-114.1320491,1050
21.1802924,-114.1320276,1050
51.1803138,-114.1320062,1050
51.1803246,-114.1320920,1050
51.1803997,-114.1351993,1050
51.1805069,-114.1351564,1050
51.1801851,-114.1320062,1050
51.1803246,-114.1319847,1050
51.1803138,-114.1320276,1050
51.1803782,-114.1320705,1050
51.1807108,-114.1320705,1050
51.1801636,-114.1351349,1050
51.1804426,-114.1319847,1050
51.1803460,-114.1320491,1050
51.1803997,-114.1319203,1050
51.1803889,-114.1320062,1050
51.1803460,-114.1320062,1050
51.1802924,-114.1319418,1050
51.1804748,-114.1351993,1050
51.1801529,-114.1320276,1050
51.1802709,-114.1351778,1050
51.1803246,-114.1320491,1050
51.1803782,-114.1320062,1050
51.1802602,-114.1320920,1050
51.1803031,-114.1320276,1050
51.1802280,-114.1320491,1050
51.1802816,-114.1320062,1050
51.1802924,-114.1319633,1050
51.1803782,-114.1320920,1050
51.1803567,-114.1351349,1050
51.1805606,-114.1320062,1050
51.1803567,-114.1351564,1050
51.1804426,-114.1320920,1050
51.1801314,-114.1320705,1050
51.1802495,-114.1320062,1050
51.1804104,-114.1320705,1050
51.1803675,-114.1320705,1050
51.1802280,-114.1320491,1050
51.1803138,-114.1320062,1050
51.1802280,-114.1351993,1050
51.1804511,-114.1351778,1050
51.1803675,-114.1322422,1050
51.1801422,-114.1351564,1050
51.1803138,-114.1323280,1050
51.1801744,-114.1325512,1050
51.1803246,-114.1351564,1050
51.1804104,-114.1320062,1050
51.1802816,-114.1319847,1050
51.1803782,-114.1320276,1050
51.1802816,-114.1320705,1050
51.1802924,-114.1319203,1050
51.1802280,-114.1320062,1050
51.1803460,-114.1320491,1050
51.1802495,-114.1320491,1050
51.1803138,-114.1320920,1050
51.1803997,-114.1320705,1050
51.1804318,-114.1351564,1050
51.1803889,-114.1320705,1050
51.1804533,-114.1351135,1050
51.1801958,-114.1320062,1050
51.1802924,-114.1351778,1050
51.1803567,-114.1351135,1050
51.1803246,-114.1320062,1050
51.1802602,-114.1320491,1050
51.1803460,-114.1320062,1050
51.1803889,-114.1320491,1050
51.1802924,-114.1320705,1050
51.1803460,-114.1320062,1050
51.1802387,-114.1320491,1050
51.1803675,-114.1320276,1050
51.1802387,-114.1320705,1050
51.1803675,-114.1320276,1050
51.1803782,-114.1320062,1050
51.1803031,-114.1320062,1050
51.1803675,-114.1320491,1050
51.1802495,-114.1320062,1050
51.1802924,-114.1319203,1050
51.1803138,-114.1319847,1050
51.1803138,-114.1320705,1050
51.1805177,-114.1313839,1050
51.1803246,-114.1320062,1050
51.1802065,-114.1320705,1050
51.1803246,-114.1320276,1050
51.1803031,-114.1351135,1050
51.1803567,-114.1320491,1050
51.1802924,-114.1320062,1050
51.1803353,-114.1319847,1050
51.1803460,-114.1320491,1050
51.1805284,-114.1351564,1050
51.1804104,-114.1320920,1050
51.1803997,-114.1351349,1050
51.1800671,-114.1319633,1050
51.1801744,-114.1319847,1050
51.1803246,-114.1320276,1050
51.1802065,-114.1320705,1050
51.1802924,-114.1351135,1050
51.1802602,-114.1319418,1050
51.1801207,-114.1319418,1050
51.1802495,-114.1319418,1050
51.1801314,-114.1320491,1050
51.1802924,-114.1320491,1050
51.1802924,-114.1320276,1050
Binary file modified public/Examples/example-3D.xlsx
Binary file not shown.
44 changes: 38 additions & 6 deletions src/Dev/Components/Visualizers/DataExports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const DataExports = (props) => {
altPlotData,
} = props;

const exportToExcel = () => {
const exportToExcelAndKml = () => {
// Data for the second sheet
const fileData = file.data.map((item, index) => {
const dataEntry = {
Expand Down Expand Up @@ -77,7 +77,7 @@ const DataExports = (props) => {

// Create the second sheet and append it to the workbook
const ws2 = XLSX.utils.json_to_sheet(fileData);
XLSX.utils.book_append_sheet(workbook, ws2, "File Data");
XLSX.utils.book_append_sheet(workbook, ws2, "Data");

// Write the workbook to a binary string
const excelBuffer = XLSX.write(workbook, {
Expand All @@ -86,23 +86,55 @@ const DataExports = (props) => {
});

// Create a Blob object from the binary string
const blob = new Blob([excelBuffer], { type: "application/octet-stream" });
const excelBlob = new Blob([excelBuffer], {
type: "application/octet-stream",
});

// Generate a timestamp for the filename
const timestamp = new Date()
.toISOString()
.replace(/[-:T.]/g, "")
.slice(0, 14);

// Trigger the file download
saveAs(blob, `data_results_${timestamp}.xlsx`);
// Trigger the file download for the Excel file
saveAs(excelBlob, `data_results_${timestamp}.xlsx`);

// Generate KML content
const kmlContent = `<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Position Fixes</name>
<description>Position Fixes from GNSS Data</description>
${fileData
.map(
(item, index) => `
<Placemark>
<name>Fix ${index}</name>
<Point>
<coordinates>${item.Longitude},${item.Latitude},${
item.Altitude ? item.Altitude : 0
}</coordinates>
</Point>
</Placemark>`
)
.join("")}
</Document>
</kml>`;

// Create a Blob object for the KML file
const kmlBlob = new Blob([kmlContent], {
type: "application/vnd.google-earth.kml+xml",
});

// Trigger the file download for the KML file
saveAs(kmlBlob, `data_results_${timestamp}.kml`);
};

return (
<div>
<button
className="h-fit w-fit px-6 py-3 border bg-gray-700 rounded-2xl text-white transition duration-300 ease-in-out hover:bg-blue-500"
onClick={exportToExcel}
onClick={exportToExcelAndKml}
>
Download Results
</button>
Expand Down
52 changes: 0 additions & 52 deletions src/Dev/Functions/ExportToExcel.jsx

This file was deleted.

0 comments on commit d0ef168

Please sign in to comment.