Skip to content

Commit 6e785bf

Browse files
authored
feat: add lazy loading feature, optimize code related to calamine via PR #9 from fuhan666/feature/optimize-calamine
2 parents c659cc0 + bea6f12 commit 6e785bf

24 files changed

Lines changed: 637 additions & 263 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Support dimming other areas while editing
1313
- Remember the selected cell when switching between sheets
14+
- Added optional lazy loading for xlsx and xlsb files to improve performance with large files (enabled with -l flag)
1415

1516
### Fixed
1617

@@ -21,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2122
- Edit cell content using vim shortcuts
2223
- Multiple UI improvements
2324
- Replace ratatui_textarea with tui_textarea
25+
- Upgraded calamine to version 0.27.0
2426

2527
## [0.2.0] - 2025-04-27
2628

Cargo.lock

Lines changed: 22 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exclude = ["/.github", "CHANGELOG.md", ".gitignore"]
1212
[dependencies]
1313
ratatui = "0.24.0"
1414
crossterm = "0.27.0"
15-
calamine = "0.22.1"
15+
calamine = "0.27.0"
1616
anyhow = "1.0.79"
1717
clap = { version = "4.5.0", features = ["derive"] }
1818
rust_xlsxwriter = "0.86.0"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ excel-cli path/to/your/file.xlsx -j > data.json # (example) Save JSON output to
7575
- `--json-export`, `-j`: Export all sheets to JSON and output to stdout (for piping)
7676
- `--direction`, `-d`: Header direction in Excel: 'h' for horizontal (top rows), 'v' for vertical (left columns). Default: 'h'
7777
- `--header-count`, `-r`: Number of header rows (for horizontal) or columns (for vertical) in Excel. Default: 1
78+
- `--lazy-loading`, `-l`: Enable lazy loading for large Excel files (only loads data when needed)
7879

7980
## User Interface
8081

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ excel-cli path/to/your/file.xlsx -j > data.json # (示例)将JSON输出保
7575
- `--json-export`, `-j`:将所有工作表导出为 JSON 并输出到 stdout(用于管道传输)
7676
- `--direction`, `-d`:Excel 中的表头方向:'h'表示水平(顶部行),'v'表示垂直(左侧列)。默认:'h'
7777
- `--header-count`, `-r`:Excel 中的表头行数(水平方向)或列数(垂直方向)。默认:1
78+
- `--lazy-loading`, `-l`:启用大型 Excel 文件的懒加载功能(仅在需要时加载数据)
7879

7980
## 用户界面
8081

src/actions/cell.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct CellAction {
1414
}
1515

1616
impl CellAction {
17+
#[must_use]
1718
pub fn new(
1819
sheet_index: usize,
1920
sheet_name: String,

src/actions/command.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ use super::types::{ActionCommand, ActionType};
22

33
impl ActionCommand {
44
// Returns the action type of this command
5+
#[must_use]
56
pub fn get_action_type(&self) -> ActionType {
67
match self {
78
ActionCommand::Cell(action) => match action.action_type {
8-
ActionType::Edit => ActionType::Edit,
9-
ActionType::Cut => ActionType::Cut,
109
ActionType::Paste => ActionType::Paste,
11-
_ => ActionType::Edit, // Default case
10+
_ => ActionType::Edit, // Default case including Edit and Cut
1211
},
1312
ActionCommand::Row(_) => ActionType::DeleteRow,
1413
ActionCommand::MultiRow(_) => ActionType::DeleteMultiRows,

src/actions/history.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ impl Default for UndoHistory {
1313
}
1414

1515
impl UndoHistory {
16+
#[must_use]
1617
pub fn new() -> Self {
1718
Self {
1819
undo_stack: Vec::with_capacity(100), // Pre-allocate capacity
@@ -44,6 +45,7 @@ impl UndoHistory {
4445
}
4546
}
4647

48+
#[must_use]
4749
pub fn all_undone(&self) -> bool {
4850
self.undo_stack.is_empty()
4951
}

src/app/edit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl AppState<'_> {
1010
pub fn start_editing(&mut self) {
1111
self.input_mode = InputMode::Editing;
1212
let content = self.get_cell_content(self.selected_cell.0, self.selected_cell.1);
13-
self.input_buffer = content.clone();
13+
self.input_buffer.clone_from(&content);
1414

1515
// Initialize TextArea with content and settings
1616
let mut text_area = tui_textarea::TextArea::default();
@@ -57,7 +57,7 @@ impl AppState<'_> {
5757
let old_cell = self.workbook.get_current_sheet().data[row][col].clone();
5858

5959
let mut new_cell = old_cell.clone();
60-
new_cell.value = content.clone();
60+
new_cell.value.clone_from(&content);
6161

6262
let cell_action = CellAction::new(
6363
sheet_index,
@@ -134,7 +134,7 @@ impl AppState<'_> {
134134
let old_cell = self.workbook.get_current_sheet().data[row][col].clone();
135135

136136
let mut new_cell = old_cell.clone();
137-
new_cell.value = content.clone();
137+
new_cell.value.clone_from(&content);
138138

139139
let cell_action = CellAction::new(
140140
sheet_index,

src/app/navigation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ impl AppState<'_> {
108108
|| sheet.data[row][col].value.is_empty();
109109

110110
let message = if is_cell_empty {
111-
format!("Jumped to first non-empty cell ({})", dir_name)
111+
format!("Jumped to first non-empty cell ({dir_name})")
112112
} else {
113-
format!("Jumped to last non-empty cell ({})", dir_name)
113+
format!("Jumped to last non-empty cell ({dir_name})")
114114
};
115115

116116
self.add_notification(message);

0 commit comments

Comments
 (0)