javascript - 在反应中读取/显示excel文件
问题描述
我想上传一个 excel 文件,然后首先将其所有内容显示为文本。目前,文本的格式并不重要。我正在使用 dropzone 库上传文件。该text
参数是我要保存文件的文本/内容的位置。但是,目前,它给了我一个错误
Uncaught Error: Objects are not valid as a React child (found: object with keys {file, meta, cancel, remove, restart, xhr}). If you meant to render a collection of children, use an array instead.
所以,我不确定我可以在哪里处理文件的内容并使用saveText
钩子保存它。我应该尝试什么?
export function Page() {
const [text, setText] = useState<any>('hello');
const getUploadParams = ({ meta }: any) => { return { url: 'https://httpbin.org/post' } }
const handleChangeStatus = ({ meta, file }: any, status: any) => { console.log(status, meta, file) }
const handleSubmit = (files: any[], allFiles: any[]) => {
//console.log(files.map(f => f.meta))
setText(files)
console.log('TEXT', text)
}
return (
<div>
<main className={classes.content}>
<Dropzone
getUploadParams={getUploadParams}
onChangeStatus={handleChangeStatus}
onSubmit={handleSubmit}
/>
{text}
<div>
</div>
</main>
</div>
);
}
解决方案
推荐阅读
- r - 将我的无向网络图(使用 igraph)转换为 R 中 networkd3 中的交互式图
- javascript - 如何使用本机 javascript 调用移动浏览器的共享功能?
- laravel - How to list Jetstream Roles on other view blade
- amazon-web-services - terraform elasticsearch:domain_name 的值无效
- javascript - 从 javascript 调用的 Bootstrap 5 beta 下拉问题
- jquery - 显示匹配多个选定数据属性的元素
- django - 当我添加参数时,DRF url 不起作用
- mysql - MySQL 如何使用外键识别另一个表中的列?
- r - R仅查找带有数字和“,”的元素
- python - Python3.9 ModuleNotFoundError: No module named Can't figure out base directory