Skip to content

Commit

Permalink
add save as html table data UI option (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomFractals committed Dec 24, 2021
1 parent 9d9e3f1 commit 90aa94f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

...

Expand Down
1 change: 1 addition & 0 deletions src/views/tableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export class TableView {
<option value="">📥&nbsp;Save</option>
<option value="csv">,,, csv</option>
<option value="json">{} &nbsp;json</option>
<option value="html">&lt;&gt; &nbsp;html</option>
</select>
<vscode-button id="reload-button"
appearance="icon" aria-label="Reload Data">
Expand Down
10 changes: 9 additions & 1 deletion web/scripts/tableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down

0 comments on commit 90aa94f

Please sign in to comment.