如何在网站上显示电子表格/CSV文件

发布于 2025-02-13 04:57:36 字数 150 浏览 1 评论 0原文

我正在尝试使用React.js在网站上显示电子表格或CSV文件 这些文件已上传到网站上,我只想将输入到网站的文件显示。我尝试过流行的Meduim.com解决方案,但它对我不起作用,并且并不能完全做我想要的。

我不知道已上传到网站的文件的内容,但我只想显示上传到网站的内容。

I am trying to display a spreadsheet or a CSV file on a website using react.js
The files are uploaded on the website and I just want to display the files inputted to the website. I have tried the popular meduim.com solution but it does not work for me, and it does not do exactly what I'm looking for.

I am not aware of the contents of the file which is uploaded to the website, but I just want to display whatever is uploaded to the website.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆头 2025-02-20 04:57:36

编辑:如果要解析XLS文件,则将100%需要一个库。我已经制作了一个上传器,它以前可以脱颖而出,并且自己解析XLS文件只是一个非开始者。查看这个


您可以使用许多不同的库来执行此操作,但是如果您想自己执行此操作,则可以将CSV解析为一组数组,然后使用MAP创建HTML元素。

return (
    <table>
        csvArray.map(row => {
            return <tr><td>row[0]</td></tr>
        })
    </table>
)

EDIT: If you want to parse xls file, you will 100% need a library. I've made a uploader that take excel before and parsing a xls file yourself is just a non starter. Look into this one.


There are many different library that you can use to do this but if you want to do this yourself, you can parse the csv into an array of array, then use map to create html element.

return (
    <table>
        csvArray.map(row => {
            return <tr><td>row[0]</td></tr>
        })
    </table>
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文