Xlsx sử dụng định dạng ô json_to_sheet

Trình phân tích cú pháp và trình ghi cho các định dạng bảng tính khác nhau. Triển khai phòng sạch Pure-JS từ thông số kỹ thuật chính thức, tài liệu liên quan và tệp thử nghiệm. Nhấn mạnh vào tính mạnh mẽ của phân tích cú pháp và viết, khả năng tương thích tính năng đa định dạng với biểu diễn JS thống nhất và khả năng tương thích trình duyệt ES3/ES5 trở lại IE6

Đây là phiên bản cộng đồng. Chúng tôi cũng cung cấp phiên bản chuyên nghiệp với các cải tiến về hiệu suất, các tính năng bổ sung như kiểu dáng và hỗ trợ chuyên dụng

Phiên bản chuyên nghiệp

Hỗ trợ thương mại

Tài liệu kết xuất

Trình diễn trong trình duyệt

Mã nguồn

Sự cố và Báo cáo lỗi

Hỗ trợ định dạng tệp cho các định dạng dữ liệu bảng tính đã biết

Biểu đồ các định dạng được hỗ trợ (bấm để hiển thị)

Xlsx sử dụng định dạng ô json_to_sheet

Xlsx sử dụng định dạng ô json_to_sheet

Kiểm tra trình duyệt

Xlsx sử dụng định dạng ô json_to_sheet

Xlsx sử dụng định dạng ô json_to_sheet
Xlsx sử dụng định dạng ô json_to_sheet
Xlsx sử dụng định dạng ô json_to_sheet
Xlsx sử dụng định dạng ô json_to_sheet
Xlsx sử dụng định dạng ô json_to_sheet
Xlsx sử dụng định dạng ô json_to_sheet

Mục lục

Mở rộng để hiển thị Mục lục
  • Cài đặt
    • Trình diễn hệ sinh thái JS
    • Mô-đun tùy chọn
    • Khả năng tương thích ECMAScript 5
  • Triết học
  • Phân tích sổ làm việc
    • Ví dụ phân tích cú pháp
    • Đọc trực tuyến
  • Làm việc với Sổ làm việc
    • Phân tích cú pháp và viết ví dụ
  • Viết sách bài tập
    • Viết ví dụ
    • Viết trực tuyến
  • giao diện
    • chức năng phân tích cú pháp
    • viết hàm
    • tiện ích
  • Định dạng bảng tính chung
    • cấu trúc chung
    • đối tượng tế bào
      • Loại dữ liệu
      • ngày
    • Đối tượng trang tính
      • đối tượng trang tính
      • Đối tượng biểu đồ
      • Đối tượng Macrosheet
      • đối tượng bảng đối thoại
    • đối tượng sổ làm việc
      • Thuộc tính tệp sổ làm việc
    • Thuộc tính cấp sổ làm việc
      • Tên được xác định
      • Chế độ xem sổ làm việc
      • Thuộc tính sổ làm việc khác
    • Tính năng tài liệu
      • công thức
      • Thuộc tính cột
      • Thuộc tính hàng
      • định dạng số
      • siêu liên kết
      • Nhận xét di động
      • Khả năng hiển thị trang tính
      • VBA và Macro
  • Tùy chọn phân tích cú pháp
    • Kiểu đầu vào
    • đoán loại tập tin
  • tùy chọn viết
    • Định dạng đầu ra được hỗ trợ
    • Loại đầu ra
  • Các chức năng tiện ích
    • Mảng đầu vào mảng
    • Mảng đối tượng đầu vào
    • Đầu vào bảng HTML
    • Đầu ra công thức
    • Đầu ra được phân tách bằng dấu phân cách
      • Văn bản Unicode UTF-16
    • Đầu ra HTML
    • JSON
  • Định dạng tệp
    • Excel 2007+ XML (XLSX/XLSM)
    • Excel 2. 0-95 (BIFF2/BIFF3/BIFF4/BIFF5)
    • Excel 97-2004 nhị phân (BIFF8)
    • Excel 2003-2004 (ML bảng tính)
    • Excel 2007+ Nhị phân (XLSB, BIFF12)
    • Giá trị được phân tách bằng dấu phân cách (CSV/TXT)
    • Các định dạng sổ làm việc khác
      • Hoa sen 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)
      • Quattro Pro (WQ1/WQ2/WB1/WB2/WB3/QPW)
      • Bảng tính OpenDocument (ODS/FODS)
      • Bảng tính văn phòng thống nhất (UOS1/2)
    • Các định dạng trang tính đơn khác
      • dBASE và Visual FoxPro (DBF)
      • Liên kết tượng trưng (SYLK)
      • Văn bản định dạng hoa sen (PRN)
      • Định dạng trao đổi dữ liệu (DIF)
      • HTML
      • Định dạng văn bản có định dạng (RTF)
      • Định dạng Bản ghi Ethercalc (ETH)
  • thử nghiệm
    • Nút
    • trình duyệt
    • Môi trường thử nghiệm
    • tập tin kiểm tra
  • Đóng góp
    • Hệ điều hành/Linux
    • các cửa sổ
    • bài kiểm tra
  • Giấy phép
  • Người giới thiệu

Cài đặt

Trong trình duyệt, chỉ cần thêm thẻ script

<script lang="javascript" src="dist/xlsx.full.min.js">script>

Tính khả dụng của CDN (nhấp để hiển thị)CDNURL
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
9https. // giải nén. com/xlsx/
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
0https. // jsdelivr. com/gói/npm/xlsx
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
1http. //cdnjs. com/libraries/xlsx
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
2https. //bó. chạy/xlsx@latest?name=XLSX

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
9 cung cấp phiên bản mới nhất tại

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>

Với npm

$ npm install xlsx

với bower

________số 8

Trình diễn hệ sinh thái JS

Thư mục

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
4 bao gồm các dự án mẫu cho

Framework và API

  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    5
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    6
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    7
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    8
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    9
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    50
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    51
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    52
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    53
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    54

Bó và dụng cụ

  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    55
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    56
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    57
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    58
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    59
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    00
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    01
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    02

Nền tảng và tích hợp

  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    03
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    04
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    05
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    06
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    07
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    08
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    09
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    10
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    11
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    12

Các ví dụ khác được bao gồm trong showcase

Mô-đun tùy chọn

Các tính năng tùy chọn (bấm để hiển thị)

Phiên bản nút tự động yêu cầu các mô-đun cho các tính năng bổ sung. Một số mô-đun này có kích thước khá lớn và chỉ cần thiết trong những trường hợp đặc biệt, vì vậy chúng không vận chuyển cùng với lõi. Để sử dụng trình duyệt, chúng phải được đưa vào trực tiếp

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
8

Một phiên bản thích hợp cho mỗi phụ thuộc được bao gồm trong thư mục dist/

Phiên bản một tệp hoàn chỉnh được tạo tại

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
13

Bản dựng mỏng hơn với hỗ trợ XLSX / HTML được tạo tại

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
14

Các bản dựng Webpack và Browserify bao gồm các mô-đun tùy chọn theo mặc định. Webpack có thể được cấu hình để loại bỏ hỗ trợ với

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
15

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
2

Khả năng tương thích ECMAScript 5

Vì thư viện sử dụng các chức năng như

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
16, các trình duyệt cũ hơn yêu cầu các miếng chêm cung cấp các chức năng còn thiếu

Để sử dụng miếng chêm, hãy thêm miếng chêm trước thẻ tập lệnh tải

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
17

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
5

Tập lệnh cũng bao gồm

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
18 và
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
19 để tải và lưu tệp trong Internet Explorer phiên bản 6-9. Tập lệnh
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
20 gói miếng chêm ở định dạng phù hợp với Photoshop và các sản phẩm Adobe khác

Triết học

Triết học (bấm vào để hiển thị)

Trước SheetJS, các API để xử lý tệp bảng tính có định dạng cụ thể. Các thư viện của bên thứ ba hỗ trợ một định dạng hoặc chúng liên quan đến một tập hợp các lớp riêng biệt cho từng loại tệp được hỗ trợ. Mặc dù XLSB đã được giới thiệu trong Excel 2007, nhưng không có gì ngoài SheetJS hoặc Excel hỗ trợ định dạng

Để thúc đẩy chế độ xem không biết định dạng, js-xlsx bắt đầu từ một biểu diễn JS thuần túy mà chúng tôi gọi là "Định dạng bảng tính chung". Việc nhấn mạnh một biểu diễn đối tượng thống nhất cho phép các tính năng mới như chuyển đổi định dạng (đọc mẫu XLSX và lưu dưới dạng XLS) và loại bỏ sự lộn xộn của các lớp. Bằng cách trừu tượng hóa sự phức tạp của các định dạng khác nhau, các công cụ không cần lo lắng về loại tệp cụ thể

Biểu diễn đối tượng đơn giản kết hợp với thực hành viết mã cẩn thận cho phép sử dụng các trường hợp trong các trình duyệt cũ hơn và trong các môi trường thay thế như ExtendScript và Web Worker. Việc sử dụng các tính năng mới nhất và tốt nhất luôn luôn hấp dẫn, nhưng chúng có xu hướng yêu cầu các phiên bản trình duyệt mới nhất, hạn chế khả năng sử dụng

Các chức năng tiện ích nắm bắt các trường hợp sử dụng phổ biến như tạo các đối tượng JS hoặc HTML. Hầu hết các hoạt động đơn giản chỉ cần một vài dòng mã. Các hoạt động phức tạp hơn thường dễ thực hiện

Excel đẩy định dạng XLSX làm mặc định bắt đầu từ Excel 2007. Tuy nhiên, có những định dạng khác với các thuộc tính hấp dẫn hơn. Ví dụ: định dạng XLSB về mặt tinh thần tương tự như XLSX nhưng các tệp thường có xu hướng chiếm ít hơn một nửa dung lượng và mở nhanh hơn nhiều. Mặc dù có sẵn trình ghi XLSX, nhưng các trình ghi định dạng khác cũng có sẵn để người dùng có thể tận dụng các đặc điểm độc đáo của từng định dạng

Trọng tâm chính của Phiên bản cộng đồng là trao đổi dữ liệu chính xác, tập trung vào trích xuất dữ liệu từ bất kỳ biểu diễn dữ liệu tương thích nào và xuất dữ liệu ở nhiều định dạng khác nhau phù hợp với mọi giao diện của bên thứ ba

Phân tích sổ làm việc

Để phân tích cú pháp, bước đầu tiên là đọc tệp. Điều này liên quan đến việc thu thập dữ liệu và đưa nó vào thư viện. Dưới đây là một vài tình huống phổ biến

