@@ -109,20 +109,12 @@ pub fn read_excel_file(file_path: &str) -> Result<ExcelWorkbook> {
109109 }
110110 }
111111
112- // For .xlsb (binary spreadsheet), try XLSB parsing but gracefully return empty workbook on failure
112+ // For .xlsb (binary spreadsheet), use XLSB parser with error propagation
113113 if lower_path. ends_with ( ".xlsb" ) {
114114 let file = std:: fs:: File :: open ( file_path) ?;
115- match calamine:: Xlsb :: new ( std:: io:: BufReader :: new ( file) ) {
116- Ok ( workbook) => {
117- return process_workbook ( workbook, office_metadata) ;
118- }
119- Err ( _) => {
120- return Ok ( ExcelWorkbook {
121- sheets : vec ! [ ] ,
122- metadata : office_metadata. unwrap_or_default ( ) ,
123- } ) ;
124- }
125- }
115+ let workbook = calamine:: Xlsb :: new ( std:: io:: BufReader :: new ( file) )
116+ . map_err ( |e| KreuzbergError :: parsing ( format ! ( "Failed to parse XLSB: {}" , e) ) ) ?;
117+ return process_workbook ( workbook, office_metadata) ;
126118 }
127119
128120 // For other formats, use open_workbook_auto
@@ -197,19 +189,12 @@ pub fn read_excel_bytes(data: &[u8], file_extension: &str) -> Result<ExcelWorkbo
197189 }
198190 }
199191 }
200- // Exotic format: .xlsb (binary spreadsheet) - may not contain proper workbook data
192+ // Standard XLSB format (binary spreadsheet): propagate errors
201193 ".xlsb" => {
202194 let cursor = Cursor :: new ( data) ;
203- match calamine:: Xlsb :: new ( cursor) {
204- Ok ( workbook) => process_workbook ( workbook, office_metadata) ,
205- Err ( _) => {
206- // .xlsb files may not contain proper workbook data - return empty workbook
207- Ok ( ExcelWorkbook {
208- sheets : vec ! [ ] ,
209- metadata : office_metadata. unwrap_or_default ( ) ,
210- } )
211- }
212- }
195+ let workbook = calamine:: Xlsb :: new ( cursor)
196+ . map_err ( |e| KreuzbergError :: parsing ( format ! ( "Failed to parse XLSB: {}" , e) ) ) ?;
197+ process_workbook ( workbook, office_metadata)
213198 }
214199 // Standard OpenDocument format
215200 ".ods" => {
0 commit comments