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

excel-viewer

v1.0.1

Published

这是一个excel文件查看器,支持xls、xlsx、csv格式,你可以用它在指定DOM渲染excel,也可以将它内嵌在iframe中。This is an excel file viewer that supports xls, xlsx, csv and ods. You can use it to render excel in the specified DOM or embedded it in the iframe.

Downloads

5,397

Readme

excel-viewer

excel-viewer blog

这是一个excel文件查看器,支持xls、xlsx、csv格式,你可以用它在指定DOM渲染excel,也可以将它内嵌在iframe中。

This is an excel file viewer that supports xls, xlsx, csv and ods. You can use it to render excel in the specified DOM or embedded it in the iframe.

中文文档

Introduction

This is an excel file viewer developed using xlsx and xspreadsheet.

Added light and dark theme mode switching, new support for Chinese, new support for iframe, so that you can use it right out of the box.

image-readme-theme-light

image-readme-theme-dark

Usage

new ExcelViewer(el:string|HTMLElement, source:string|Buffer, options)

  • el:excel view container.
    • string:excel view element selector string.
    • HTMLElement:html element
  • source:excel source url or data.
    • string:excel file source url.
    • Buffer:excel file source buffer data.
  • options:more functions.
new ExcelViewer("#excel-view", "http://example.com/test.xls", {
    theme: "dark",
    lang: "zh_cn"
});

options

| option | type | description | | ------------ | --------------------- | ------------------------------------------------ | | theme | "light""dark" | excel theme mode. default"light" | | themeBtn | boolean | enable theme mode switch button. defaulttrue | | lang | "en""zh_cn" | viewer language. default"en" |

  • supports language

| lang | description | | ----------- | -------------------------------- | | "en" | English | | "zh_cn" | 简体中文(Simplified Chinese) |

iframe

<iframe src="https://unpkg.com/[email protected]/dist/index.html?file=http://example.com/test.xls"></iframe>
  • query params

| params | description | | ------------- | -------------------------------------------------------------------------- | | file | excel file url. | | theme? | excel viewer theme mode. supports:lightdark | | themeBtn? | enable viewer theme switch button. supports:1 (true)、0 (disabled) | | lang? | viewer language. supports:enzh_cn |

CDN

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/excel/xspreadsheet.css">
<script src="https://unpkg.com/[email protected]/dist/excel/xspreadsheet.js"></script>
<script src="https://unpkg.com/[email protected]/dist/excel/xlsx.full.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/excel-viewer.js"></script>
<script>
    new ExcelViewer("#excel-view", "http://example.com/test.xls", {
        theme: "dark",
        lang: "zh_cn"
    });
</script>

ESM

import ExcelViewer from "excel-viewer";

new ExcelViewer("#excel-view", "http://example.com/test.xls", {
    theme: "dark",
    lang: "zh_cn"
});

Authorization

If your excel file needs authorization, you can help you through this.

iframe

<iframe id="excel-viewer"></iframe>

<script>
let iframe = document.getElementById("excel-viewer");
// example with axios
axios({
    url: "http://example.com/test.xls",
    method: "GET",
    headers: { "Authorization": "Your Authorization Token" }, // authorization token
    responseType: "blob"
}).then(blob => {
    let localUrl = URL.createObjectURL(blob) + ".xls"; // add excel file suffix
    iframe.src = "https://unpkg.com/[email protected]/dist/index.html?file=" + localUrl;
})
</script>

CDN

<div id="excel-view"></div>

<script>
// example with axios
axios({
    url: "http://example.com/test.xls",
    method: "GET",
    headers: { "Authorization": "Your Authorization Token" }, // authorization token
    responseType: "arraybuffer"
}).then(res => {
    new ExcelViewer("#excel-view", res.data);
})
</script>

ESM

<template>
	<div ref="excel-view"></div>
</template>
<script>
import axios from "axios";
import ExcelViewer from "excel-viewer";

// example with vuejs and axios
export default {
    mounted() {
        let container = this.$refs["excel-view"];
  
        axios({
            url: "http://example.com/test.xls",
            method: "GET",
            headers: { "Authorization": "Your Authorization Token" }, // authorization token
            responseType: "arraybuffer"
        }).then(res => {
            new ExcelViewer(container, res.data);
        })
    }
}
</script>

!!Known Restrictions

If you need to use multiple excel-viewer on one page, the ESM method will not be able to set different theme modes for the previewer and cannot use the theme switching function. You can use the iframe embedded approach to solve this problem perfectly.

<div id="excel-view1"></excel-view>
<div id="excel-view2"></excel-view>
<script>
    // right
    new ExcelViewer("#excel-view1", "http://example.com/test.xlsx", { theme: "dark", themeBtn: false });
    new ExcelViewer("#excel-view2", "http://example.com/test.xlsx", { theme: "dark", themeBtn: false });
    // error
    new ExcelViewer("#excel-view1", "http://example.com/test.xlsx", { theme: "dark", themeBtn: true }); // error,themeBtn should disabled
    new ExcelViewer("#excel-view2", "http://example.com/test.xlsx", { theme: "light", themeBtn: false }); // error, multiple viewer theme mode must be the same
</script>