nodejs đọc một tệp (bấm để hiển thị)

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
21 chỉ khả dụng trong môi trường máy chủ. Các trình duyệt không có API để đọc các tệp tùy ý được cung cấp một đường dẫn, vì vậy phải sử dụng một chiến lược khác

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */

Photoshop ExtendScript đọc một tệp (bấm để hiển thị)

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
21 kết thúc logic
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
23 trong Photoshop và các mục tiêu ExtendScript khác. Đường dẫn đã chỉ định phải là đường dẫn tuyệt đối

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */

Bản demo

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
24 bao gồm một ví dụ phức tạp hơn

Trình duyệt đọc phần tử BẢNG từ trang (bấm để hiển thị)

Các hàm tiện ích

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
25 và
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
26 lấy một phần tử DOM TABLE và lặp qua các nút con

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
5

Nhiều bảng trên một trang web có thể được chuyển đổi thành các trang tính riêng lẻ

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
0

Ngoài ra, mã HTML có thể được trích xuất và phân tích cú pháp

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
1

Tệp tải xuống trình duyệt (ajax) (bấm để hiển thị)

Ghi chú. để biết ví dụ đầy đủ hơn hoạt động trong các trình duyệt cũ hơn, hãy xem bản trình diễn tại http. // oss. trang tính. com/js-xlsx/ajax. html. Bản trình diễn

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
27 bao gồm nhiều ví dụ hơn với
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
28 và
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
29

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
2

Trình duyệt kéo và thả (bấm để hiển thị)

Kéo và thả sử dụng API HTML5

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
30

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
3

Phần tử biểu mẫu tải lên tệp trình duyệt (bấm để hiển thị)

Dữ liệu từ các phần tử đầu vào tệp có thể được xử lý bằng cách sử dụng cùng một API

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
30 như trong ví dụ kéo và thả

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
4

Bản trình diễn

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
32 hiển thị kịch bản dự phòng tương thích với IE

Các trường hợp chuyên biệt hơn, bao gồm xử lý tệp ứng dụng dành cho thiết bị di động, được đề cập trong các bản trình diễn đi kèm

Ví dụ phân tích cú pháp

  • http. // oss. trang tính. com/js-xlsx/ API tệp HTML5 / Văn bản Base64 / Công nhân web

Lưu ý rằng các phiên bản IE cũ hơn không hỗ trợ API tệp HTML5, vì vậy chế độ Base64 được sử dụng để thử nghiệm

Nhận mã hóa Base64 trên OSX/Windows (bấm để hiển thị)

Trên OSX, bạn có thể nhận mã hóa Base64 với

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
5

Trên Windows XP trở lên, bạn có thể lấy mã hóa Base64 bằng cách sử dụng

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
33

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
6

(Ghi chú. Bạn phải mở tệp và xóa các dòng đầu trang và chân trang)

  • http. // oss. trang tính. com/js-xlsx/ajax. html XMLHttpRequest

Đọc trực tuyến

Tại sao không có API đọc trực tuyến?

Các định dạng phổ biến và thú vị nhất (XLS, XLSX/M, XLSB, ODS) cuối cùng là các vùng chứa tệp ZIP hoặc CFB. Không định dạng nào đặt cấu trúc thư mục ở đầu tệp. Các tệp ZIP đặt các bản ghi Thư mục Trung tâm ở cuối tệp logic, trong khi các tệp CFB có thể đặt thông tin lưu trữ ở bất kỳ đâu trong tệp. Do đó, để xử lý đúng các định dạng này, chức năng phát trực tuyến sẽ phải đệm toàn bộ tệp trước khi bắt đầu. Điều đó trái với kỳ vọng của việc phát trực tuyến, vì vậy chúng tôi không cung cấp bất kỳ API đọc trực tuyến nào

Khi xử lý Luồng có thể đọc được, cách tiếp cận đơn giản nhất là đệm luồng và xử lý toàn bộ nội dung ở cuối. Điều này có thể được thực hiện với một tệp tạm thời hoặc bằng cách nối rõ ràng luồng

Các luồng kết nối rõ ràng (bấm để hiển thị)

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
7

Các giải pháp mạnh mẽ hơn có sẵn bằng cách sử dụng các mô-đun như

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
34

Ghi vào hệ thống tập tin đầu tiên (bấm vào để hiển thị)

Ví dụ này sử dụng

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
35 để tạo tên tệp

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
8

Làm việc với Sổ làm việc

Định dạng đối tượng đầy đủ được mô tả sau trong README này

Đọc một ô cụ thể (bấm để hiển thị)

Ví dụ này trích xuất giá trị được lưu trữ trong ô A1 từ trang tính đầu tiên

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
9

Thêm một trang tính mới vào sổ làm việc (bấm để hiển thị)

Ví dụ này sử dụng

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
36 để tạo một trang tính và
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
37 để nối thêm trang tính vào sổ làm việc

$ npm install xlsx
0

Tạo sổ làm việc mới từ đầu (bấm để hiển thị)

Đối tượng sổ làm việc chứa một mảng tên

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
38 và tên trang tính ánh xạ đối tượng
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
39 với các đối tượng trang tính. Hàm tiện ích
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
40 tạo một đối tượng sổ làm việc mới

$ npm install xlsx
1

Sổ làm việc mới trống và không chứa trang tính nào. Các chức năng ghi sẽ lỗi nếu sổ làm việc trống

Phân tích cú pháp và viết ví dụ

  • http. //sheetjs. com/demos/sửa đổi. html đọc + sửa đổi + ghi tệp

  • https. //github. com/SheetJS/js-xlsx/blob/master/bin/xlsx. nút njs

Phiên bản nút cài đặt công cụ dòng lệnh

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
41 có thể đọc các tệp bảng tính và xuất nội dung ở nhiều định dạng khác nhau. Nguồn có sẵn tại
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
42 trong thư mục bin

Một số hàm trợ giúp trong

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
43 tạo ra các dạng xem khác nhau của trang tính

  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    44 tạo CSV
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    45 tạo Văn bản có định dạng UTF16
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    46 tạo HTML
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    47 tạo ra một mảng các đối tượng
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    48 tạo ra một danh sách các công thức

Viết sách bài tập

Để viết, bước đầu tiên là tạo dữ liệu đầu ra. Các hàm trợ giúp

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
49 và
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
50 sẽ tạo dữ liệu ở các định dạng khác nhau phù hợp để phổ biến. Bước thứ hai là thực sự chia sẻ dữ liệu với điểm cuối. Giả sử
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
51 là một đối tượng sổ làm việc

nodejs viết một tệp (bấm để hiển thị)

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
52 sử dụng
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
53 trong môi trường máy chủ

$ npm install xlsx
2

Photoshop ExtendScript viết một tập tin (bấm để hiển thị)

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
50 kết thúc logic
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
23 trong Photoshop và các mục tiêu ExtendScript khác. Đường dẫn đã chỉ định phải là đường dẫn tuyệt đối

$ npm install xlsx
3

Bản demo

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
24 bao gồm một ví dụ phức tạp hơn

Trình duyệt thêm phần tử BẢNG vào trang (bấm để hiển thị)

Hàm tiện ích

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
57 tạo mã HTML có thể được thêm vào bất kỳ phần tử DOM nào

$ npm install xlsx
4

Tệp tải lên trình duyệt (ajax) (bấm để hiển thị)

Một ví dụ hoàn chỉnh sử dụng XHR được bao gồm trong bản trình diễn XHR, cùng với các ví dụ về thư viện tìm nạp và trình bao bọc. Ví dụ này giả định rằng máy chủ có thể xử lý các tệp được mã hóa Base64 (xem bản demo cho máy chủ nodejs cơ bản)

$ npm install xlsx
5

Tệp lưu trình duyệt (bấm để hiển thị)

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
52 kết thúc một số kỹ thuật để kích hoạt lưu tệp

  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    59 API trình duyệt tạo URL đối tượng cho tệp mà thư viện sử dụng bằng cách tạo liên kết và buộc nhấp chuột. Nó được hỗ trợ trong các trình duyệt hiện đại
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    60 là API IE10+ để kích hoạt lưu tệp
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    61 sử dụng VBScript và ActiveX để ghi tệp trong IE6+ cho Windows XP và Windows 7. Miếng chêm phải được bao gồm trong trang chứa HTML

Không có cách tiêu chuẩn nào để xác định xem tệp thực đã được tải xuống chưa

$ npm install xlsx
6

Tệp lưu trình duyệt (tương thích) (bấm để hiển thị)

Các kỹ thuật

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
52 hoạt động với hầu hết các trình duyệt hiện đại cũng như IE cũ hơn. Đối với các trình duyệt cũ hơn nhiều, có các cách giải quyết được triển khai bởi các thư viện trình bao bọc

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
63 dụng cụ
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
64. Ghi chú.
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
52 sẽ tự động gọi cho
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
64 nếu có

$ npm install xlsx
7

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
67 sử dụng nút Flash SWF để tạo tệp cục bộ, phù hợp với môi trường không có ActiveX

$ npm install xlsx
8

Bản trình diễn

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
32 hiển thị kịch bản dự phòng tương thích với IE

Các bản demo đi kèm bao gồm các ứng dụng dành cho thiết bị di động và các triển khai đặc biệt khác

Viết ví dụ

  • http. //sheetjs. com/bản trình diễn/bảng. html xuất bảng HTML
  • http. //sheetjs. com/demos/writexlsx. html tạo một tệp đơn giản

Viết trực tuyến

Các chức năng ghi trực tuyến có sẵn trong đối tượng

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
69. Chúng lấy các đối số giống như các hàm ghi bình thường nhưng trả về Luồng có thể đọc được. Chúng chỉ được hiển thị trong NodeJS

  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    70 là phiên bản phát trực tuyến của
    <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    44
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    72 là phiên bản phát trực tuyến của
    <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    46
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    74 là phiên bản phát trực tuyến của
    <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    47
nodejs chuyển sang CSV và ghi tệp (bấm để hiển thị)

$ npm install xlsx
9

nodejs viết luồng JSON lên màn hình (bấm để hiển thị)

$ bower install js-xlsx
0

https. //github. ống com/sheetjs/sheetaki ghi luồng vào phản hồi của nodejs

giao diện

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
76 là biến được hiển thị trong trình duyệt và biến nút đã xuất

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
77 là phiên bản của thư viện (được thêm vào bởi tập lệnh xây dựng)

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
78 là phiên bản nhúng của thư viện định dạng

chức năng phân tích cú pháp

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
79 cố gắng phân tích cú pháp
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
80

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
81 cố gắng đọc
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
82 và phân tích cú pháp

Tùy chọn phân tích cú pháp được mô tả trong phần Tùy chọn phân tích cú pháp

