Skip to main content

命令行中的工作表

随着 JS 引擎的出现和服务器端平台的成功,从 JavaScript 代码构建独立的命令行工具成为可能。

¥With the availability of JS engines and the success of server-side platforms, it is possible to build standalone command-line tools from JavaScript code.

SheetJS 是一个用于从电子表格读取和写入数据的 JavaScript 库。

¥SheetJS is a JavaScript library for reading and writing data from spreadsheets.

该演示涵盖了构建独立电子表格处理器的多种策略。最终目标是使用 SheetJS 库从任意电子表格文件生成 CSV 输出。生成的命令行工具将接受参数,解析指定的工作簿,并将 CSV 行打印到终端。

¥This demo covers a number of strategies for building standalone spreadsheet processors. The ultimate goal is to use SheetJS libraries to generate CSV output from arbitrary spreadsheet files. The generated command-line tool will accept an argument, parse the specified workbook, and print CSV rows to the terminal.

Sample terminal session
> xlsx-cli.exe pres.numbers
Name,Index
Bill Clinton,42
GeorgeW Bush,43
Barack Obama,44
Donald Trump,45
Joseph Biden,46

常见独立 CLI 工具的演示包含在单独的页面中:

¥Demos for common standalone CLI tools are included in separate pages:

  • nexe - Prebuilt NodeJS packages
  • pkg - Prebuilt NodeJS packages
  • boxednode - NodeJS binaries with scripts, built from source
  • NodeJS SEA - Single Executable Applications
  • BunJS SEA - BunJS Single-file Executables
  • Deno SEA - Deno Standalone Binaries

平台支持

¥Platform Support

以下框架已在以下平台上进行了测试:

¥The following frameworks have been tested on the following platforms:

xlsx-cli NodeJS 脚本可作为 SheetJS CDN 上的包使用。这是一个用于在支持的电子表格文件格式之间转换文件的简单命令行工具。

¥The xlsx-cli NodeJS script is available as a package on the SheetJS CDN. It is a straightforward command-line tool for translating files between supported spreadsheet file formats.

对于大多数常见的部署场景,可以安装服务器端平台,例如 NodeJS

¥For most common deployment scenarios, it is possible to install a server-side platform such as NodeJS.

强烈建议尽可能使用专用平台。

¥It is strongly recommended to use a dedicated platform when possible.

当目标计算机上无法安装专用服务器端脚本平台时,此演示中生成的独立程序非常有用。

¥The standalone programs generated in this demo are useful when a dedicated server-side scripting platform cannot be installed on the target computer.

NodeJS

此演示按框架组织:

¥This demo has been organized by framework:

V8

说明已移至 "V8" 演示。

¥The exposition has been moved to the "V8" demo.

BunJS

该展览已移至单独的页面。

¥The exposition has been moved to a separate page.

Deno

该展览已移至单独的页面。

¥The exposition has been moved to a separate page.

专用引擎

¥Dedicated Engines

以下 JS 引擎演示生成独立程序:

¥The following demos for JS engines produce standalone programs: