From 3c493b2bd61856851737bd61726ffb9b005067f8 Mon Sep 17 00:00:00 2001 From: Halfknow Date: Fri, 7 Aug 2026 09:50:41 +0800 Subject: [PATCH] feat: add support for .wps and .et --- README.md | 4 ++-- src/lib.rs | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ed4cb9e4..6a08a1e5 100644 --- a/README.md +++ b/README.md @@ -140,9 +140,9 @@ let document = anydoc::to_document(&bytes, None)?; | Format | Extensions | | ---------------- | ---------------------------------------------------------- | -| Word | `.doc`, `.docx`, `.docm` | +| Word | `.doc`, `.docx`, `.docm`, `.wps` | | PowerPoint | `.ppt`, `.pps`, `.pot`, `.pptx`, `.pptm`, `.ppsx`, `.ppsm` | -| Excel | `.xls`, `.xlsx`, `.xlsm`, `.xlsb` | +| Excel | `.xls`, `.xlsx`, `.xlsm`, `.xlsb`, `.et` | | OpenDocument | `.odt`, `.ods`, `.odp` | | Rich Text Format | `.rtf` | | EPUB | `.epub` | diff --git a/src/lib.rs b/src/lib.rs index efba6ff8..daa93bab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,8 @@ use std::path::Path; /// [`Format::from_extension`]. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Format { - /// Binary Word 97-2003 (`.doc`). + /// Binary Word 97-2003 (`.doc`), and the OLE2-based Kingsoft WPS Writer + /// / Microsoft Works wrapper that shares its `WordDocument` stream (`.wps`). Doc, /// WordprocessingML (`.docx`, `.docm`), both Transitional and Strict. Docx, @@ -46,7 +47,8 @@ pub enum Format { /// EPUB 2 and 3 (`.epub`). Epub, /// Excel workbooks in every container calamine reads: `.xlsx`, `.xlsm`, - /// `.xlsb`, and binary `.xls`. + /// `.xlsb`, binary `.xls`, and the OLE2-based Kingsoft WPS Spreadsheet + /// wrapper that shares its `Workbook`/`Book` stream (`.et`). Excel, /// OpenDocument Spreadsheet (`.ods`). Ods, @@ -71,7 +73,9 @@ impl Format { /// case-insensitively. `None` for anything unrecognized. pub fn from_extension(ext: &str) -> Option { Some(match ext.to_ascii_lowercase().as_str() { - "doc" => Format::Doc, + // `.wps` is the Kingsoft WPS Writer / Microsoft Works wrapper, + // an OLE2 compound file with a `WordDocument` stream like `.doc`. + "doc" | "wps" => Format::Doc, "docx" | "docm" => Format::Docx, "odt" => Format::Odt, "pdf" => Format::Pdf, @@ -79,7 +83,9 @@ impl Format { "ppt" | "pps" | "pot" => Format::Ppt, "rtf" => Format::Rtf, "epub" => Format::Epub, - "xlsx" | "xlsm" | "xlsb" | "xls" => Format::Excel, + // `.et` is the Kingsoft WPS Spreadsheet wrapper; modern files are + // an OLE2 compound file with a `Workbook`/`Book` stream like `.xls`. + "xlsx" | "xlsm" | "xlsb" | "xls" | "et" => Format::Excel, "ods" => Format::Ods, "odp" => Format::Odp, "csv" => Format::Csv,