viết hàm

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
83 cố gắng viết sổ làm việc
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
84

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
85 cố gắng viết
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
84 thành
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
82. Trong môi trường dựa trên trình duyệt, nó sẽ cố gắng buộc tải xuống phía máy khách

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
88 cố gắng viết
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
84 thành
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
82. Nếu bỏ qua
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
91, người viết sẽ sử dụng đối số thứ ba làm hàm gọi lại

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
69 chứa một tập hợp các chức năng ghi trực tuyến

Các tùy chọn viết được mô tả trong phần Tùy chọn viết

tiện ích

Các tiện ích có sẵn trong đối tượng

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
43 và được mô tả trong phần Chức năng tiện ích

nhập khẩu

  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    94 chuyển đổi một mảng các mảng dữ liệu JS thành một trang tính
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    95 chuyển đổi một mảng các đối tượng JS thành một trang tính
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    26 chuyển đổi phần tử DOM TABLE thành trang tính
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    97 thêm một mảng các mảng dữ liệu JS vào một trang tính hiện có
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    98 thêm một mảng các đối tượng JS vào một trang tính hiện có

xuất khẩu

  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    99 chuyển đổi một đối tượng trang tính thành một mảng các đối tượng JSON
  • $ npm install xlsx
    00 tạo đầu ra giá trị được phân tách bằng dấu phân cách
  • $ npm install xlsx
    01 tạo văn bản có định dạng UTF16
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    57 tạo đầu ra HTML
  • $ npm install xlsx
    03 tạo danh sách các công thức (có giá trị dự phòng)

Thao tác ô và địa chỉ ô

  • $ npm install xlsx
    04 tạo giá trị văn bản cho một ô (sử dụng định dạng số)
  • $ npm install xlsx
    05 chuyển đổi giữa các hàng được lập chỉ mục 0 và các hàng được lập chỉ mục 1
  • $ npm install xlsx
    06 chuyển đổi giữa các cột có chỉ mục 0 và tên cột
  • $ npm install xlsx
    07 chuyển đổi địa chỉ ô
  • $ npm install xlsx
    08 chuyển đổi phạm vi ô

Định dạng bảng tính chung

js-xlsx tuân theo Định dạng bảng tính chung (CSF)

cấu trúc chung

Các đối tượng địa chỉ ô được lưu trữ dưới dạng

$ npm install xlsx
09 trong đó
$ npm install xlsx
10 và
$ npm install xlsx
11 lần lượt là số cột và hàng được lập chỉ mục 0. Ví dụ: địa chỉ ô
$ npm install xlsx
12 được đại diện bởi đối tượng
$ npm install xlsx
13

Các đối tượng phạm vi ô được lưu trữ dưới dạng

$ npm install xlsx
14 trong đó
$ npm install xlsx
15 là ô đầu tiên và
$ npm install xlsx
16 là ô cuối cùng trong phạm vi. Các phạm vi được bao gồm. Ví dụ: phạm vi
$ npm install xlsx
17 được đại diện bởi đối tượng
$ npm install xlsx
18. Các hàm tiện ích thực hiện duyệt theo thứ tự hàng lớn của một phạm vi trang tính

$ bower install js-xlsx
1

đối tượng tế bào

Các đối tượng ô là các đối tượng JS đơn giản với các khóa và giá trị tuân theo quy ước

Mô tả khóa
$ npm install xlsx
19giá trị thô (xem phần Loại dữ liệu để biết thêm thông tin)
$ npm install xlsx
20văn bản được định dạng (nếu có)
$ npm install xlsx
21loại.
$ npm install xlsx
22 Boolean,
$ npm install xlsx
23 Error,
$ npm install xlsx
24 Number,
$ npm install xlsx
25 Date,
$ npm install xlsx
26 Text,
$ npm install xlsx
27 Stub
$ npm install xlsx
28công thức ô được mã hóa dưới dạng chuỗi kiểu A1 (nếu có)
$ npm install xlsx
29phạm vi của mảng kèm theo nếu công thức là công thức mảng (nếu có)
$ npm install xlsx
30mã hóa văn bản đa dạng thức (nếu có)
$ npm install xlsx
31HTML

Các tiện ích xuất tích hợp sẵn (chẳng hạn như trình xuất CSV) sẽ sử dụng văn bản

$ npm install xlsx
20 nếu có. Để thay đổi một giá trị, hãy nhớ xóa
$ npm install xlsx
39 (hoặc đặt thành
$ npm install xlsx
40) trước khi thử xuất. Các tiện ích sẽ tạo lại văn bản
$ npm install xlsx
20 từ định dạng số (
$ npm install xlsx
42) và giá trị thô nếu có thể

Công thức mảng thực tế được lưu trữ trong trường

$ npm install xlsx
28 của ô đầu tiên trong phạm vi mảng. Các ô khác trong phạm vi sẽ bỏ qua trường
$ npm install xlsx
28

Loại dữ liệu

Giá trị thô được lưu trữ trong thuộc tính giá trị

$ npm install xlsx
19, được diễn giải dựa trên thuộc tính loại
$ npm install xlsx
21. Sự tách biệt này cho phép biểu diễn các số cũng như văn bản số. Có 6 loại ô hợp lệ

LoạiMô tả
$ npm install xlsx
22Boolean. giá trị được hiểu là JS
$ npm install xlsx
48
$ npm install xlsx
23Error. giá trị là một mã số và tài sản
$ npm install xlsx
20 lưu trữ tên chung **
$ npm install xlsx
24Number. giá trị là một JS
$ npm install xlsx
52 **______725Date. giá trị là một đối tượng hoặc chuỗi JS
$ npm install xlsx
54 được phân tích thành Ngày **
$ npm install xlsx
26Text. giá trị được hiểu là JS
$ npm install xlsx
56 và được viết dưới dạng văn bản **
$ npm install xlsx
27Stub. ô sơ khai trống bị các tiện ích xử lý dữ liệu bỏ qua **Giá trị lỗi và diễn giải (bấm để hiển thị)Giá trịLỗi Ý nghĩa
$ npm install xlsx
58
$ npm install xlsx
59
$ npm install xlsx
60
$ npm install xlsx
61
$ npm install xlsx
62
$ npm install xlsx
63
$ npm install xlsx
64
$ npm install xlsx
65
$ npm install xlsx
66
$ npm install xlsx
67
$ npm install xlsx
68
$ npm install xlsx
69
$ npm install xlsx
70
$ npm install xlsx
71
$ npm install xlsx
72
$ npm install xlsx
73

Loại

$ npm install xlsx
24 là loại Số. Điều này bao gồm tất cả các dạng dữ liệu mà Excel lưu trữ dưới dạng số, chẳng hạn như ngày/thời gian và trường Boolean. Excel độc quyền sử dụng dữ liệu có thể vừa với số dấu phẩy động IEEE 754, giống như Số JS, đối với trường ________ 719 giữ số thô. Trường
$ npm install xlsx
20 giữ văn bản được định dạng. Ngày được lưu trữ dưới dạng số theo mặc định và được chuyển đổi bằng
$ npm install xlsx
77

Loại

$ npm install xlsx
25 là loại Ngày, chỉ được tạo khi tùy chọn
$ npm install xlsx
79 được thông qua. Vì JSON không có loại Ngày tự nhiên, nên các trình phân tích cú pháp thường được mong đợi sẽ lưu trữ các chuỗi Ngày theo tiêu chuẩn ISO 8601 giống như bạn sẽ nhận được từ
$ npm install xlsx
80. Mặt khác, người viết và người xuất sẽ có thể xử lý chuỗi ngày và đối tượng Ngày JS. Lưu ý rằng Excel bỏ qua các công cụ sửa đổi múi giờ và xử lý tất cả các ngày theo múi giờ địa phương. Thư viện không sửa lỗi này

Loại

$ npm install xlsx
26 là loại Chuỗi. Các giá trị được lưu trữ rõ ràng dưới dạng văn bản. Excel sẽ hiểu các ô này là "số được lưu dưới dạng văn bản". Các tệp Excel được tạo sẽ tự động loại bỏ loại lỗi đó, nhưng các định dạng khác có thể gây ra lỗi

Loại

$ npm install xlsx
27 đại diện cho các ô sơ khai trống. Chúng được tạo trong trường hợp các ô không có giá trị được gán nhưng chứa nhận xét hoặc siêu dữ liệu khác. Chúng bị bỏ qua bởi các chức năng tiện ích xử lý dữ liệu thư viện lõi. Theo mặc định, các ô này không được tạo;

ngày

Chi tiết mã ngày Excel (bấm để hiển thị)

Theo mặc định, Excel lưu trữ ngày tháng dưới dạng số với mã định dạng chỉ định xử lý ngày tháng. Ví dụ: ngày

$ npm install xlsx
85 được lưu dưới dạng số
$ npm install xlsx
86 với định dạng số là
$ npm install xlsx
87. Mô-đun
$ npm install xlsx
88 hiểu các định dạng số và thực hiện chuyển đổi thích hợp

XLSX cũng hỗ trợ loại ngày đặc biệt

$ npm install xlsx
25 trong đó dữ liệu là chuỗi ngày theo tiêu chuẩn ISO 8601. Trình định dạng chuyển đổi ngày trở lại thành một số

Hành vi mặc định cho tất cả các trình phân tích cú pháp là tạo các ô số. Đặt

$ npm install xlsx
79 thành true sẽ buộc trình tạo lưu trữ ngày

Múi giờ và ngày (bấm để hiển thị)

Excel không có khái niệm riêng về thời gian toàn cầu. Tất cả thời gian được chỉ định theo múi giờ địa phương. Các giới hạn của Excel ngăn việc chỉ định ngày tuyệt đối thực

Theo Excel, thư viện này xử lý tất cả các ngày liên quan đến múi giờ địa phương

kỷ nguyên. 1900 và 1904 (bấm vào để hiển thị)

Excel hỗ trợ hai kỷ nguyên (ngày 1 tháng 1 năm 1900 và ngày 1 tháng 1 năm 1904), xem "1900 so với. Bài viết Hệ thống ngày tháng năm 1904". Kỷ nguyên của sổ làm việc có thể được xác định bằng cách kiểm tra thuộc tính

$ npm install xlsx
91 của sổ làm việc

$ bower install js-xlsx
2

Đối tượng trang tính

Mỗi khóa không bắt đầu bằng

$ npm install xlsx
92 ánh xạ tới một ô (sử dụng ký hiệu
$ npm install xlsx
93)

$ npm install xlsx
94 trả về đối tượng ô cho địa chỉ đã chỉ định

