Skip to content

Commit

Permalink
Merge pull request #311 from tom-writes-code/feature/left-align-table…
Browse files Browse the repository at this point in the history
…-data

Left align table headers and data on exported data
  • Loading branch information
worksofliam authored Jan 7, 2025
2 parents 82e13c0 + 8a0a877 commit 1d028cd
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/notebooks/logic/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,38 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
}

if (fallbackToTable) {
cellContents.push([
`<table style="width: 100%; margin-left: auto; margin-right: auto;">`,
`<thead>`,
`<tr>`,
columns.map(c => `<th>${c}</th>`).join(``),
`</tr>`,
`</thead>`,
`<tbody>`,
table.map(row => {
return [
`<tr>`,
keys.map(key => `<td>${row[key]}</td>`).join(``),
`</tr>`
].join(``);
}).join(``),
`</tbody>`,
`</table>`
].join(``));
cellContents.push(
[
`<table style="width: 100%; margin-left: auto; margin-right: auto;">`,
`<thead>`,
`<tr>`,
columns
.map(
(c) =>
`<th style="text-align: left;">${c}</th>`
)
.join(``),
`</tr>`,
`</thead>`,
`<tbody>`,
table
.map((row) => {
return [
`<tr>`,
keys
.map(
(key) =>
`<td style="text-align: left;">${row[key]}</td>`
)
.join(``),
`</tr>`,
].join(``);
})
.join(``),
`</tbody>`,
`</table>`,
].join(``)
);
}
} else {
// items.push(vscode.NotebookCellOutputItem.stderr(`No rows returned from statement.`));
Expand Down

0 comments on commit 1d028cd

Please sign in to comment.