
Envelope is a JavaScript library that parses Microsoft Office and OpenDocument formats and converts them to HTML.
It runs entirely in the browser, so you don’t need a server to generate previews.
Features:
- Multi-format support: Handles DOCX, PPTX (partial), XLSX (partial), ODT, ODP (partial), and ODS.
- Pure JavaScript: No server-side components or native code.
- Browser-native: Uses standard JavaScript APIs (like
Uint8ArrayandPromise) for parsing. - Lightweight: Minimal footprint; only the code you need for the formats you use.
How To Use It:
1. Implement Envelope in your project by importing the specific parser for your file type.
import parseDOCX from "./parseDOCX.js";
import parsePPTX from "./parsePPTX.js";
import parseXLSX from "./parseXLSX.js";
import { parseODT, parseODP, parseODS } from "./parseODF.js";
// Parses a Microsoft Word (.docx) file
parseDOCX(bytes);
// Parses a Microsoft PowerPoint (.pptx) file
// Note: This currently implements basic slide and text support
parsePPTX(bytes);
// Parses a Microsoft Excel (.xlsx) file
// Note: This extracts raw cell data without complex formatting
parseXLSX(bytes);
// Parses an OpenDocument Text (.odt) file
parseODT(bytes);
// Parses an OpenDocument Presentation (.odp) file
parseODP(bytes);
// Parses an OpenDocument Spreadsheet (.ods) file
parseODS(bytes);2. Example: Handling a file upload from an input element.
const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
const arrayBuffer = await file.arrayBuffer();
const bytes = new Uint8Array(arrayBuffer);
const output = await getHTML(bytes);
document.body.innerHTML = output; // Inject the result into the page
});