Các phím trang tính đặc biệt (có thể truy cập dưới dạng

$ npm install xlsx
95, mỗi phím bắt đầu bằng
$ npm install xlsx
92)

  • $ npm install xlsx
    97. Phạm vi dựa trên A-1 đại diện cho phạm vi trang tính. Các chức năng làm việc với trang tính nên sử dụng tham số này để xác định phạm vi. Các ô được gán bên ngoài phạm vi không được xử lý. Đặc biệt, khi viết một trang tính bằng tay, các ô nằm ngoài phạm vi không được bao gồm

    Các chức năng xử lý trang tính phải kiểm tra sự hiện diện của trường

    $ npm install xlsx
    98. Nếu
    $ npm install xlsx
    98 bị bỏ qua hoặc không phải là một phạm vi hợp lệ, các chức năng có thể tự do coi trang tính là trống hoặc cố gắng đoán phạm vi. Các tiện ích tiêu chuẩn đi kèm với thư viện này coi các trang tính là trống (ví dụ: đầu ra CSV là chuỗi trống)

    Khi đọc một trang tính với bộ thuộc tính

    $ bower install js-xlsx
    00, tham số ref sẽ sử dụng phạm vi giới hạn. Phạm vi ban đầu được đặt tại
    $ bower install js-xlsx
    01

  • $ bower install js-xlsx
    02. Đối tượng đại diện cho lề trang. Các giá trị mặc định tuân theo giá trị đặt trước "bình thường" của Excel. Excel cũng có giá trị đặt trước "rộng" và "hẹp" nhưng chúng được lưu dưới dạng phép đo thô. Các thuộc tính chính được liệt kê dưới đây

Page margin details (click to show)keydescription"normal""wide""narrow"
$ bower install js-xlsx
03left margin (inches)
$ bower install js-xlsx
04
$ bower install js-xlsx
05
$ bower install js-xlsx
06
$ bower install js-xlsx
07right margin (inches)
$ bower install js-xlsx
04
$ bower install js-xlsx
05
$ bower install js-xlsx
06
$ bower install js-xlsx
11top margin (inches)
$ bower install js-xlsx
12
$ bower install js-xlsx
05
$ bower install js-xlsx
12
$ bower install js-xlsx
15bottom margin (inches)
$ bower install js-xlsx
12
$ bower install js-xlsx
05
$ bower install js-xlsx
12
$ bower install js-xlsx
19header margin (inches)
$ bower install js-xlsx
20
$ bower install js-xlsx
21
$ bower install js-xlsx
20
$ bower install js-xlsx
23footer margin (inches)
$ bower install js-xlsx
20
$ bower install js-xlsx
21
$ bower install js-xlsx
20

$ bower install js-xlsx
3

đối tượng trang tính

Ngoài các phím trang tính cơ sở, trang tính cũng thêm

  • $ bower install js-xlsx
    27. mảng các đối tượng thuộc tính cột. Độ rộng cột thực sự được lưu trữ trong các tệp theo cách chuẩn hóa, được đo bằng "Chiều rộng chữ số tối đa" (chiều rộng lớn nhất của các chữ số được hiển thị 0-9, tính bằng pixel). Khi được phân tích cú pháp, các đối tượng cột lưu chiều rộng pixel trong trường
    $ bower install js-xlsx
    28, chiều rộng ký tự trong trường
    $ bower install js-xlsx
    29 và chiều rộng chữ số tối đa trong trường
    $ bower install js-xlsx
    30

  • $ bower install js-xlsx
    31. mảng các đối tượng thuộc tính hàng như được giải thích sau trong tài liệu. Mỗi đối tượng hàng mã hóa các thuộc tính bao gồm chiều cao hàng và khả năng hiển thị

  • $ bower install js-xlsx
    32. mảng các đối tượng phạm vi tương ứng với các ô được hợp nhất trong trang tính. Các định dạng văn bản thuần túy không hỗ trợ hợp nhất các ô. Xuất CSV sẽ ghi tất cả các ô trong phạm vi hợp nhất nếu chúng tồn tại, vì vậy hãy đảm bảo rằng chỉ ô đầu tiên (phía trên bên trái) trong phạm vi được đặt

  • $ bower install js-xlsx
    33. định cấu hình cách các đường viền sẽ hoạt động. Tùy chọn mặc định cho cài đặt mặc định trong Excel 2019

keyExcel featuredefault
$ bower install js-xlsx
34Bỏ chọn "Các hàng tóm tắt bên dưới chi tiết"
$ bower install js-xlsx
35
$ bower install js-xlsx
03Bỏ chọn "Các hàng tóm tắt bên phải chi tiết"
$ bower install js-xlsx
35
  • $ bower install js-xlsx
    38. đối tượng của thuộc tính bảo vệ bảng ghi. Khóa
    $ bower install js-xlsx
    39 chỉ định mật khẩu cho các định dạng hỗ trợ trang tính được bảo vệ bằng mật khẩu (XLSX/XLSB/XLS). Người viết sử dụng phương pháp obfuscation XOR. Các phím sau kiểm soát việc bảo vệ trang tính -- được đặt thành
    $ bower install js-xlsx
    35 để bật một tính năng khi trang tính bị khóa hoặc được đặt thành
    $ npm install xlsx
    84 để tắt một tính năng
Worksheet Protection Details (click to show)keyfeature (true=disabled / false=enabled)default
$ bower install js-xlsx
42Select locked cellsenabled
$ bower install js-xlsx
43Select unlocked cellsenabled
$ bower install js-xlsx
44Format cellsdisabled
$ bower install js-xlsx
45Format columnsdisabled
$ bower install js-xlsx
46Format rowsdisabled
$ bower install js-xlsx
47Insert columnsdisabled
$ bower install js-xlsx
48Insert rowsdisabled
$ bower install js-xlsx
49Insert hyperlinksdisabled
$ bower install js-xlsx
50Delete columnsdisabled
$ bower install js-xlsx
51Delete rowsdisabled
$ bower install js-xlsx
52Sortdisabled
$ bower install js-xlsx
53Filterdisabled
$ bower install js-xlsx
54Use PivotTable reportsdisabled
$ bower install js-xlsx
55Edit objectsenabled
$ bower install js-xlsx
56Edit scenariosenabled
  • $ bower install js-xlsx
    57. Đối tượng AutoFilter theo lược đồ

$ bower install js-xlsx
4

Đối tượng biểu đồ

Bảng biểu đồ được thể hiện dưới dạng trang tiêu chuẩn. Chúng được phân biệt với thuộc tính

$ bower install js-xlsx
58 được đặt thành
$ bower install js-xlsx
59

Dữ liệu cơ bản và

$ npm install xlsx
98 đề cập đến dữ liệu được lưu trong bộ nhớ cache trong biểu đồ. Hàng đầu tiên của biểu đồ là tiêu đề cơ bản

Đối tượng Macrosheet

Macrosheet được biểu diễn dưới dạng các sheet tiêu chuẩn. Chúng được phân biệt với thuộc tính

$ bower install js-xlsx
58 được đặt thành
$ bower install js-xlsx
62

đối tượng bảng đối thoại

Dialogsheets được biểu diễn dưới dạng các sheet tiêu chuẩn. Chúng được phân biệt với thuộc tính

$ bower install js-xlsx
58 được đặt thành
$ bower install js-xlsx
64

đối tượng sổ làm việc

$ bower install js-xlsx
65 là danh sách có thứ tự của các trang tính trong sổ làm việc

$ bower install js-xlsx
66 trả về một đối tượng đại diện cho trang tính

$ bower install js-xlsx
67 là một đối tượng lưu trữ các thuộc tính tiêu chuẩn.
$ bower install js-xlsx
68 lưu trữ các thuộc tính tùy chỉnh. Do các thuộc tính tiêu chuẩn của XLS khác với tiêu chuẩn của XLSX nên việc phân tích cú pháp XLS lưu trữ các thuộc tính cốt lõi ở cả hai nơi

$ bower install js-xlsx
69 lưu trữ các thuộc tính cấp sổ làm việc

Thuộc tính tệp sổ làm việc

Các định dạng tệp khác nhau sử dụng các tên nội bộ khác nhau cho thuộc tính tệp. Đối tượng sổ làm việc

$ bower install js-xlsx
70 bình thường hóa tên

Thuộc tính tệp (nhấp để hiển thị)Tên JSMô tả Excel
$ bower install js-xlsx
71Tab tóm tắt "Tiêu đề"
$ bower install js-xlsx
72Tab tóm tắt "Chủ đề"
$ bower install js-xlsx
73Tab tóm tắt "Tác giả"
$ bower install js-xlsx
74Tab tóm tắt "Người quản lý"
$ bower install js-xlsx
75Tab tóm tắt "Công ty"
$ bower install js-xlsx
76Tab tóm tắt "Danh mục"
$ bower install js-xlsx
77Tab tóm tắt "Từ khóa"
$ bower install js-xlsx
78Tab tóm tắt "Nhận xét"
$ bower install js-xlsx
79Thống kê

Ví dụ: để đặt thuộc tính tiêu đề sổ làm việc

$ bower install js-xlsx
5

Các thuộc tính tùy chỉnh được thêm vào đối tượng sổ làm việc

$ bower install js-xlsx
81

$ bower install js-xlsx
6

Người viết sẽ xử lý khóa

$ bower install js-xlsx
70 của đối tượng tùy chọn

$ bower install js-xlsx
7

Thuộc tính cấp sổ làm việc

$ bower install js-xlsx
69 lưu trữ các thuộc tính cấp sổ làm việc

Tên được xác định

$ bower install js-xlsx
84 là một mảng các đối tượng tên được xác định có các khóa

Thuộc tính tên đã xác định (bấm để hiển thị)Mô tả chính
$ bower install js-xlsx
85Phạm vi tên. Sheet Index (0 = first sheet) or
$ bower install js-xlsx
86 (Workbook)
$ bower install js-xlsx
87Case-sensitive name. Các quy tắc tiêu chuẩn được áp dụng **
$ bower install js-xlsx
88A1-style Reference (
$ bower install js-xlsx
89)
$ bower install js-xlsx
90Comment (chỉ áp dụng cho XLS/XLSX/XLSB)

Excel allows two sheet-scoped defined names to share the same name. Tuy nhiên, tên trong phạm vi trang tính không thể xung đột với tên trong phạm vi sổ làm việc. Người viết sổ làm việc có thể không thực thi ràng buộc này

Chế độ xem sổ làm việc

$ bower install js-xlsx
91 is an array of workbook view objects which have the keys

KeyDescription
$ bower install js-xlsx
92Nếu đúng, hiển thị từ phải sang trái

Thuộc tính sổ làm việc khác

$ bower install js-xlsx
93 giữ các thuộc tính sổ làm việc khác

KeyDescription
$ bower install js-xlsx
94VBA Project Workbook Code Name
$ bower install js-xlsx
95epoch. 0/false cho hệ thống 1900, 1/true cho 1904
$ bower install js-xlsx
96Cảnh báo hoặc tước thông tin nhận dạng cá nhân khi lưu

