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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -71,15 +73,19 @@ impl Format {
/// case-insensitively. `None` for anything unrecognized.
pub fn from_extension(ext: &str) -> Option<Format> {
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,
"pptx" | "pptm" | "ppsx" | "ppsm" => Format::Pptx,
"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,
Expand Down