npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@orginone/react-office-viewer

v1.0.5

Published

A React component to preview document of 'pdf,xls,xlsx,docx', which can automatically identify file types.

Downloads

4

Readme

react-office-viewer: pdf, xls, xlsx, docx

Features

  1. Temporary support 'pdf,xls,xlsx,docx'.For more types, please pay attention to the following updates.
  2. Automatically identify file types of 'pdf,xls,xlsx,doc,docx,ppt,pptx' according to file arraybuffer. File suffix or file name is better but not necessary. Further more, it can avoid wrong judgment by the falsy changes of file suffix.
    能自动识别文件类型,传递文件名称不是必须的(但最好传递),可以避免后缀名错误修改导致的错误类型判断。
  3. PDF viewer has a full functional toolbar with common functions of pagination,zoom,rotate,print,thumbview,etc.
    其中pdf 预览组件有功能健全的toolbar,实现了翻页、缩放、旋转、打印、缩略图等常用功能。
  4. The inner prompt language supports both Chinese and English, you can choose it by passing a param.(Default Chinese)
    组件内置的提示语言支持中英双语,你可以通过传递参数来选择。(默认中文)
  5. Implemented based on react 16.8.

Usage

npm install react-office-viewer
import Viewer from "react-office-viewer"

//If you only want to preview a certain format, you can import them individually.
import { SheetViewer, PdfViewer, DocxViewer } from "react-office-viewer"

Params

// Pass a url that can get the file stream. 
<Viewer file="http://xxxx"/>   

// Or, pass a File Object.
<Viewer file={ fileObject }/>

<input type='file' onChange={this.getFileObject} />
getFileObject = e => {
  this.setState({ fileObject: e.target.files[0] });
}


//other optional params:
let params = {
  fileName,  //PropTypes.string
  locale: 'en', // PropTypes.oneOf(['zh','en'])
  width, //PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  height, //PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  timeout: 10000, //PropTypes.number. Timeout limit of url request, only works on sheet/docx previewer.
}

<Viewer file="http://xxxx" {...params} />

Demo

效果样例: image image image

Dependencies

handsontable,
mammoth,
xlsx, pdfjs-dist