Tính năng tài liệu

Ngay cả đối với các tính năng cơ bản như lưu trữ ngày tháng, các định dạng Excel chính thức lưu trữ cùng một nội dung theo những cách khác nhau. Trình phân tích cú pháp dự kiến ​​sẽ chuyển đổi từ biểu diễn định dạng tệp cơ bản sang Định dạng bảng tính chung. Người viết dự kiến ​​​​sẽ chuyển đổi từ CSF trở lại định dạng tệp cơ bản

công thức

Chuỗi công thức kiểu A1 được lưu trữ trong trường

$ npm install xlsx
28. Mặc dù các định dạng tệp khác nhau lưu trữ các công thức theo những cách khác nhau, các định dạng được dịch. Mặc dù một số định dạng lưu trữ các công thức có dấu bằng ở đầu, các công thức CSF không bắt đầu bằng
$ bower install js-xlsx
98

Representation of A1=1, A2=2, A3=A1+A2 (click to show)

$ bower install js-xlsx
8

Shared formulae are decompressed and each cell has the formula corresponding to its cell. Writers generally do not attempt to generate shared formulae

Cells with formula entries but no value will be serialized in a way that Excel and other spreadsheet tools will recognize. This library will not automatically compute formula results. For example, to compute

$ bower install js-xlsx
99 in a worksheet

Formula without known value (click to show)

$ bower install js-xlsx
9

Array Formulae

Array formulae are stored in the top-left cell of the array block. All cells of an array formula have a

$ npm install xlsx
29 field corresponding to the range. A single-cell formula can be distinguished from a plain formula by the presence of
$ npm install xlsx
29 field

Array Formula examples (click to show)

For example, setting the cell

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
802 to the array formula
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
803

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
80

For a multi-cell array formula, every cell has the same array range but only the first cell specifies the formula. Consider

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
804

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
81

Utilities and writers are expected to check for the presence of a

$ npm install xlsx
29 field and ignore any possible formula element
$ npm install xlsx
28 in cells other than the starting cell. They are not expected to perform validation of the formulae

Formula Output Utility Function (click to show)

The

$ npm install xlsx
03 method generates one line per formula or array formula. Array formulae are rendered in the form
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
808 while plain cells are rendered in the form
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
809. Note that string literals are prefixed with an apostrophe
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
810, consistent with Excel's formula bar display

Formulae File Format Details (click to show)Storage RepresentationFormatsReadWriteA1-style stringsXLSX⭕⭕RC-style stringsXLML and plain text⭕⭕BIFF Parsed formulaeXLSB and all XLS formats⭕OpenFormula formulaeODS/FODS/UOS⭕⭕

Since Excel prohibits named cells from colliding with names of A1 or RC style cell references, a (not-so-simple) regex conversion is possible. BIFF Parsed formulae have to be explicitly unwound. OpenFormula formulae can be converted with regular expressions

Thuộc tính cột

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
811 array in each worksheet, if present, is a collection of
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
812 objects which have the following properties

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
82

Why are there three width types? (click to show)

There are three different width types corresponding to the three different ways spreadsheets store column widths

SYLK and other plain text formats use raw character count. Contemporaneous tools like Visicalc and Multiplan were character based. Since the characters had the same width, it sufficed to store a count. This tradition was continued into the BIFF formats

SpreadsheetML (2003) tried to align with HTML by standardizing on screen pixel count throughout the file. Column widths, row heights, and other measures use pixels. When the pixel and character counts do not align, Excel rounds values

XLSX internally stores column widths in a nebulous "Max Digit Width" form. The Max Digit Width is the width of the largest digit when rendered (generally the "0" character is the widest). Chiều rộng bên trong phải là bội số nguyên của chiều rộng chia cho 256. ECMA-376 describes a formula for converting between pixels and the internal width. This represents a hybrid approach

Read functions attempt to populate all three properties. Write functions will try to cycle specified values to the desired type. In order to avoid potential conflicts, manipulation should delete the other properties first. For example, when changing the pixel width, delete the

$ bower install js-xlsx
29 and
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
814 properties

Implementation details (click to show)

Given the constraints, it is possible to determine the MDW without actually inspecting the font. The parsers guess the pixel width by converting from width to pixels and back, repeating for all possible MDW and selecting the MDW that minimizes the error. XLML actually stores the pixel width, so the guess works in the opposite direction

Even though all of the information is made available, writers are expected to follow the priority order

  1. use
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    814 field if available
  2. use
    $ bower install js-xlsx
    28 pixel width if available
  3. use
    $ bower install js-xlsx
    29 character count if available

Thuộc tính hàng

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
818 array in each worksheet, if present, is a collection of
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
819 objects which have the following properties

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
83

Note. Excel UI displays the base outline level as

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
820 and the max level as
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
821. The
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
822 field stores the base outline as
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
823 and the max level as
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
824

Implementation details (click to show)

Excel internally stores row heights in points. The default resolution is 72 DPI or 96 PPI, so the pixel and point size should agree. For different resolutions they may not agree, so the library separates the concepts

Even though all of the information is made available, writers are expected to follow the priority order

  1. use
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    825 pixel height if available
  2. use
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    826 point height if available

định dạng số

The

$ npm install xlsx
39 formatted text for each cell is produced from
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
828 and
$ npm install xlsx
42 format. If the format is not specified, the Excel
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
830 format is used. The format can either be specified as a string or as an index into the format table. Parsers are expected to populate
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
831 with the number format table. Writers are expected to serialize the table

Custom tools should ensure that the local table has each used format string somewhere in the table. Excel convention mandates that the custom formats start at index 164. The following example creates a custom format from scratch

New worksheet with custom format (click to show)

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84

The rules are slightly different from how Excel displays custom number formats. In particular, literal characters must be wrapped in double quotes or preceded by a backslash. For more info, see the Excel documentation article

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
832 or ECMA-376 18. 8. 31 (Number Formats)

Default Number Formats (click to show)

The default formats are listed in ECMA-376 18. 8. 30

IDFormat0
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
8301
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
8232
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
8353
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
8364
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
8379
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
83810
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
83911
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84012
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84113
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84214
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
843 (see below)15
$ npm install xlsx
8716
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84517
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84618
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84719
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84820
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84921
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85022
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85137
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85238
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85339
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85440
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85545
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85646
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85747
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85848
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85949
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
860

Format 14 (

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
843) is localized by Excel. even though the file specifies that number format, it will be drawn differently based on system settings. It makes sense when the producer and consumer of files are in the same locale, but that is not always the case over the Internet. To get around this ambiguity, parse functions accept the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862 option to override the interpretation of that specific format string

siêu liên kết

Hyperlinks are stored in the

$ npm install xlsx
34 key of cell objects. The
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
864 field of the hyperlink object is the target of the link, including the URI fragment. Tooltips are stored in the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
865 field and are displayed when you move your mouse over the text

For example, the following snippet creates a link from cell

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
866 to http. //sheetjs. com with the tip
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
867

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
85

Note that Excel does not automatically style hyperlinks -- they will generally be displayed as normal text

Links where the target is a cell or range or defined name in the same workbook ("Internal Links") are marked with a leading hash character

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
86

Nhận xét di động

Cell comments are objects stored in the

$ npm install xlsx
32 array of cell objects. The actual contents of the comment are split into blocks based on the comment author. The
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
869 field of each comment object is the author of the comment and the
$ npm install xlsx
21 field is the plain text representation

For example, the following snippet appends a cell comment into cell

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
871

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
87

Note. XLSB enforces a 54 character limit on the Author name. Names longer than 54 characters may cause issues with other formats

To mark a comment as normally hidden, set the

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
872 property

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
88

Khả năng hiển thị trang tính

Excel enables hiding sheets in the lower tab bar. The sheet data is stored in the file but the UI does not readily make it available. Standard hidden sheets are revealed in the "Unhide" menu. Excel also has "very hidden" sheets which cannot be revealed in the menu. It is only accessible in the VB Editor

The visibility setting is stored in the

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
873 property of sheet props array

More details (click to show)ValueDefinition0Visible1Hidden2Very Hidden

With https. //rawgit. com/SheetJS/test_files/master/sheet_visibility. xlsx

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
89

Non-Excel formats do not support the Very Hidden state. The best way to test if a sheet is visible is to check if the

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
873 property is logical truth

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
20

VBA và Macro

VBA Macros are stored in a special data blob that is exposed in the

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
875 property of the workbook object when the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
876 option is
$ npm install xlsx
84. They are supported in
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
878,
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
879, and
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
880 formats. The supported format writers automatically insert the data blobs if it is present in the workbook and associate with the worksheet names

Custom Code Names (click to show)

The workbook code name is stored in

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
881. By default, Excel will write
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
882 or a translated phrase like
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
883. Worksheet and Chartsheet code names are in the worksheet properties object at
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
884. Macrosheets and Dialogsheets are ignored

The readers and writers preserve the code names, but they have to be manually set when adding a VBA blob to a different workbook

Macrosheets (bấm để hiển thị)

Older versions of Excel also supported a non-VBA "macrosheet" sheet type that stored automation commands. These are exposed in objects with the

$ bower install js-xlsx
58 property set to
$ bower install js-xlsx
62

Detecting macros in workbooks (click to show)

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
875 field will only be set if macros are present, so testing is simple

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
21

Tùy chọn phân tích cú pháp

The exported

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
888 and
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
21 functions accept an options argument

