SuperYesifang / excel-viewer

这是一个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.
MIT License
36 stars 6 forks source link

Loading local Excel File #8

Open abhishekdana1999 opened 1 month ago

abhishekdana1999 commented 1 month ago

Hey there,

I have been using the plugin to load local file, how can we do that

kubil-ismail commented 1 month ago

You can try like this

import ExcelViewer from "excel-viewer";
import { useSearchParams } from "react-router-dom";
import React from "react";

function App() {
  const [searchParams] = useSearchParams();
  const url = searchParams.get("url");

  React.useEffect(() => {
    if (url) {
      new ExcelViewer("#excel-view", url, { themeBtn: false });
    }
  }, [url]);

  return (
    <div className="App">
      <div id="excel-view"></div>
    </div>
  );
}

export default App;