Skip to content

Commit 1d028cd

Browse files
authored
Merge pull request #311 from tom-writes-code/feature/left-align-table-data
Left align table headers and data on exported data
2 parents 82e13c0 + 8a0a877 commit 1d028cd

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

src/notebooks/logic/export.ts

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,38 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
114114
}
115115

116116
if (fallbackToTable) {
117-
cellContents.push([
118-
`<table style="width: 100%; margin-left: auto; margin-right: auto;">`,
119-
`<thead>`,
120-
`<tr>`,
121-
columns.map(c => `<th>${c}</th>`).join(``),
122-
`</tr>`,
123-
`</thead>`,
124-
`<tbody>`,
125-
table.map(row => {
126-
return [
127-
`<tr>`,
128-
keys.map(key => `<td>${row[key]}</td>`).join(``),
129-
`</tr>`
130-
].join(``);
131-
}).join(``),
132-
`</tbody>`,
133-
`</table>`
134-
].join(``));
117+
cellContents.push(
118+
[
119+
`<table style="width: 100%; margin-left: auto; margin-right: auto;">`,
120+
`<thead>`,
121+
`<tr>`,
122+
columns
123+
.map(
124+
(c) =>
125+
`<th style="text-align: left;">${c}</th>`
126+
)
127+
.join(``),
128+
`</tr>`,
129+
`</thead>`,
130+
`<tbody>`,
131+
table
132+
.map((row) => {
133+
return [
134+
`<tr>`,
135+
keys
136+
.map(
137+
(key) =>
138+
`<td style="text-align: left;">${row[key]}</td>`
139+
)
140+
.join(``),
141+
`</tr>`,
142+
].join(``);
143+
})
144+
.join(``),
145+
`</tbody>`,
146+
`</table>`,
147+
].join(``)
148+
);
135149
}
136150
} else {
137151
// items.push(vscode.NotebookCellOutputItem.stderr(`No rows returned from statement.`));

0 commit comments

Comments
 (0)