Option NameDefaultDescription
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
890Input data encoding (see Input Type below)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
891falseIf true, plain text parsing will not parse values **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
892If specified, use code page when appropriate **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
893trueSave formulae to the . f field
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
894trueParse rich text and save HTML to the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
895 field
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
896falseSave number format string to the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
897 field
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
898falseSave style/theme info to the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
899 field
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
200trueGenerated formatted text to the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
201 field
$ npm install xlsx
79falseStore dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862If specified, use the string for date code 14 **
$ npm install xlsx
83falseCreate cell objects of type
$ npm install xlsx
27 for stub cells
$ bower install js-xlsx
000If >0, read the first
$ bower install js-xlsx
00 rows **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
210falseIf true, parse calculation chains
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
211falseIf true, add raw files to book object **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
212falseIf true, only parse enough to get book metadata **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
213falseIf true, only parse enough to get the sheet names
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
876falseIf true, copy VBA blob to
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
875 field **
$ bower install js-xlsx
39""If defined and file is encrypted, use password **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
217falseIf true, throw errors on unexpected file features **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
218If specified, only parse specified sheets **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
219falseIf true, allow parsing of PRN files **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
220falseIf true, preserve
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
221 prefixes in formulae **
  • Even if
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    896 is false, formatted text will be generated and saved to
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    201
  • Trong một số trường hợp, trang tính có thể được phân tích cú pháp ngay cả khi
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    213 là sai
  • Excel aggressively tries to interpret values from CSV and other plain text. This leads to surprising behavior. The
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    891 option suppresses value parsing
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    213 và
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    212 kết hợp để cung cấp cả hai bộ thông tin
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    228 will be an empty object if
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    210 is false
  • Hành vi của
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    211 phụ thuộc vào loại tệp
    • #include "xlsx.extendscript.js"
      /* Read test.xlsx from the Documents folder */
      var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
      /* DO SOMETHING WITH workbook HERE */
      231 array (paths in the ZIP) for ZIP-based formats
    • Hàm băm
      #include "xlsx.extendscript.js"
      /* Read test.xlsx from the Documents folder */
      var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
      /* DO SOMETHING WITH workbook HERE */
      232 (ánh xạ đường dẫn tới các đối tượng đại diện cho tệp) cho ZIP
    • #include "xlsx.extendscript.js"
      /* Read test.xlsx from the Documents folder */
      var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
      /* DO SOMETHING WITH workbook HERE */
      233 object for formats using CFB containers
  • Các hàng
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    234 sẽ được tạo khi nhìn vào đầu ra của đối tượng JSON (vì hàng tiêu đề được tính là một hàng khi phân tích dữ liệu)
  • By default all worksheets are parsed.
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    218 restricts based on input type
    • number. zero-based index of worksheet to parse (
      #include "xlsx.extendscript.js"
      /* Read test.xlsx from the Documents folder */
      var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
      /* DO SOMETHING WITH workbook HERE */
      823 is first worksheet)
    • string. tên của trang tính để phân tích cú pháp (phân biệt chữ hoa chữ thường)
    • array of numbers and strings to select multiple worksheets
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    876 merely exposes the raw VBA CFB object. It does not parse the data. XLSM and XLSB store the VBA CFB object in
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    238. BIFF8 XLS mixes the VBA entries alongside the core Workbook entry, so the library generates a new XLSB-compatible blob from the XLS CFB container
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    892 is applied to BIFF2 - BIFF5 files without
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    240 records and to CSV files without BOM in
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    241. BIFF8 XLS always defaults to 1200
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    219 affects parsing of text files without a common delimiter character
  • Hiện chỉ hỗ trợ mã hóa XOR. Unsupported error will be thrown for files employing other encryption methods
  • Newer Excel functions are serialized with the
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    221 prefix, hidden from the user. SheetJS will strip
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    221 normally. The
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    220 option preserves them
  • WTF is mainly for development. By default, the parser will suppress read errors on single worksheets, allowing you to read from the worksheets that do parse properly. Setting
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    246 forces those errors to be thrown

Kiểu đầu vào

Strings can be interpreted in multiple ways. The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
890 parameter for
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
888 tells the library how to parse the data argument

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
890expected input
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
250string. Base64 encoding of the file
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
251string. binary string (byte
$ npm install xlsx
24 is
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
253)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
254string. JS string (characters interpreted as UTF8)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
255nodejs Buffer
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
256array. array of 8-bit unsigned int (byte
$ npm install xlsx
24 is
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
258)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
259string. path of file that will be read (nodejs only)

đoán loại tập tin

Implementation Details (click to show)

Excel and other spreadsheet tools read the first few bytes and apply other heuristics to determine a file type. This enables file type punning. renaming files with the

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
260 extension will tell your computer to use Excel to open the file but Excel will know how to handle it. This library applies similar logic

Byte 0Raw File TypeSpreadsheet Types
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
261CFB ContainerBIFF 5/8 or password-protected XLSX/XLSB or WQ3/QPW
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
262BIFF StreamBIFF 2/3/4/5
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
263XML/HTMLSpreadsheetML / Flat ODS / UOS1 / HTML / plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
264ZIP ArchiveXLSB or XLSX/M or ODS or UOS2 or plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
265Plain TextSYLK or plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
266Plain TextDIF or plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
267UTF8 EncodedSpreadsheetML / Flat ODS / UOS1 / HTML / plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
268UTF16 EncodedSpreadsheetML / Flat ODS / UOS1 / HTML / plain text
$ npm install xlsx
58Record StreamLotus WK* or Quattro Pro or plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
270Plain textRTF or plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
271Plain textSpreadsheetML / Flat ODS / UOS1 / HTML / plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
272Plain textSpreadsheetML / Flat ODS / UOS1 / HTML / plain text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
273Plain textSpreadsheetML / Flat ODS / UOS1 / HTML / plain text

DBF files are detected based on the first byte as well as the third and fourth bytes (corresponding to month and day of the file date)

Plain text format guessing follows the priority order

FormatTestXML
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
274 xuất hiện trong 1024 ký tự đầu tiênHTMLbắt đầu bằng
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
275 và các thẻ HTML xuất hiện trong 1024 ký tự đầu tiên *XMLbắt đầu bằng
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
275RTFbắt đầu bằng
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
277DSVbắt đầu bằng
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
278, dấu phân cách là ký tự được chỉ địnhDSVnhiều ký tự
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
279 không được trích dẫn hơn so với
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
280 hoặc
  • HTML tags include.
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    286,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    287,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    288,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    289,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    290,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    291,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    292
Why are random text files valid? (click to show)

Excel is extremely aggressive in reading files. Adding an XLS extension to any display text file (where the only characters are ANSI display chars) tricks Excel into thinking that the file is potentially a CSV or TSV file, even if it is only one column. This library attempts to replicate that behavior

The best approach is to validate the desired worksheet and ensure it has the expected number of rows or columns. Extracting the range is extremely simple

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
22

tùy chọn viết

The exported

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
49 and
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
50 functions accept an options argument

Option NameDefaultDescription
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
890Output data encoding (see Output Type below)
$ npm install xlsx
79
$ bower install js-xlsx
35Store dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
500
$ bower install js-xlsx
35Generate Shared String Table **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
502
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
503Type of Workbook (see below for supported formats)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
504
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
505Name of Worksheet for single-sheet formats **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
506
$ bower install js-xlsx
35Use ZIP compression for ZIP-based formats **
$ bower install js-xlsx
70Override workbook properties when writing **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
509Override theme XML when writing XLSX/XLSB/XLSM **
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
510
$ npm install xlsx
84Suppress "number as text" errors **
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    500 is slower and more memory intensive, but has better compatibility with older versions of iOS Numbers
  • The raw data is the only thing guaranteed to be saved. Features not described in this README may not be serialized
  • $ npm install xlsx
    79 only applies to XLSX output and is not guaranteed to work with third-party readers. Excel itself does not usually write cells with type
    $ npm install xlsx
    25 so non-Excel tools may ignore the data or error in the presence of dates
  • $ bower install js-xlsx
    70 is an object mirroring the workbook
    $ bower install js-xlsx
    70 field. See the table from the Workbook File Properties section
  • if specified, the string from
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    509 will be saved as the primary theme for XLSX/XLSB/XLSM files (to
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    518 in the ZIP)
  • Due to a bug in the program, some features like "Text to Columns" will crash Excel on worksheets where error conditions are ignored. The writer will mark files to ignore the error by default. Set
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    510 to
    $ bower install js-xlsx
    35 to suppress

Định dạng đầu ra được hỗ trợ

For broad compatibility with third-party tools, this library supports many output formats. The specific file type is controlled with

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
502 option

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
502file extcontainersheetsDescription
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
41
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
524ZIPmultiExcel 2007+ XML Format
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
525
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
526ZIPmultiExcel 2007+ Macro XML Format
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
527
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
528ZIPmultiExcel 2007+ Binary Format
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
529
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
260CFBmultiExcel 97-2004 Workbook Format
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
531
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
260CFBmultiExcel 5. 0/95 Workbook Format
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
533
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
260nonesingleExcel 2. 0 Worksheet Format
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
535
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
260nonemultiExcel 2003-2004 (SpreadsheetML)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
537
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
538ZIPmultiOpenDocument Spreadsheet
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
539
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
540nonemultiFlat OpenDocument Spreadsheet
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
541
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
542nonesingleComma Separated Values
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
543
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
544nonesingleUTF-16 Unicode Text (TXT)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
545
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
546nonesingleSymbolic Link (SYLK)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
286
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
548nonesingleHTML Document
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
549
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
550nonesingleData Interchange Format (DIF)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
551
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
552nonesingledBASE II + VFP Extensions (DBF)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
553
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
554nonesingleRich Text Format (RTF)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
555
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
556nonesingleLotus Formatted Text
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
557
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
558nonesingleEthercalc Record Format (ETH)
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    506 only applies to formats with ZIP containers
  • Formats that only support a single sheet require a
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    504 option specifying the worksheet. If the string is empty, the first worksheet is used
  • <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
    50 will automatically guess the output file format based on the file extension if
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    502 is not specified. It will choose the first format in the aforementioned table that matches the extension

Loại đầu ra

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
890 argument for
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
49 mirrors the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
890 argument for
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
888

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
890output
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
250string. Base64 encoding of the file
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
251string. binary string (byte
$ npm install xlsx
24 is
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
253)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
254string. JS string (characters interpreted as UTF8)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
255nodejs Buffer
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
256ArrayBuffer, fallback array of 8-bit unsigned int
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
259string. path of file that will be created (nodejs only)

Các chức năng tiện ích

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
576 functions accept a worksheet and an optional options object

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
577 functions accept a data object and an optional options object

The examples are based on the following worksheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
23

Mảng đầu vào mảng

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
36 takes an array of arrays of JS values and returns a worksheet resembling the input data. Numbers, Booleans and Strings are stored as the corresponding styles. Dates are stored as date or numbers. Array holes and explicit
$ npm install xlsx
40 values are skipped.
$ bower install js-xlsx
86 values may be stubbed. All other values are stored as strings. The function takes an options argument

Option NameDefaultDescription
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
$ npm install xlsx
79falseStore dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
$ npm install xlsx
83falseCreate cell objects of type
$ npm install xlsx
27 for
$ bower install js-xlsx
86 valuesExamples (click to show)

To generate the example sheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
24

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
588 takes an array of arrays of JS values and updates an existing worksheet object. It follows the same process as
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
94 and accepts an options argument

Option NameDefaultDescription
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
$ npm install xlsx
79falseStore dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
$ npm install xlsx
83falseCreate cell objects of type
$ npm install xlsx
27 for
$ bower install js-xlsx
86 values
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597Use specified cell as starting point (see below)

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597 is expected to be one of

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597Description(cell object)Use specified cell (cell object)(string)Use specified cell (A1-style cell)(number >= 0)Start from the first column at specified row (0-indexed)-1Append to bottom of worksheet starting on first column(default)Start from cell A1Examples (click to show)

