Skip to content

Data Explorer: Add support for opening .xlsx files #7366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions extensions/positron-duckdb/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/positron-duckdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"vsce": "^2.11.0"
},
"dependencies": {
"@duckdb/duckdb-wasm": "1.29.0",
"@duckdb/duckdb-wasm": "1.29.1-dev68.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on a dev version here feels a bit icky to me, however the last non-dev release of duckdb-wasm, 1.29.0, was October 2024, so the next release may not be for a while. I can ask the duckdb folks what they think about shipping a dev version to production to see. I also just learned about https://duckdb.org/docs/stable/clients/node_neo/overview.html which would enable us to get off of wasm altogether which might be a preferable path

"apache-arrow": "^16.0.0",
"web-worker": "^1.3.0"
},
Expand Down
6 changes: 6 additions & 0 deletions extensions/positron-duckdb/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,12 @@ export class DataExplorerRpcHandler {
const query = `CREATE OR REPLACE TABLE ${catalogName} AS
SELECT * FROM parquet_scan('${virtualPath}');`;
await this.db.runQuery(query);
} else if (baseExt === '.xlsx') {
await this.db.runQuery('INSTALL excel FROM core_nightly;');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this "phones home" to load the extension from duckdb.org (http://nightly-extensions.duckdb.org, see https://duckdb.org/docs/stable/extensions/installing_extensions.html), it might fail in some environments where Positron isn't able to access the public internet, but that seems like an acceptable caveat until we sort out how to bundle supported DuckDB extensions with Positron to avoid installing from the internet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good callout.

await this.db.runQuery('LOAD excel;');
await this.db.runQuery(
`CREATE OR REPLACE TABLE ${catalogName} AS SELECT * FROM read_xlsx('${virtualPath}');`
);
} else {
await importDelimited(virtualPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PositronDataExplorerContribution extends Disposable {
}
));

const DUCKDB_SUPPORTED_EXTENSIONS = ['parquet', 'parq', 'csv', 'tsv', 'gz'];
const DUCKDB_SUPPORTED_EXTENSIONS = ['parquet', 'parq', 'csv', 'tsv', 'xlsx', 'gz'];

this._register(editorResolverService.registerEditor(
`*.{${DUCKDB_SUPPORTED_EXTENSIONS.join(',')}}`,
Expand Down
Loading