Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(import): read legacy Excel sheet names with Calamine

t8y2fcedfef63d32
diff --git a/crates/dbx-core/src/table_import.rs b/crates/dbx-core/src/table_import.rs
index cbef4b3794..cba2159807 100644
--- a/crates/dbx-core/src/table_import.rs
+++ b/crates/dbx-core/src/table_import.rs
@@ -1252,6 +1252,10 @@ fn xlsx_cell_ref_label_with_temporal_kind(cell: &DataRef<'_>, temporal_kind: Opt
}
pub fn xlsx_sheet_names(path: &str) -> Result<Vec<String>, String> {
+ if is_legacy_xls_path(path) {
+ let workbook = open_workbook_auto(path).map_err(|error| error.to_string())?;
+ return Ok(workbook.sheet_names().to_vec());
+ }
let file = File::open(path).map_err(|error| error.to_string())?;
let mut zip = zip::ZipArchive::new(file).map_err(|error| error.to_string())?;
let workbook_xml = read_xlsx_zip_text(&mut zip, "xl/workbook.xml")?;
@@ -6691,6 +6695,28 @@ mod tests {
let _ = std::fs::remove_file(path);
}
+ #[tokio::test]
+ async fn legacy_xls_preview_reads_sheet_names_without_zip_parser() {
+ let path = std::env::temp_dir().join(format!("dbx-table-import-preview-{}.xls", uuid::Uuid::new_v4()));
+ std::fs::write(&path, include_bytes!("../tests/fixtures/issue3683-formatted-numbers.xls")).unwrap();
+ let options = TableImportParseOptions { has_header: Some(false), ..TableImportParseOptions::default() };
+
+ let (parsed, non_streaming, sheets) = parse_import_preview_file_with_options(
+ &path.to_string_lossy(),
+ TableImportSourceFormat::Excel,
+ &options,
+ 10,
+ )
+ .await
+ .unwrap();
+
+ assert!(non_streaming);
+ assert_eq!(sheets, vec!["Sheet1"]);
+ assert_eq!(parsed.columns, vec!["column_1", "column_2", "column_3", "column_4", "column_5"]);
+ assert_eq!(parsed.rows.len(), 1);
+ let _ = std::fs::remove_file(path);
+ }
+
#[cfg(target_os = "linux")]
fn linux_process_rss_kib(pid: u32) -> Option<u64> {
let status = std::fs::read_to_string(format!("/proc/{pid}/status")).ok()?;