让数据在滑动数据网格上滑动
滑动数据网格 是一个为 ReactJS Web 框架设计的高性能数据网格。
¥Glide Data Grid is a high-performance data grid designed for the ReactJS web framework.
SheetJS 是一个用于从电子表格读取和写入数据的 JavaScript 库。
¥SheetJS is a JavaScript library for reading and writing data from spreadsheets.
该演示使用 Glide Data Grid 和 SheetJS 从电子表格中提取数据并在数据网格中显示内容。我们将探讨如何将数据从文件导入到数据网格以及如何将修改后的数据从网格导出到工作簿。
¥This demo uses Glide Data Grid and SheetJS to pull data from a spreadsheet and display the content in a data grid. We'll explore how to import data from files into the data grid and how to export modified data from the grid to workbooks.
"演示" 部分包括一个完整的示例,该示例显示用户提供的工作表中的数据并将数据导出到 XLSX 工作簿:
¥The "Demo" section includes a complete example that displays data from user-supplied sheets and exports data to XLSX workbooks:
本 demo 在以下环境下进行了测试:
¥This demo was tested in the following environments:
浏览器 | 版本 | 日期 |
---|---|---|
Chromium 135 | 5.3.2 | 2025-04-23 |
Konqueror 22 | 5.3.2 | 2025-04-23 |
Glide 数据网格与 ReactJS 19 不兼容!
¥Glide Data Grid is not compatible with ReactJS 19!
尝试在新项目中安装 npm install
时,会失败:
¥When trying to install in a new project, npm install
will fail:
npm error Found: react@19.1.0
npm error node_modules/react
npm error react@"^19.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^16.12.0 || 17.x || 18.x" from @glideapps/glide-data-grid@5.3.2
npm error node_modules/@glideapps/glide-data-grid
此演示明确使用了 ReactJS 18。
¥This demo explicitly uses ReactJS 18.
集成详情
¥Integration Details
"构架" 章节 涵盖了 Yarn 和其他包管理器的安装。
¥The "Frameworks" section covers installation with Yarn and other package managers.
使用 npm
工具,此命令安装 SheetJS 和 Glide Data Grid:
¥Using the npm
tool, this command installs SheetJS and Glide Data Grid:
npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz @glideapps/glide-data-grid@5.3.2
两个库中的方法和组件都可以使用 import
加载到页面中:
¥Methods and components in both libraries can be loaded in pages using import
:
import { read, utils, writeFile } from 'xlsx';
import { DataEditor, GridCellKind, GridCell, Item } from '@glideapps/glide-data-grid';
Glide 数据网格主要是基于事件的。它不直接管理状态。相反,开发者应该在用户编辑单元格时管理更新。
¥Glide Data Grid is primarily event-based. It does not manage state directly. Instead, developers are expected to manage updates when users edit cells.