Skip to content

Commit

Permalink
#129 added Save xml and html data options
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomFractals committed Aug 3, 2019
1 parent 72b2869 commit 6ec54c1
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 4 deletions.
103 changes: 103 additions & 0 deletions data/xml/data-set.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<html>

<head>
<meta charset="utf-8" />
<title>SheetJS Table Export</title>
</head>

<body>
<table>
<tr>
<td t="s" id="sjs-A1">Country</td>
<td t="s" id="sjs-B1">Last Name</td>
<td t="s" id="sjs-C1">Quarter</td>
<td t="s" id="sjs-D1">Sales</td>
</tr>
<tr>
<td t="s" id="sjs-A2">UK</td>
<td t="s" id="sjs-B2">Smith</td>
<td t="s" id="sjs-C2">Qtr 3</td>
<td t="n" id="sjs-D2">16753</td>
</tr>
<tr>
<td t="s" id="sjs-A3">USA</td>
<td t="s" id="sjs-B3">Johnson</td>
<td t="s" id="sjs-C3">Qtr 4</td>
<td t="n" id="sjs-D3">14808</td>
</tr>
<tr>
<td t="s" id="sjs-A4">UK</td>
<td t="s" id="sjs-B4">Williams</td>
<td t="s" id="sjs-C4">Qtr 2</td>
<td t="n" id="sjs-D4">10644</td>
</tr>
<tr>
<td t="s" id="sjs-A5">USA</td>
<td t="s" id="sjs-B5">Jones</td>
<td t="s" id="sjs-C5">Qtr 3</td>
<td t="n" id="sjs-D5">1390</td>
</tr>
<tr>
<td t="s" id="sjs-A6">USA</td>
<td t="s" id="sjs-B6">Brown</td>
<td t="s" id="sjs-C6">Qtr 4</td>
<td t="n" id="sjs-D6">4865</td>
</tr>
<tr>
<td t="s" id="sjs-A7">UK</td>
<td t="s" id="sjs-B7">Williams</td>
<td t="s" id="sjs-C7">Qtr 1</td>
<td t="n" id="sjs-D7">12438</td>
</tr>
<tr>
<td t="s" id="sjs-A8">UK</td>
<td t="s" id="sjs-B8">Johnson</td>
<td t="s" id="sjs-C8">Qtr 2</td>
<td t="n" id="sjs-D8">9339</td>
</tr>
<tr>
<td t="s" id="sjs-A9">USA</td>
<td t="s" id="sjs-B9">Smith</td>
<td t="s" id="sjs-C9">Qtr 3</td>
<td t="n" id="sjs-D9">18919</td>
</tr>
<tr>
<td t="s" id="sjs-A10">USA</td>
<td t="s" id="sjs-B10">Jones</td>
<td t="s" id="sjs-C10">Qtr 4</td>
<td t="n" id="sjs-D10">9213</td>
</tr>
<tr>
<td t="s" id="sjs-A11">UK</td>
<td t="s" id="sjs-B11">Jones</td>
<td t="s" id="sjs-C11">Qtr 1</td>
<td t="n" id="sjs-D11">7433</td>
</tr>
<tr>
<td t="s" id="sjs-A12">USA</td>
<td t="s" id="sjs-B12">Brown</td>
<td t="s" id="sjs-C12">Qtr 2</td>
<td t="n" id="sjs-D12">3255</td>
</tr>
<tr>
<td t="s" id="sjs-A13">USA</td>
<td t="s" id="sjs-B13">Williams</td>
<td t="s" id="sjs-C13">Qtr 3</td>
<td t="n" id="sjs-D13">14867</td>
</tr>
<tr>
<td t="s" id="sjs-A14">UK</td>
<td t="s" id="sjs-B14">Williams</td>
<td t="s" id="sjs-C14">Qtr 4</td>
<td t="n" id="sjs-D14">19302</td>
</tr>
<tr>
<td t="s" id="sjs-A15">USA</td>
<td t="s" id="sjs-B15">Smith</td>
<td t="s" id="sjs-C15">Qtr 1</td>
<td t="n" id="sjs-D15">9698</td>
</tr>
</table>
</body>

