Categories: CSSScriptWeb Design

Lightweight MS Office Document to HTML Parser – Envelope

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.

Table of Contents

Toggle

Features:

  • Multi-format support: Handles DOCX, PPTX (partial), XLSX (partial), ODT, ODP (partial), and ODS.
  • Pure JavaScript: No server-side components or native code.
  • Sponsored
  • Browser-native: Uses standard JavaScript APIs (like Uint8Array and Promise) 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.

Sponsored
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
});

The post Lightweight MS Office Document to HTML Parser – Envelope appeared first on CSS Script.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

A Look Back, Feb. 26

50 Years Ago A number of area residents attended a slide presentation by the Northampton…

17 minutes ago

Photos: Steering toward service

Jameson Fournier,11, a member of the Western Mass 4-H Ox teamsters, leads his two steers,…

18 minutes ago

McGovern, Neal slam Trump’s State of the Union address

President Donald Trump addressed the nation in his State of the Union Tuesday night —…

18 minutes ago

Hadley schools face $754K shortfall; potential staff cuts

HADLEY — Significant reductions to teaching staff and education support professionals at the Hadley Elementary…

18 minutes ago

Photo: Snowblower fix

The post Photo: Snowblower fix appeared first on Daily Hampshire Gazette.

18 minutes ago

Along Route 202: Donations get pickleball courts back on track

SOUTH HADLEY — The town has slid out of its pickleball court pickle. Over the…

18 minutes ago

This website uses cookies.