feat(grid): right-align numeric result columns

This commit is contained in:
gggaiitx authored and GitHub committed 2026-07-27 18:54:54 +08:00
1 parent 66c768061a
commit e2b35944ce
35 files changed
+1082 -109

No files matched your search

+15 -3
View File
@@ -21,7 +21,7 @@ use crate::transfer::{
pagination_sql_with_filter_order, qualified_table, quote_identifier,
};
use crate::types::QueryResult;
use crate::xlsx_export::{finish_streaming_xlsx_workbook, start_streaming_xlsx_workbook};
use crate::xlsx_export::{finish_streaming_xlsx_workbook, start_streaming_xlsx_workbook_with_options};
const DEFAULT_BATCH_SIZE: usize = 10_000;
const SQL_INSERT_BATCH_SIZE: usize = 100;
@@ -59,6 +59,8 @@ pub struct TableExportRequest {
pub row_limit: Option<usize>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub date_time_format: Option<String>,
#[serde(default)]
pub numeric_column_right_align: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -763,11 +765,14 @@ async fn try_export_native_table_stream(
let xlsx_column_types = export_column_types(request);
let xlsx_file =
std::fs::File::create(&request.file_path).map_err(|e| format!("Failed to create XLSX file: {e}"))?;
let mut writer = start_streaming_xlsx_workbook(
let mut writer = start_streaming_xlsx_workbook_with_options(
BufWriter::new(xlsx_file),
Some(&request.table_name),
col_names,
&xlsx_column_types,
&[],
request.date_time_format.as_deref(),
request.numeric_column_right_align,
)?;
let result = stream_native_table_rows(
state,
@@ -1387,11 +1392,14 @@ async fn export_table_data_core_inner(
// sharing a file descriptor between two independent buffers.
let xlsx_file =
std::fs::File::create(&request.file_path).map_err(|e| format!("Failed to create XLSX file: {e}"))?;
let mut writer = start_streaming_xlsx_workbook(
let mut writer = start_streaming_xlsx_workbook_with_options(
BufWriter::new(xlsx_file),
Some(&request.table_name),
&col_names,
&xlsx_column_types,
&[],
request.date_time_format.as_deref(),
request.numeric_column_right_align,
)?;
loop {
@@ -1869,6 +1877,7 @@ mod tests {
batch_size: Some(batch_size),
row_limit,
date_time_format: None,
numeric_column_right_align: false,
};
ExternalDriverExportFixture { state, request, calls, output, dir }
@@ -2029,6 +2038,7 @@ mod tests {
batch_size: Some(500),
row_limit: Some(1000),
date_time_format: None,
numeric_column_right_align: false,
};
let sql = table_cursor_sql(
@@ -2077,6 +2087,7 @@ mod tests {
batch_size: Some(100),
row_limit: None,
date_time_format: None,
numeric_column_right_align: false,
};
let sql = table_cursor_sql(&request, &DatabaseType::Oracle, &columns, &primary_keys);
assert_eq!(sql, "SELECT \"ID\", \"NAME\" FROM \"APP\".\"USERS\"");
@@ -2395,6 +2406,7 @@ mod tests {
vec![json!(2), json!("Bob"), json!(82000)],
vec![json!(3), Value::Null, json!(0)],
],
numeric_column_right_align: false,
};
let workbook = build_xlsx_workbook(&data).expect("XLSX build should succeed");