</html>
86 changes: 86 additions & 0 deletions data/xml/data-set.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"Last Name": "Smith",
"Sales": 16753,
"Country": "UK",
"Quarter": "Qtr 3"
},
{
"Last Name": "Johnson",
"Sales": 14808,
"Country": "USA",
"Quarter": "Qtr 4"
},
{
"Last Name": "Williams",
"Sales": 10644,
"Country": "UK",
"Quarter": "Qtr 2"
},
{
"Last Name": "Jones",
"Sales": 1390,
"Country": "USA",
"Quarter": "Qtr 3"
},
{
"Last Name": "Brown",
"Sales": 4865,
"Country": "USA",
"Quarter": "Qtr 4"
},
{
"Last Name": "Williams",
"Sales": 12438,
"Country": "UK",
"Quarter": "Qtr 1"
},
{
"Last Name": "Johnson",
"Sales": 9339,
"Country": "UK",
"Quarter": "Qtr 2"
},
{
"Last Name": "Smith",
"Sales": 18919,
"Country": "USA",
"Quarter": "Qtr 3"
},
{
"Last Name": "Jones",
"Sales": 9213,
"Country": "USA",
"Quarter": "Qtr 4"
},
{
"Last Name": "Jones",
"Sales": 7433,
"Country": "UK",
"Quarter": "Qtr 1"
},
{
"Last Name": "Brown",
"Sales": 3255,
"Country": "USA",
"Quarter": "Qtr 2"
},
{
"Last Name": "Williams",
"Sales": 14867,
"Country": "USA",
"Quarter": "Qtr 3"
},
{
"Last Name": "Williams",
"Sales": 19302,
"Country": "UK",
"Quarter": "Qtr 4"
},
{
"Last Name": "Smith",
"Sales": 9698,
"Country": "USA",
"Quarter": "Qtr 1"
}
]
Binary file added data/xml/data-set.xlsx
Binary file not shown.
2 changes: 2 additions & 0 deletions data/xml/data-set.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:html="http://www.w3.org/TR/REC-html40"><Styles><Style ss:ID="Default" ss:Name="Normal"><NumberFormat/></Style><Style ss:ID="s21"><NumberFormat ss:Format="General"/></Style></Styles><Worksheet ss:Name="Sheet1"><Table><Row ss:Index="1"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">Country</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Last Name</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Quarter</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="String">Sales</Data></Cell></Row><Row ss:Index="2"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">UK</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Smith</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 3</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">16753</Data></Cell></Row><Row ss:Index="3"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Johnson</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 4</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">14808</Data></Cell></Row><Row ss:Index="4"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">UK</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Williams</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 2</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">10644</Data></Cell></Row><Row ss:Index="5"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Jones</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 3</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">1390</Data></Cell></Row><Row ss:Index="6"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Brown</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 4</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">4865</Data></Cell></Row><Row ss:Index="7"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">UK</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Williams</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 1</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">12438</Data></Cell></Row><Row ss:Index="8"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">UK</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Johnson</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 2</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">9339</Data></Cell></Row><Row ss:Index="9"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Smith</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 3</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">18919</Data></Cell></Row><Row ss:Index="10"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Jones</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 4</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">9213</Data></Cell></Row><Row ss:Index="11"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">UK</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Jones</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 1</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">7433</Data></Cell></Row><Row ss:Index="12"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Brown</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 2</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">3255</Data></Cell></Row><Row ss:Index="13"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Williams</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 3</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">14867</Data></Cell></Row><Row ss:Index="14"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">UK</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Williams</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 4</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">19302</Data></Cell></Row><Row ss:Index="15"><Cell ss:StyleID="s21" ss:Index="1"><Data ss:Type="String">USA</Data></Cell><Cell ss:StyleID="s21" ss:Index="2"><Data ss:Type="String">Smith</Data></Cell><Cell ss:StyleID="s21" ss:Index="3"><Data ss:Type="String">Qtr 1</Data></Cell><Cell ss:StyleID="s21" ss:Index="4"><Data ss:Type="Number">9698</Data></Cell></Row></Table></Worksheet></Workbook>
15 changes: 15 additions & 0 deletions data/xml/schema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<LastName>Smith</LastName>
<Sales>16753</Sales>
<Country>UK</Country>
<Quarter>Qtr 3</Quarter>
</record>
<record>
<LastName>Johnson</LastName>
<Sales>14808</Sales>
<Country>USA</Country>
<Quarter>Qtr 4</Quarter>
</record>
</data-set>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-data-preview",
"displayName": "Data Preview",
"description": "Data Preview 🈸 extension for importing 📤 viewing 🔎 slicing 🔪 dicing 🎲 charting 📊 & exporting 📥 large JSON array/config, YAML, Apache Arrow, Avro & Excel data files",
"version": "1.28.0",
"version": "1.29.0",
"icon": "images/data-preview.png",
"publisher": "RandomFractalsInc",
"author": "Taras Novak a.k.a. dataPixy devTools maker :)",
Expand Down
12 changes: 9 additions & 3 deletions src/data.preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ export class DataPreview {
dataFilePath += `-${this._dataTable}`;
}

// add requested data file ext.
// add requested data file extension
dataFilePath += fileType;
this._logger.debug('saveData(): saving data file:', dataFilePath);

Expand Down Expand Up @@ -973,9 +973,15 @@ export class DataPreview {
case '.hjson':
fileData = hjson.stringify(fileData);
break;
case '.html':
fileData = this.jsonToExcelData(fileData, 'html');
break;
case '.ods':
fileData = this.jsonToExcelData(fileData, 'ods');
break;
fileData = this.jsonToExcelData(fileData, 'ods');
break;
case '.xml':
fileData = this.jsonToExcelData(fileData, 'xlml');
break;
case '.xlsb':
fileData = this.jsonToExcelData(fileData, 'xlsb');
break;
Expand Down
4 changes: 4 additions & 0 deletions templates/data.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@
<option value=".json">{} &nbsp;json</option>
<option value=".json5">{} &nbsp;json5</option>
<option value=".hjson">{} &nbsp;hjson</option>
<option value=".html">&lt;&gt;html</option>
<option value=".md">⇩ &nbsp;md</option>
<option value=".ods">⊞ ods</option>
<option value=".xml">&lt;&gt;xml</option>
<option value=".xlsb">⊞ xlsb</option>
<option value=".xlsx">⊞ xlsx</option>
<option value=".yml">&nbsp;!&nbsp; yml</option>
Expand Down Expand Up @@ -585,7 +587,9 @@
case '.json':
case '.json5':
case '.hjson':
case '.html':
case '.ods':
case '.xml':
case '.xlsb':
case '.xlsx':
case '.yml':
Expand Down

0 comments on commit 6ec54c1

Please sign in to comment.