From 90aa94f61bab2a568f5d0bfb28250d804c6cf2be Mon Sep 17 00:00:00 2001 From: RandomFractals <RandomFractals@users.noreply.github.com> Date: Fri, 24 Dec 2021 11:18:06 -0600 Subject: [PATCH] add save as html table data UI option (#26) --- CHANGELOG.md | 2 ++ README.md | 2 +- src/views/tableView.ts | 1 + web/scripts/tableView.js | 10 +++++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5970ec8..380481f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,3 +48,5 @@ Add hide, freeze, and delete column context menu options Add data loading progress ring display - [#25](https://github.com/RandomFractals/tabular-data-viewer/issues/25) Add Save as CSV or JSON data UI options +- [#26](https://github.com/RandomFractals/tabular-data-viewer/issues/26) +Add Save as HTML data table UI option diff --git a/README.md b/README.md index 71ac38c..29af59b 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Tabular Data Viewer 🀄 provides custom Table View for `.csv`, `.tsv` and `.tab - Freeze or delete table rows - Perisist table settings per data file - Copy table data to Clipboard -- Save table data in `CSV` or `JSON` data array format +- Save table data in `CSV`, `HTML` table, or `JSON` data array format ... diff --git a/src/views/tableView.ts b/src/views/tableView.ts index 9dfc0f2..a32e9c8 100644 --- a/src/views/tableView.ts +++ b/src/views/tableView.ts @@ -351,6 +351,7 @@ export class TableView { <option value="">📥 Save</option> <option value="csv">,,, csv</option> <option value="json">{} json</option> + <option value="html"><> html</option> </select> <vscode-button id="reload-button" appearance="icon" aria-label="Reload Data"> diff --git a/web/scripts/tableView.js b/web/scripts/tableView.js index 46158fa..4d91d33 100644 --- a/web/scripts/tableView.js +++ b/web/scripts/tableView.js @@ -254,7 +254,15 @@ function saveData() { const dataFileName = fileName.substring(0, fileName.lastIndexOf('.') + 1); saveDataFileName = dataFileName + dataFileType; console.log('tabView:saveData(): saving data:', saveDataFileName); - table.download(dataFileType, saveDataFileName); + switch (dataFileType) { + case 'csv': + case 'json': + table.download(dataFileType, saveDataFileName); + break; + case 'html': + table.download(dataFileType, saveDataFileName, { style: true}); + break; + } } /**