Skip to content
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
4 changes: 2 additions & 2 deletions src/formats/sheet/xls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,9 @@ fn txo_text(segs: &[&[u8]]) -> Option<String> {
Some(String::from_utf16_lossy(&units))
}

/// Record only non-empty cell text, like the xlsx reader.
/// Record only cells with visible text, like the xlsx reader.
fn put(out: &mut SheetContent, row: u32, col: u32, text: String) {
if !text.is_empty() {
if !text.trim().is_empty() {
out.cells.insert((row, col), text);
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/formats/sheet/xlsb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,20 @@ pub(super) fn parse(pkg: &mut Package, wb_part: &str) -> Result<Document, Conver
let mut doc = Document::default();
let mut failed = 0usize;
// One budget for the workbook, so sheets cannot multiply the cap.
let mut remaining: HashMap<&str, usize> = HashMap::with_capacity(sheets.len());
for (_, part) in &sheets {
*remaining.entry(part.as_str()).or_insert(0) += 1;
}
let mut slots = 0u64;
for (name, part) in &sheets {
let content =
pkg.optional_part(part)?.map(|bytes| read_sheet(&bytes, &shared, &xfs, date1904));
if let Some(left) = remaining.get_mut(part.as_str()) {
*left -= 1;
if *left == 0 {
pkg.evict(part);
}
}
let mut content = match content {
Some(Ok(c)) => c,
Some(Err(e)) if e.is_fatal() => return Err(e),
Expand Down Expand Up @@ -272,7 +282,7 @@ fn read_sheet(
}
let fmt = xfs.get(style as usize).unwrap_or(&CellFormat::General);
let text = cell_text(id, &mut f, fmt, shared, date1904)?;
if !text.is_empty() {
if !text.trim().is_empty() {
out.cells.insert((r, col), text);
}
}
Expand Down
Loading