Consider the worksheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
25

This worksheet can be built up in the order

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
00

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
26

Mảng đối tượng đầu vào

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
01 takes an array of objects and returns a worksheet with automatically-generated "headers" based on the keys of the objects. The default column order is determined by the first appearance of the field using
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
02, but can be overridden using the options argument

Option NameDefaultDescription
$ bower install js-xlsx
19Use specified column order (default
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
02)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
$ npm install xlsx
79falseStore dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
09falseIf true, do not include header row in outputExamples (click to show)

The original sheet cannot be reproduced using plain objects since JS object keys must be unique. After replacing the second

$ npm install xlsx
23 and
$ npm install xlsx
15 with
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
12 and
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
13

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
27

Alternatively, the header row can be skipped

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
28

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
14 takes an array of objects and updates an existing worksheet object. It follows the same process as
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
95 and accepts an options argument

Option NameDefaultDescription
$ bower install js-xlsx
19Use specified column order (default
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
02)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
$ npm install xlsx
79falseStore dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
09falseIf true, do not include header row in output
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597Use specified cell as starting point (see below)

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597 is expected to be one of

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597Description(cell object)Use specified cell (cell object)(string)Use specified cell (A1-style cell)(number >= 0)Start from the first column at specified row (0-indexed)-1Append to bottom of worksheet starting on first column(default)Start from cell A1Examples (click to show)

Consider the worksheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
25

This worksheet can be built up in the order

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
00

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
50

Đầu vào bảng HTML

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
27 takes a table DOM element and returns a worksheet resembling the input table. Numbers are parsed. All other data will be stored as strings

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
28 produces a minimal workbook based on the worksheet

Cả hai chức năng chấp nhận đối số tùy chọn

Option NameDefaultDescription
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
891If true, every cell will hold raw strings
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
$ npm install xlsx
79falseStore dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
$ bower install js-xlsx
000If >0, read the first
$ bower install js-xlsx
00 rows of the table
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
36falseIf true, hidden rows and cells will not be parsedExamples (click to show)

To generate the example sheet, start with the HTML table

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
51

To process the table

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
52

Note.

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
37 can handle HTML represented as strings

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
38 takes a table DOM element and updates an existing worksheet object. It follows the same process as
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
26 and accepts an options argument

Option NameDefaultDescription
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
891If true, every cell will hold raw strings
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
$ npm install xlsx
79falseStore dates as type
$ npm install xlsx
25 (default is
$ npm install xlsx
24)
$ bower install js-xlsx
000If >0, read the first
$ bower install js-xlsx
00 rows of the table
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
36falseIf true, hidden rows and cells will not be parsed

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597 is expected to be one of

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
597Description(cell object)Use specified cell (cell object)(string)Use specified cell (A1-style cell)(number >= 0)Start from the first column at specified row (0-indexed)-1Append to bottom of worksheet starting on first column(default)Start from cell A1Examples (click to show)

A small helper function can create gap rows between tables

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
53

Đầu ra công thức

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
48 generates an array of commands that represent how a person would enter data into an application. Each entry is of the form
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
51. String literals are prefixed with a
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
810 in accordance with Excel

Examples (click to show)

For the example sheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
54

Đầu ra được phân tách bằng dấu phân cách

As an alternative to the

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
50 CSV type,
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
44 also produces CSV output. The function takes an options argument

Option NameDefaultDescription
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
55
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
281"Field Separator" delimiter between fields
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
57
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
58"Record Separator" delimiter between rows
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
60falseRemove trailing field separators in each record **
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
61trueInclude blank lines in the CSV output
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
62falseSkips hidden rows/columns in the CSV output
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
63falseForce quotes around fields
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    60 will remove trailing commas from each line under default
    if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    65
  • if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    61 must be set to
    $ bower install js-xlsx
    35 to skip blank lines
  • Fields containing the record or field separator will automatically be wrapped in double quotes;
    if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    63 forces all cells to be wrapped in quotes
Examples (click to show)

For the example sheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
55

Văn bản Unicode UTF-16

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
543 output type uses the tab character as the field separator. If the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
892 library is available (included in full distribution but not core), the output will be encoded in
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
71 and the BOM will be prepended

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
45 lấy các đối số giống như
$ npm install xlsx
00

Đầu ra HTML

As an alternative to the

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
50 HTML type,
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
46 also produces HTML output. The function takes an options argument

Option NameDefaultDescription
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
76Specify the
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
76 attribute for the
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
78 element
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
79falseIf true, set
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
80 for every TD
$ bower install js-xlsx
19Override header (default
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
82)
$ bower install js-xlsx
23Override footer (default
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
84)Examples (click to show)

For the example sheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
56

JSON

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
47 generates different types of JS objects. The function takes an options argument

Option NameDefaultDescription
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
891
$ npm install xlsx
84Use raw values (true) or formatted strings (false)
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
88from WSOverride Range (see table below)
$ bower install js-xlsx
19Control output format (see table below)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
862FMT 14Use specified date format in string output
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
91Use specified value in place of null or undefined
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
61**Include blank lines in the output **
  • #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    891 only affects cells which have a format code (
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    897) field or a formatted text (
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    201) field
  • If
    $ bower install js-xlsx
    19 is specified, the first row is considered a data row; if
    $ bower install js-xlsx
    19 is not specified, the first row is the header row and not considered data
  • When
    $ bower install js-xlsx
    19 is not specified, the conversion will automatically disambiguate header entries by affixing
    if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    99 and a count starting at
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    820. For example, if three columns have header
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    01 the output fields are
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    01,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    03,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    04
  • $ bower install js-xlsx
    86 values are returned when
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    891 is true but are skipped when false
  • If
    if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    91 is not specified, null and undefined values are skipped normally. If specified, all null and undefined points will be filled with
    if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    91
  • When
    $ bower install js-xlsx
    19 is
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    820, the default is to generate blank rows.
    if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    61 must be set to
    $ bower install js-xlsx
    35 to skip blank rows
  • When
    $ bower install js-xlsx
    19 is not
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    820, the default is to skip blank rows.
    if(typeof require !== 'undefined') XLSX = require('xlsx');
    var workbook = XLSX.readFile('test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    61 must be true to generate blank rows

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
88 is expected to be one of

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
88Description(number)Use worksheet range but set starting row to the value(string)Use specified range (A1-style bounded range string)(default)Use worksheet range (
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
18)

$ bower install js-xlsx
19 is expected to be one of

$ bower install js-xlsx
19Description
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
820Generate an array of arrays ("2D Array")
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
22Row object keys are literal column labelsarray of stringsUse specified strings as keys in row objects(default)Read and disambiguate first row as keys

If header is not

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
820, the row object will contain the non-enumerable property
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
24 that represents the row of the sheet corresponding to the entry

Examples (click to show)

For the example sheet

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
57

Example showing the effect of

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
891

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
58

Định dạng tệp

Despite the library name

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
41, it supports numerous spreadsheet file formats

FormatReadWriteExcel Worksheet/Workbook Formats. -----. -----. Excel 2007+ XML Formats (XLSX/XLSM)⭕⭕Excel 2007+ Binary Format (XLSB BIFF12)⭕⭕Excel 2003-2004 XML Format (XML "SpreadsheetML")⭕⭕Excel 97-2004 (XLS BIFF8)⭕⭕Excel 5. 0/95 (XLS BIFF5)⭕⭕Excel 4. 0 (XLS/XLW BIFF4)⭕Excel 3. 0 (XLS BIFF3)⭕Excel 2. 0/2. 1 (XLS BIFF2)⭕⭕Excel Supported Text Formats. -----. -----. Giá trị được phân tách bằng dấu phân tách (CSV/TXT)⭕⭕Định dạng trao đổi dữ liệu (DIF)⭕⭕Liên kết tượng trưng (SYLK/SLK)⭕⭕Văn bản định dạng hoa sen (PRN)⭕⭕Văn bản Unicode UTF-16 (TXT)⭕⭕Sổ bài/trang tính khác . -----. -----. OpenDocument Spreadsheet (ODS)⭕⭕Flat XML ODF Spreadsheet (FODS)⭕⭕Uniform Office Format Spreadsheet (标文通 UOS1/UOS2)⭕dBASE II/III/IV / Visual FoxPro (DBF)⭕⭕Lotus 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)⭕Quattro Pro Spreadsheet (WQ1/WQ2/WB1/WB2/WB3/QPW)⭕Other Common Spreadsheet Output Formats. -----. -----. HTML Tables⭕⭕Rich Text Format tables (RTF)⭕Ethercalc Record Format (ETH)⭕⭕

Features not supported by a given file format will not be written. Formats with range limits will be silently truncated

FormatLast CellMax ColsMax RowsExcel 2007+ XML Formats (XLSX/XLSM)XFD1048576163841048576Excel 2007+ Binary Format (XLSB BIFF12)XFD1048576163841048576Excel 97-2004 (XLS BIFF8)IV6553625665536Excel 5. 0/95 (XLS BIFF5)IV1638425616384Excel 2. 0/2. 1 (XLS BIFF2)IV1638425616384

Excel 2003 SpreadsheetML range limits are governed by the version of Excel and are not enforced by the writer

Excel 2007+ XML (XLSX/XLSM)

(click to show)

Các tệp XLSX và XLSM là các vùng chứa ZIP chứa một loạt tệp XML theo Quy ước Đóng gói Mở (OPC). The XLSM format, almost identical to XLSX, is used for files containing macros

The format is standardized in ECMA-376 and later in ISO/IEC 29500. Excel không tuân theo đặc điểm kỹ thuật và có các tài liệu bổ sung thảo luận về cách Excel khác với đặc điểm kỹ thuật

Excel 2. 0-95 (BIFF2/BIFF3/BIFF4/BIFF5)

(click to show)

BIFF 2/3 XLS là các luồng bản ghi nhị phân trên một trang tính. Excel 4 introduced the concept of a workbook (

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
27 files) but also had single-sheet
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
28 format. The structure is largely similar to the Lotus 1-2-3 file formats. BIFF5/8/12 extended the format in various ways but largely stuck to the same record format

There is no official specification for any of these formats. Excel 95 can write files in these formats, so record lengths and fields were determined by writing in all of the supported formats and comparing files. Excel 2016 can generate BIFF5 files, enabling a full suite of file tests starting from XLSX or BIFF2

Excel 97-2004 nhị phân (BIFF8)

(click to show)

BIFF8 exclusively uses the Compound File Binary container format, splitting some content into streams within the file. At its core, it still uses an extended version of the binary record format from older versions of BIFF

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
29 specification covers the basics of the file format, and other specifications expand on serialization of features like properties

Excel 2003-2004 (ML bảng tính)

(click to show)

