Skip to main content

Roadmap路线图

Most scenarios involving spreadsheets and data can be divided into 5 parts:大多数涉及电子表格和数据的场景可分为5个部分:

1) Acquire Data获取数据: Data may be stored anywhere: local or remote files, databases, HTML TABLE, or even generated programmatically in the web browser.:数据可以存储在任何地方:本地或远程文件、数据库、HTML TABLE,甚至可以在web浏览器中以编程方式生成。

2) Extract Data提取数据: For spreadsheet files, this involves parsing raw bytes to read the cell data. For general JS data, this involves reshaping the data.:对于电子表格文件,这涉及到解析原始字节以读取单元格数据。对于一般的JS数据,这涉及到对数据进行整形。

3) Process Data处理数据: From generating summary statistics to cleaning data records, this step is the heart of the problem.:从生成汇总统计数据到清理数据记录,这一步是问题的核心。

4) Package Data打包数据: This can involve making a new spreadsheet or serializing with JSON.stringify or writing XML or simply flattening data for UI tools.:这可能涉及到制作一个新的电子表格,或者使用JSONstringify进行序列化,或者编写XML,或者简单地为UI工具压平数据。

5) Release Data发布数据: Spreadsheet files can be uploaded to a server or written locally. Data can be presented to users in an HTML TABLE or data grid.:电子表格文件可以上传到服务器或在本地编写。数据可以在HTML表格或数据网格中呈现给用户。

A common problem involves generating a valid spreadsheet export from data stored in an HTML table.一个常见的问题涉及从HTML表中存储的数据生成有效的电子表格导出。

Get Table (1)
.
Parse Table (2)
`table_to_book`
Add data (3)
`sheet_add_aoa`
Export file (4,5)
`writeFile`
Backend
Server
HTML
TABLE
SheetJS
Workbook
Modified
Workbook
workbook
file

In this example, an HTML TABLE on the page will be scraped, a row will be added to the bottom with the date of the report, and a new file will be generated and downloaded locally. 在这个例子中,页面上的一个HTML TABLE将被刮取,一行将被添加到底部,其中包含报告的日期,并且一个新文件将被生成并在本地下载。XLSX.writeFile takes care of packaging the data and attempting a local download:负责打包数据并尝试本地下载:

// Acquire Data (reference to the HTML table)获取数据(参考HTML表)
var table_elt = document.getElementById("my-table-id");

// Extract Data (create a workbook object from the table)提取数据(从表中创建工作簿对象)
var workbook = XLSX.utils.table_to_book(table_elt);

// Process Data (add a new row)流程数据(添加新行)
var ws = workbook.Sheets["Sheet1"];
XLSX.utils.sheet_add_aoa(ws, [["Created "+new Date().toISOString()]], {origin:-1});

// Package and Release Data (`writeFile` tries to write and save an XLSB file)包和发布数据(`writeFile`尝试写入并保存XLSB文件)
XLSX.writeFile(workbook, "Report.xlsb");

This library tries to simplify steps 2 and 4 with functions to extract useful data from spreadsheet files (read / readFile) and generate new spreadsheet files from data (write / writeFile). 该库试图通过从电子表格文件(read/readFile)中提取有用数据并从数据(write/writeFile)中生成新的电子表格文件的功能来简化步骤2和4。Additional utility functions like table_to_book work with other common data sources like HTML tables.table_to_book等其他实用程序函数可与HTML表等其他常见数据源配合使用。

This documentation and various demo projects cover a number of common scenarios and approaches for steps 1 and 5.本文档和各种演示项目涵盖了步骤1和5的许多常见场景和方法。

Utility functions help with step 3.实用程序功能有助于步骤3。

Highlights集锦

"Demos"“演示文档” describes special deployments using SheetJS in tandem with other tools and libraries.描述了将SheetJS与其他工具和库一起使用的特殊部署。

"Data Import"“数据导入” describes solutions for common data import scenarios.描述了常见数据导入场景的解决方案。

"Data Export"“数据导出” describes solutions for common data export scenarios.描述了常见数据导出场景的解决方案。

"Data Processing"“数据处理” describes solutions for common workbook processing and manipulation scenarios.描述了常见工作簿处理和操作场景的解决方案。

"Utility Functions"“实用程序功能” details utility functions for translating JSON Arrays and other common JS structures into worksheet objects.详细介绍了用于将JSON数组和其他常见JS结构转换为工作表对象的实用函数。