惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
L
LangChain Blog
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
博客园_首页
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
美团技术团队
V
V2EX

Inside Nutrient

A guide to the invisible work behind documents Introducing Nutrient Documents for Salesforce: Native document generation and signing Document AI vs. traditional OCR: Choosing between OCR, AI, and hybrid pipelines PDF SDK compliance and security evaluation checklist for enterprise teams (2026) Invariant Corp replaces paper processes with Nutrient Workflow and scales without limits What is process mapping? A complete guide Nutrient vs. Conga Composer for Salesforce document generation (2026) Document routing: How to automate document distribution The CTO’s AI playbook: Why accountability architecture beats orchestration Compliance workflow automation: Why built-in compliance is table stakes Workflow diagrams: Examples, symbols, and how to build one that actually runs Digital forms: Replace paper forms with automated workflows Approval workflow software: How to automate approvals Why document-centric automation is different The CEO’s AI playbook: Why decision architecture beats model selection Nutrient SDK product updates for Q1 2026 PDF redaction verification: How to prove sensitive data is permanently removed What is a VPAT? The complete guide to accessibility conformance reports What is PDF/UA? The accessible PDF standard explained Salesforce eSignatures: Generate, sign, and track documents in one flow Online document viewer: Options, tradeoffs, and how to embed one Document viewer for web apps: React, Vue, Angular (2026) Best document viewers in 2026: A buyer’s guide How to edit a PDF in Python: Add text, images, and annotations Nutrient advances Workflow platform with agentic AI for enterprise-grade speed and consistency in document-heavy operations How to create a Salesforce quote template from opportunity data The business case for accessibility: Five ways it drives enterprise value Python PDF library comparison (2026): 7 libraries for developers Why your AI agent hallucinates PDF table data PDF.js limitations: When to upgrade to a commercial PDF SDK
How to build a React.js Excel (XLS/XLSX) viewer
Hulya Masharipov · 2023-11-17 · via Inside Nutrient

Table of contents

    How to build a React.js Excel (XLS/XLSX) viewer

    In this blog post, learn how to build a React Excel viewer using the Nutrient Web SDK. You’ll open and view XLS and XLSX files directly in your web browser using client-side processing (no server required).

    The image below shows what you’ll be building.

    resulting image

    You can check out the demo to see it in action.

    Opening and rendering Office documents in the browser

    Nutrient Web SDK brings support for Word, Excel, and PowerPoint formats to your application, without you or your users needing any MS Office software, MS Office licenses, or third-party open source software. The technology works by converting an Office document to PDF directly in the browser, and the document is then rendered in our JavaScript viewer.

    Unlocking more capabilities with Office-to-PDF conversion

    ​​By converting an Office document to PDF using client-side JavaScript, you have the option to support a rich array of additional Office document functionality, such as:

    • Text editing — Edit text directly in the displayed Office document.
    • Page manipulation — Organize documents by adding, removing, or rearranging pages.
    • Annotations — Boost collaboration by adding text highlights, comments, or stamps.
    • Adding signatures — Draw, type, or upload a signature directly to an Office document.

    Explore Demo

    Requirements to get started

    To get started, you’ll need:

    Setting up a new React project with Vite

    1. To get started, create a new React project using Vite:

    # Using Yarn

    yarn create vite nutrient-react-example --template react

    # Using npm

    npm create vite@latest nutrient-react-example -- --template react

    1. Navigate to your project directory:

    cd nutrient-react-example

    Adding Nutrient to your project

    1. First, install Nutrient as a dependency:

    npm i @nutrient-sdk/viewer

    1. The Nutrient Web SDK loads its WebAssembly and supporting files from a local path, so you need to copy them to the public folder. Start by installing the required copy plugin:

    npm install -D rollup-plugin-copy

    Then, update your Vite configuration (vite.config.ts) to copy the SDK’s asset files during build:

    import { defineConfig } from 'vite';

    import react from '@vitejs/plugin-react';

    import copy from 'rollup-plugin-copy';

    export default defineConfig({

    plugins: [

    copy({

    targets: [

    {

    src:

    'node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib',

    dest: 'public/',

    },

    ],

    hook: 'buildStart',

    }),

    react(),

    ],

    });

    Displaying a PDF in your React app

    1. Add an Excel (XLS, XLSX) document you want to display to the public directory. You can use our demo document as an example. Add this file to the public directory of your project.
    2. Now that everything is set up, you’ll render a PDF using the Nutrient SDK.

    Basic usage in App.tsx:

    import { useEffect, useRef } from 'react';

    function App() {

    const containerRef = useRef(null);

    useEffect(() => {

    const container = containerRef.current;

    let cleanup = () => {};

    (async () => {

    const NutrientViewer = (await import('@nutrient-sdk/viewer'))

    .default;

    // Unload any previous instance.

    NutrientViewer.unload(container);

    if (container && NutrientViewer) {

    NutrientViewer.load({

    container,

    document: 'chart.xlsx',

    baseUrl: `${window.location.protocol}//${

    window.location.host

    }/${import.meta.env.PUBLIC_URL ?? ''}`,

    });

    }

    cleanup = () => {

    NutrientViewer.unload(container);

    };

    })();

    return cleanup;

    }, []);

    return (

    <div

    ref={containerRef}

    style={{ height: '100vh', width: '100vw' }}

    />

    );

    }

    export default App;

    1. Start your development server:

    # Using Yarn

    yarn dev

    # Using npm

    npm run dev

    Once the server is running, you can view and interact with your PDF directly in the browser.

    A note about fonts

    In client-side web applications for Microsoft Office-to-PDF conversion, Nutrient addresses font licensing constraints through font substitutions, typically replacing unavailable fonts with their equivalents — like Arial with Noto. For precise font matching, you can provide your own fonts, embed them into source files, or designate paths to your .ttf fonts for custom solutions.

    Adding even more capabilities

    Once you’ve deployed your viewer, you can start customizing it to meet your specific requirements or easily add more capabilities. To help you get started, here are some of our most popular React.js guides:

    Conclusion

    In this blog post, you learned how to build an Excel viewer using React.js with the Nutrient SDK.

    If you’re looking for a way to render Office documents in your web application, then Nutrient Web SDK is a great option. It’s a powerful and flexible library that can help you provide your users with a seamless and enjoyable experience.

    To get started, you can either:

    • Start your free trial to test out the library and see how it works in your application.
    • Launch our demo to see the viewer in action.

    FAQ

    To integrate Nutrient, install the @nutrient-sdk/viewer package with npm or Yarn, copy the library assets to your public directory, and create a React component to initialize and configure Nutrient.

    Import the Nutrient library in your React component, provide the path to your Excel document, and use NutrientViewer.load() to render the document.

    Yes, you can customize the Nutrient viewer with options for initial view state, annotations, text editing, and additional functionalities.

    You can check out a demo of the React.js Excel viewer with Nutrient by visiting the Nutrient demo page.

    Explore related topics

    Try for free Ready to get started?

    Related SDK articles

    Explore more