Predating XLSX, SpreadsheetML files are simple XML files. There is no official and comprehensive specification, although MS has released documentation on the format. Since Excel 2016 can generate SpreadsheetML files, mapping features is pretty straightforward

Excel 2007+ Nhị phân (XLSB, BIFF12)

(click to show)

Introduced in parallel with XLSX, the XLSB format combines the BIFF architecture with the content separation and ZIP container of XLSX. For the most part nodes in an XLSX sub-file can be mapped to XLSB records in a corresponding sub-file

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
30 specification covers the basics of the file format, and other specifications expand on serialization of features like properties

Giá trị được phân tách bằng dấu phân cách (CSV/TXT)

(click to show)

Excel CSV deviates from RFC4180 in a number of important ways. The generated CSV files should generally work in Excel although they may not work in RFC4180 compatible readers. The parser should generally understand Excel CSV. The writer proactively generates cells for formulae if values are unavailable

Excel TXT uses tab as the delimiter and code page 1200

Notes

  • Like in Excel, files starting with
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    31 are treated as Symbolic Link files. Unlike Excel, if the file does not have a valid SYLK header, it will be proactively reinterpreted as CSV. There are some files with semicolon delimiter that align with a valid SYLK file. For the broadest compatibility, all cells with the value of
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    32 are automatically wrapped in double-quotes

Các định dạng sổ làm việc khác

(click to show)

Support for other formats is generally far XLS/XLSB/XLSX support, due in large part to a lack of publicly available documentation. Test files were produced in the respective apps and compared to their XLS exports to determine structure. The main focus is data extraction

Hoa sen 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)

(click to show)

The Lotus formats consist of binary records similar to the BIFF structure. Lotus did release a specification decades ago covering the original WK1 format. Other features were deduced by producing files and comparing to Excel support

Quattro Pro (WQ1/WQ2/WB1/WB2/WB3/QPW)

(click to show)

The Quattro Pro formats use binary records in the same way as BIFF and Lotus. Some of the newer formats (namely WB3 and QPW) use a CFB enclosure just like BIFF8 XLS

Bảng tính OpenDocument (ODS/FODS)

(click to show)

ODS is an XML-in-ZIP format akin to XLSX while FODS is an XML format akin to SpreadsheetML. Both are detailed in the OASIS standard, but tools like LO/OO add undocumented extensions. The parsers and writers do not implement the full standard, instead focusing on parts necessary to extract and store raw data

Bảng tính văn phòng thống nhất (UOS1/2)

(click to show)

UOS is a very similar format, and it comes in 2 varieties corresponding to ODS and FODS respectively. For the most part, the difference between the formats is in the names of tags and attributes

Các định dạng trang tính đơn khác

Many older formats supported only one worksheet

dBASE và Visual FoxPro (DBF)

(click to show)

DBF is really a typed table format. each column can only hold one data type and each record omits type information. The parser generates a header row and inserts records starting at the second row of the worksheet. The writer makes files compatible with Visual FoxPro extensions

Multi-file extensions like external memos and tables are currently unsupported, limited by the general ability to read arbitrary files in the web browser. The reader understands DBF Level 7 extensions like DATETIME

Liên kết tượng trưng (SYLK)

(click to show)

There is no real documentation. All knowledge was gathered by saving files in various versions of Excel to deduce the meaning of fields. Notes

  • Plain formulae are stored in the RC form
  • Column widths are rounded to integral characters

Văn bản định dạng hoa sen (PRN)

(click to show)

There is no real documentation, and in fact Excel treats PRN as an output-only file format. Tuy nhiên, chúng tôi có thể đoán độ rộng cột và thiết kế ngược lại bố cục ban đầu. Excel's 240 character width limitation is not enforced

Định dạng trao đổi dữ liệu (DIF)

(click to show)

There is no unified definition. Visicalc DIF differs from Lotus DIF, and both differ from Excel DIF. Where ambiguous, the parser/writer follows the expected behavior from Excel. In particular, Excel extends DIF in incompatible ways

  • Since Excel automatically converts numbers-as-strings to numbers, numeric string constants are converted to formulae.
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    33
  • DIF technically expects numeric cells to hold the raw numeric data, but Excel permits formatted numbers (including dates)
  • DIF technically has no support for formulae, but Excel will automatically convert plain formulae. Array formulae are not preserved

HTML

(click to show)

Excel HTML worksheets include special metadata encoded in styles. For example,

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
34 is a localized string containing the number format. Despite the metadata the output is valid HTML, although it does accept bare
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
35 symbols

The writer adds type metadata to the TD elements via the

$ npm install xlsx
21 tag. The parser looks for those tags and overrides the default interpretation. For example, text like
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
37 will be parsed as numbers but
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
38 will be parsed as text

Định dạng văn bản có định dạng (RTF)

(click to show)

Excel RTF worksheets are stored in clipboard when copying cells or ranges from a worksheet. The supported codes are a subset of the Word RTF support

Định dạng Bản ghi Ethercalc (ETH)

(click to show)

Ethercalc is an open source web spreadsheet powered by a record format reminiscent of SYLK wrapped in a MIME multi-part message

thử nghiệm

Nút

(click to show)

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
39 will run the node-based tests. By default it runs tests on files in every supported format. To test a specific file type, set
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
40 to the format you want to test. Feature-specific tests are available with
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
41

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
59

To enable all errors, set the environment variable

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
42

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
0

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
43 and
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
44 checks are available

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
1

trình duyệt

(click to show)

The core in-browser tests are available at

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
45 within this repo. Start a local server and navigate to that directory to run the tests.
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
46 will start a server on port 8000

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
47 will generate the browser fixtures. To add more files, edit the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
48 file and add the paths

To run the full in-browser tests, clone the repo for

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
49 and replace the
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
17 file (then open a browser window and go to
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
51)

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
2

Môi trường thử nghiệm

(click to show)
  • NodeJS
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    52,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    53,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    54,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    55,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    56,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    57,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    58,
    #include "xlsx.extendscript.js"
    /* Read test.xlsx from the Documents folder */
    var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
    /* DO SOMETHING WITH workbook HERE */
    59
  • IE 6/7/8/9/10/11 (IE 6-9 require shims)
  • Chrome 24+ (bao gồm cả Android 4. 0+)
  • Safari 6+ (iOS và Máy tính để bàn)
  • Edge 13+, FF 18+, and Opera 12+

Các thử nghiệm sử dụng khung thử nghiệm mocha. Travis-CI and Sauce Labs links

  • https. //travis-ci. org/SheetJS/js-xlsx for XLSX module in nodejs
  • https. //semaphoreci. com/sheetjs/js-xlsx cho mô-đun XLSX trong nodejs
  • https. //travis-ci. org/SheetJS/SheetJS. github. io cho các mô-đun XLS*
  • https. // nước sốt. com/u/sheetjs cho các mô-đun XLS* bằng Sauce Labs

Bộ thử nghiệm Travis-CI cũng bao gồm các thử nghiệm cho các múi giờ khác nhau. Để thay đổi múi giờ cục bộ, hãy đặt biến môi trường TZ

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
3

tập tin kiểm tra

Các tệp thử nghiệm được đặt trong một repo khác

Chạy

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
60 sẽ làm mới mô-đun con
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
61 và lấy các tệp. Lưu ý rằng điều này yêu cầu
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
62,
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
63,
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
64 và các lệnh khác có thể không khả dụng. Nếu
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
60 không thành công, vui lòng tải xuống phiên bản mới nhất của ảnh chụp tệp thử nghiệm từ kho lưu trữ

Ảnh chụp mới nhất (bấm để hiển thị)

Ảnh chụp tệp thử nghiệm mới nhất. http. //github. com/SheetJS/test_files/releases/download/20170409/test_files. zip

(download and unzip to the

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
61 subdirectory)

Đóng góp

Due to the precarious nature of the Open Specifications Promise, it is very important to ensure code is cleanroom. Contribution Notes

File organization (click to show)

At a high level, the final script is a concatenation of the individual files in the

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
67 folder. Running
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
68 should reproduce the final output on all platforms. The README is similarly split into bits in the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
69 folder

Folders

foldercontents
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
67raw source files that make up the final script
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
69raw markdown files that make up
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
72
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
73server-side bin scripts (
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
42)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
75dist files for web browsers and nonstandard JS environments
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
4demo projects for platforms like ExtendScript and Webpack
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
77browser tests (run
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
47 to rebuild)
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
79typescript definitions and tests
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
80miscellaneous supporting scripts
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
61test files (pulled from the test files repository)

Sau khi nhân bản repo, chạy

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
82 sẽ hiển thị danh sách các lệnh

Hệ điều hành/Linux

(click to show)

The

<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
17 file is constructed from the files in the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
67 subdirectory. The build script (run
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
68) will concatenate the individual bits to produce the script. Before submitting a contribution, ensure that running make will produce the
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
17 file exactly. The simplest way to test is to add the script

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
4

To produce the dist files, run

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
87. The dist files are updated in each version release and should not be committed between versions

các cửa sổ

(click to show)

The included

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
88 script will build
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js">script>
17 from the
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
67 directory. Building is as simple as

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
5

To prepare development environment

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
6

The full list of commands available in Windows are displayed in

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
82

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
7

As explained in Test Files, on Windows the release ZIP file must be downloaded and extracted. Nếu Bash trên Windows khả dụng, có thể chạy quy trình làm việc OSX/Linux. Các bước sau chuẩn bị môi trường

if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* DO SOMETHING WITH workbook HERE */
8

bài kiểm tra

(click to show)

The

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
92 target (
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
41 on Linux/OSX /
#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
94 on Windows) runs the targeted feature tests. It should take 5-10 seconds to perform feature tests without testing against the entire test battery. New features should be accompanied with tests for the relevant file formats and features

Đối với các thử nghiệm liên quan đến mặt đọc, một thử nghiệm tính năng thích hợp sẽ liên quan đến việc đọc một tệp hiện có và kiểm tra đối tượng sổ làm việc kết quả. If a parameter is involved, files should be read with different values to verify that the feature is working as expected

For tests involving a new write feature which can already be parsed, appropriate feature tests would involve writing a workbook with the feature and then opening and verifying that the feature is preserved

For tests involving a new write feature without an existing read ability, please add a feature test to the kitchen sink

#include "xlsx.extendscript.js"
/* Read test.xlsx from the Documents folder */
var workbook = XLSX.readFile(Folder.myDocuments + '/' + 'test.xlsx');
/* DO SOMETHING WITH workbook HERE */
95

Giấy phép

Vui lòng tham khảo tệp GIẤY PHÉP đính kèm để biết chi tiết. All rights not explicitly granted by the Apache 2. 0 Giấy phép được bảo lưu bởi Tác giả gốc