Đóng góp rất được hoan nghênh. Nó giúp tôi biết những tính năng nào được mong muốn hoặc lỗi nào đang gây khó chịu nhất
Tôi chỉ có một yêu cầu; . Ngay cả một PR chỉ có một bài kiểm tra thất bại cũng không sao - tôi có thể phân tích những gì bài kiểm tra đang làm và sửa mã từ đó
Ghi chú. Vui lòng cố gắng tránh sửa đổi phiên bản gói trong PR. Các phiên bản được cập nhật khi phát hành và mọi thay đổi rất có thể sẽ dẫn đến xung đột hợp nhất
Để rõ ràng, tất cả các đóng góp được thêm vào thư viện này sẽ được bao gồm trong giấy phép MIT của thư viện
nội dungconst ExcelJS = require['exceljs'];
Nhập khẩu ES5
Để sử dụng mã được dịch mã ES5, chẳng hạn cho nút. js cũ hơn 10, hãy sử dụng đường dẫn dist/es5
const ExcelJS = require['exceljs/dist/es5'];
Ghi chú. Bản dựng ES5 có sự phụ thuộc ngầm định vào một số polyfill không còn được thêm vào một cách rõ ràng bởi exceljs. Bạn sẽ cần thêm "core-js" và "regenerator-runtime" vào phần phụ thuộc của mình và bao gồm các yêu cầu sau trong mã của bạn trước khi nhập exceljs
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];
Đối với IE 11, bạn cũng sẽ cần một polyfill để hỗ trợ các mẫu biểu thức chính quy unicode. Ví dụ,
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }
trình duyệt
ExcelJS xuất bản hai gói trình duyệt bên trong thư mục dist/
Một với sự phụ thuộc ngầm vào polyfills core-js
Và một cái không có
giao diện
Tạo sổ làm việc
const workbook = new ExcelJS.Workbook[];
Đặt thuộc tính sổ làm việc
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];
________số 8_______
Đặt thuộc tính tính toán
const ExcelJS = require['exceljs'];0
Chế độ xem sổ làm việc
Chế độ xem sổ làm việc kiểm soát số lượng cửa sổ riêng biệt mà Excel sẽ mở khi xem sổ làm việc
const ExcelJS = require['exceljs'];1
Thêm một bảng tính
const ExcelJS = require['exceljs'];2
Sử dụng tham số thứ hai của hàm addWorksheet để chỉ định các tùy chọn cho trang tính
Ví dụ
const ExcelJS = require['exceljs'];3
Xóa một trang tính
Sử dụng trang tính
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;9 để xóa trang tính khỏi sổ làm việc
Ví dụ
const ExcelJS = require['exceljs'];4
Truy cập trang tính
const ExcelJS = require['exceljs'];5
Điều quan trọng cần biết là
const ExcelJS = require['exceljs'];00 và
const ExcelJS = require['exceljs'];01, vì
const ExcelJS = require['exceljs'];02 có thể có bất kỳ giá trị nào
Trạng thái bảng tính
const ExcelJS = require['exceljs'];6
Thuộc tính trang tính
Trang tính hỗ trợ nhóm thuộc tính để cho phép kiểm soát một số tính năng của trang tính
const ExcelJS = require['exceljs'];7
Thuộc tính được hỗ trợ
NameDefaultDescriptiontabColorundefinedMàu của các taboutlineLevelCol0Cột trang tính mức phác thảooutlineLevelRow0Mức phác thảo hàng của trang tínhmặc địnhRowHeight15Chiều cao hàng mặc địnhmặc địnhColWidth[tùy chọn]Chiều rộng cột mặc địnhdyDescent55TBDSố liệu trang tính
Một số chỉ số mới đã được thêm vào Worksheet
NameDescriptionrowCountTổng kích thước hàng của tài liệu. Bằng số hàng của hàng cuối cùng có giá trị. factRowCountMột số lượng hàng có giá trị. Nếu một hàng giữa tài liệu trống, nó sẽ không được tính vào số lượng. columnCountTổng kích thước cột của tài liệu. Bằng với số lượng ô tối đa từ tất cả các hàngactualColumnCountMột số lượng cột có giá trịThiết lập trang
Tất cả các thuộc tính có thể ảnh hưởng đến việc in trang tính được giữ trong đối tượng pageSetup trên trang tính
const ExcelJS = require['exceljs'];8
Trang được hỗ trợThiết lập cài đặt
TênMặc địnhMô tảlềKhoảng trắng trên đường viền của trang. Đơn vị là inch. direction'portrait'Orientation của trang - i. e. cao hơn [dọc] hoặc rộng hơn [ngang]ngangDpi4294967295Số chấm ngang trên mỗi inch. Giá trị mặc định là -1verticalDpi4294967295Vertical Dots per Inch. Giá trị mặc định là -1fitToPageCho dù sử dụng cài đặt fitToWidth và fitToHeight hay tỷ lệ. Mặc định dựa trên sự hiện diện của các cài đặt này trong đối tượng pageSetup - nếu có cả hai, tỷ lệ sẽ thắng [i. e. mặc định sẽ là false]pageOrder'downThenOver'Thứ tự in các trang - một trong ['downThenOver', 'overThenDown']blackAndWhitefalsePrint không có colordraftfalseIn với chất lượng [và mực]ô kém hơnComments'None'Nơi đặt nhận xét - một trong [' . Hoạt động khi fitToPage là falsefitToWidth1 Trang tính sẽ in trên bề rộng bao nhiêu trang. Hoạt động khi fitToPage là truefitToHeight1 Trang tính sẽ in trên bao nhiêu trang. Hoạt động khi fitToPage là truepaperSizeKích thước giấy nào sẽ sử dụng [xem bên dưới]showRowColHeadersfalseCó hiển thị số hàng và chữ cái cộtshowGridLinesfalseCó hiển thị đường lưới đầu tiênPageNumberSố nào sẽ sử dụng cho trang đầu tiêntheo chiều ngangCenteredfalseCó căn giữa dữ liệu trang tính theo chiều ngangCenteredfalseCho dù căn giữa dữ liệu trang tính theo chiều dọcKhổ giấy mẫu
NameValueLetterundefinedLegal5Executive7A38A49A511B5 [JIS]13Phong bì #1020Phong bì DL27Phong bì C528Phong bì B534Phong bì Monarch37Bưu thiếp kép Nhật Bản Xoay8216K 197x273 mm119Đầu trang và chân trang
Đây là cách thêm đầu trang và chân trang. Nội dung được thêm vào chủ yếu là văn bản, chẳng hạn như thời gian, giới thiệu, thông tin tệp, v.v. , và bạn có thể thiết lập phong cách của văn bản. Ngoài ra, bạn có thể đặt các văn bản khác nhau cho trang đầu tiên và trang chẵn
Ghi chú. Hình ảnh hiện không được hỗ trợ
const ExcelJS = require['exceljs'];9
Cài đặt headerFooter được hỗ trợ
NameDefaultDescriptiondifferentFirstfalseĐặt giá trị của differentFirst là true, điều này cho biết rằng đầu trang/chân trang của trang đầu tiên khác với các trang khácdifferentOddEvenfalseĐặt giá trị của differentOddEven là true, điều này cho biết rằng đầu trang/chân trang cho các trang lẻ và trang chẵn là khácoddHeadernullĐặt chuỗi tiêu đề cho lẻ[mặc định]Lệnh tập lệnh
Các lệnhMô tả&LSĐặt vị trí sang trái&CĐặt vị trí ở giữa&RĐặt vị trí ở bên phải&PSố trang hiện tại&NTổng số trang&DNgày hiện tại&TThời gian hiện tại&hình ảnh GA&ATên trang tính&FTên tệp&BLàm đậm văn bản&IIChữ nghiêng văn bản&UGạch dưới văn bản&tên phông chữ"tên phông chữ, ví dụ &"Aril"&kích thước phông chữcỡ chữ,Chế độ xem trang tính
Trang tính hiện hỗ trợ danh sách dạng xem, kiểm soát cách Excel trình bày trang tính
- cố định - nơi một số hàng và cột ở trên cùng và bên trái được cố định tại chỗ. Chỉ phần dưới cùng bên phải sẽ cuộn
- split - trong đó chế độ xem được chia thành 4 phần, mỗi phần có thể cuộn bán độc lập
Mỗi chế độ xem cũng hỗ trợ các thuộc tính khác nhau
NameDefaultDescriptionstate'normal'Kiểm soát trạng thái dạng xem - một trong các trạng thái bình thường, cố định hoặc tách phảiToLeftfalseĐặt hướng của dạng xem trang tính thành từ phải sang tráihoạt độngCellundefinedÔ hiện được chọnshowRulertrueHiển thị hoặc ẩn thước trong Bố cục trangshowRowColHeaderstrueHiển thị hoặc ẩn tiêu đề hàng và cột [e. g. A1, B1 ở trên cùng và 1,2,3 ở bên tráishowGridLinestrueHiển thị hoặc ẩn các đường lưới [được hiển thị cho các ô không có đường viền được xác định]zoomScale100Tỷ lệ phần trăm thu phóng để sử dụng cho chế độ xemthu phóngScaleNormal100Thu phóng bình thường cho kiểu xemkhông xác địnhKiểu trình bày - một trong số pageBreakPreview hoặc pageLayout. Lưu ý pageLayout không tương thích với chế độ xem cố địnhLượt xem bị đóng băng
Chế độ xem cố định hỗ trợ các thuộc tính bổ sung sau
NameDefaultDescriptionxSplit0Có bao nhiêu cột để đóng băng. Để chỉ cố định các hàng, hãy đặt giá trị này thành 0 hoặc undefinedySplit0Có bao nhiêu hàng sẽ cố định. Để chỉ cố định cột, hãy đặt giá trị này thành 0 hoặc undefinedtopLeftCellspecial Ô nào sẽ ở trên cùng bên trái trong ngăn dưới cùng bên phải. Ghi chú. không thể là một tế bào đông lạnh. Mặc định cho ô chưa được đóng băng đầu tiênconst ExcelJS = require['exceljs/dist/es5'];0
Chia nhỏ lượt xem
Chế độ xem chia nhỏ hỗ trợ các thuộc tính bổ sung sau
TênMặc địnhMô tảxSplit0Cách đặt bộ chia từ bên trái qua bao nhiêu điểm. Để chia theo chiều dọc, hãy đặt giá trị này bằng 0 hoặc không xác địnhSplit0Có bao nhiêu điểm từ trên xuống để đặt bộ chia. Để chia theo chiều ngang, hãy đặt giá trị này thành 0 hoặc undefinedtopLeftCellundefined Ô nào sẽ ở trên cùng bên trái trong ngăn dưới cùng bên phải. activePaneundefinedNgăn nào sẽ hoạt động - một trong topLeft, topRight, bottomLeft và bottomRightconst ExcelJS = require['exceljs/dist/es5'];1
bộ lọc tự động
Có thể áp dụng bộ lọc tự động cho trang tính của bạn
const ExcelJS = require['exceljs/dist/es5'];2
Mặc dù chuỗi phạm vi là dạng tiêu chuẩn của Bộ lọc tự động, trang tính cũng sẽ hỗ trợ các giá trị sau
const ExcelJS = require['exceljs/dist/es5'];3
Cột
const ExcelJS = require['exceljs/dist/es5'];4
hàng
const ExcelJS = require['exceljs/dist/es5'];5
Thêm hàng
const ExcelJS = require['exceljs/dist/es5'];6Tham số Mô tả Giá trị mặc định Giá trị/sCác giá trị hàng/s mới kiểu'i' cho kế thừa từ hàng trên, 'i+' để bao gồm các ô trống, 'n' cho không'n'
Xử lý các ô riêng lẻ
const ExcelJS = require['exceljs/dist/es5'];7
Các ô đã hợp nhất
const ExcelJS = require['exceljs/dist/es5'];8
Chèn hàng
const ExcelJS = require['exceljs/dist/es5'];9Tham sốDescriptionDefault ValueposRow Số nơi bạn muốn chèn, đẩy xuống tất cả các hàng từ therevalue/sThe new row/s valuesstyle'i' cho kế thừa từ hàng trên, , 'i+' để bao gồm các ô trống, 'o' cho kiểu gốc, 'o+'
mối nối
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];0Tham sốMô tảGiá trị mặc địnhbắt đầuĐiểm bắt đầu để nối từđếmSố hàng/ô cần xóa. insertsCác giá trị hàng/ô mới để chèn
Nhân đôi một hàng
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];1Tham số Mô tả Giá trị mặc định Số dòng bắt đầu bạn muốn sao chép [đầu tiên trong excel là 1]số lượngSố lần bạn muốn sao chép hàng1chèntrue nếu bạn muốn chèn hàng mới cho các hàng trùng lặp hoặc false nếu bạn muốn thay thế chúngtrue
Tên được xác định
Các ô riêng lẻ [hoặc nhiều nhóm ô] có thể được gán tên cho chúng. Tên có thể được sử dụng trong công thức và xác thực dữ liệu [và có thể hơn thế nữa]
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];2
Data Validations
Cells can define what values are valid or not and provide prompting to the user to help guide them
Validation types can be one of the following
TypeDescriptionlistDefine a discrete set of valid values. Excel will offer these in a dropdown for easy entrywholeThe value must be a whole numberdecimalThe value must be a decimal numbertextLengthThe value may be text but the length is controlledcustomA custom formula controls the valid valuesFor types other than list or custom, the following operators affect the validation
OperatorDescriptionbetweenValues must lie between formula resultsnotBetweenValues must not lie between formula resultsequalValue must equal formula resultnotEqualValue must not equal formula resultgreaterThanValue must be greater than formula resultlessThanValue must be less than formula resultgreaterThanOrEqualValue must be greater than or equal to formula resultlessThanOrEqualValue must be less than or equal to formula result// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];3
Cell Comments
Add old style comment to a cell
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];4
Cell Comments Properties
The following table defines the properties supported by cell comments
FieldRequiredDefault ValueDescriptiontextsYThe text of the commentmarginsN{}Determines the value of margins for automatic or custom cell commentsprotectionN{}Specifying the lock status of objects and object text using protection attributeseditAsN'absolute'Use the 'editAs' attribute to specify how the annotation is anchored to the cellCell Comments Margins
Determine the page margin setting mode of the cell annotation, automatic or custom mode
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];5
Supported Margins Properties
PropertyRequiredDefault ValueDescriptioninsetmodeN'auto'Determines whether comment margins are set automatically and the value is 'auto' or 'custom'insetN[0. 13, 0. 13, 0. 25, 0. 25]Whitespace on the borders of the comment. Units are centimeter. Direction is left, top, right, bottomNote. This
const ExcelJS = require['exceljs'];03 setting takes effect only when the value of
const ExcelJS = require['exceljs'];04 is 'custom'
Cell Comments Protection
Specifying the lock status of objects and object text using protection attributes
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];6
Supported Protection Properties
PropertyRequiredDefault ValueDescriptionlockedN'True'This element specifies that the object is locked when the sheet is protectedlockTextN'True'This element specifies that the text of the object is lockedNote. Locked objects are valid only when the worksheet is protected
Nhận xét ô EditAs
The cell comments can also have the property 'editAs' which will control how the comments is anchored to the cell[s]. It can have one of the following values
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];7ValueDescriptiontwoCellsIt specifies that the size and position of the note varies with cellsoneCellsIt specifies that the size of the note is fixed and the position changes with the cellabsoluteThis is the default. Comments will not be moved or sized with cells
Tables
Tables allow for in-sheet manipulation of tabular data
To add a table to a worksheet, define a table model and call addTable
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];8
Note. Adding a table to a worksheet will modify the sheet by placing headers and row data to the sheet. Any data on the sheet covered by the resulting table [including headers and totals] will be overwritten
Table Properties
The following table defines the properties supported by tables
Table PropertyDescriptionRequiredDefault ValuenameThe name of the tableYdisplayNameThe display name of the tableNnamerefTop left cell of the tableYheaderRowShow headers at top of tableNtruetotalsRowShow totals at bottom of tableNfalsestyleExtra style propertiesN{}columnsColumn definitionsYrowsRows of dataYTable Style Properties
The following table defines the properties supported within the table style property
Style PropertyDescriptionRequiredDefault ValuethemeThe colour theme of the tableN'TableStyleMedium2'showFirstColumnHighlight the first column [bold]NfalseshowLastColumnHighlight the last column [bold]NfalseshowRowStripesAlternate rows shown with background colourNfalseshowColumnStripesAlternate rows shown with background colourNfalseTable Column Properties
The following table defines the properties supported within each table column
Column PropertyDescriptionRequiredDefault ValuenameThe name of the column, also used in the headerYfilterButtonSwitches the filter control in the headerNfalsetotalsRowLabelLabel to describe the totals row [first column]N'Total'totalsRowFunctionName of the totals functionN'none'totalsRowFormulaOptional formula for custom functionsNHàm tổng
Bảng sau đây liệt kê các giá trị hợp lệ cho thuộc tính totalsRowFunction được xác định bởi các cột. Nếu bất kỳ giá trị nào không phải là 'tùy chỉnh' được sử dụng, thì không cần thiết phải bao gồm công thức được liên kết vì giá trị này sẽ được chèn vào bảng
Tổng số HàmMô tảkhông cóKhông có chức năng tính tổng nào cho cột nàytrung bìnhTính trung bình cho cộtđếmNumsĐếm mục nhập là sốđếmĐếm mục nhậpmaxGiá trị lớn nhất trong cột nàyminGiá trị nhỏ nhất trong cột nàystdDevĐộ lệch chuẩn cho cột nàyvarPhương sai cho cột nàysumTổng các mục nhập cho cột nàytùy chỉnhMột công thức tùy chỉnh. Yêu cầu một giá trị totalsRowFormula được liên kếtChủ đề kiểu bảng
Tên chủ đề hợp lệ tuân theo mẫu sau
- "Kiểu bảng [Bóng tối] [Số]"
Shades, Numbers có thể là một trong
- Ánh sáng, 1-21
- Trung bình, 1-28
- Tối, 1-11
Đối với không có chủ đề, hãy sử dụng giá trị null
Ghi chú. chủ đề bảng tùy chỉnh chưa được exceljs hỗ trợ
Sửa đổi bảng
Các bảng hỗ trợ một tập hợp các chức năng thao tác cho phép thêm hoặc xóa dữ liệu và thay đổi một số thuộc tính. Vì nhiều thao tác trong số này có thể có hiệu ứng trên trang tính nên các thay đổi phải được thực hiện sau khi hoàn tất
Tất cả các giá trị chỉ mục trong bảng đều dựa trên số 0, vì vậy số hàng đầu tiên và số cột đầu tiên là 0
Thêm hoặc xóa Tiêu đề và Tổng số
// polyfills required by exceljs require['core-js/modules/es.promise']; require['core-js/modules/es.string.includes']; require['core-js/modules/es.object.assign']; require['core-js/modules/es.object.keys']; require['core-js/modules/es.symbol']; require['core-js/modules/es.symbol.async-iterator']; require['regenerator-runtime/runtime']; const ExcelJS = require['exceljs/dist/es5'];9
Di dời một bảng
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }0
Thêm và xóa hàng
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }1
Thêm và xóa cột
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }2
Thay đổi thuộc tính cột
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }3
phong cách
Mỗi ô, hàng và cột hỗ trợ một tập hợp phong phú các kiểu và định dạng ảnh hưởng đến cách các ô được hiển thị
Các kiểu được đặt bằng cách gán các thuộc tính sau
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }4
When a style is applied to a row or column, it will be applied to all currently existing cells in that row or column. Also, any new cell that is created will inherit its initial styles from the row and column it belongs to
If a cell's row and column both define a specific style [e. g. font], the cell will use the row style over the column style. However if the row and column define different styles [e. g. column. numFmt and row. font], the cell will inherit the font from the row and the numFmt from the column
Caveat. All the above properties [with the exception of numFmt, which is a string], are JS object structures. If the same style object is assigned to more than one spreadsheet entity, then each entity will share the same style object. If the style object is later modified before the spreadsheet is serialized, then all entities referencing that style object will be modified too. This behaviour is intended to prioritize performance by reducing the number of JS objects created. If you want the style objects to be independent, you will need to clone them before assigning them. Also, by default, when a document is read from file [or stream] if spreadsheet entities share similar styles, then they will reference the same style object too
Number Formats
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }5
Phông chữ
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }6Font PropertyDescriptionExample Value[s]nameFont name. 'Arial', 'Calibri', etc. familyFont family for fallback. An integer value. 1 - Serif, 2 - Sans Serif, 3 - Mono, Others - unknownschemeFont scheme. 'minor', 'major', 'none'charsetFont charset. An integer value. 1, 2, etc. sizeFont size. An integer value. 9, 10, 12, 16, etc. colorColour description, an object containing an ARGB value. { argb. 'FFFF0000'}boldFont weighttrue, falseitalicFont slopetrue, falseunderlineFont underline styletrue, false, 'none', 'single', 'double', 'singleAccounting', 'doubleAccounting'strikeFont strikethroughtrue, falseoutlineFont outlinetrue, falsevertAlignVertical align'superscript', 'subscript'
Alignment
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }7
Valid Alignment Property Values
horizontalverticalwrapTextshrinkToFitindentreadingOrdertextRotationlefttoptruetrueintegerrtl0 to 90centermiddlefalsefalseltr-1 to -90rightbottomverticalfilldistributedjustifyjustifycenterContinuousdistributedBorders
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }8
Valid Border Styles
- thin
- dotted
- dashDot
- hair
- dashDotDot
- slantDashDot
- mediumDashed
- mediumDashDotDot
- mediumDashDot
- medium
- double
- thick
Fills
const rewritePattern = require['regexpu-core']; const {generateRegexpuOptions} = require['@babel/helper-create-regexp-features-plugin/lib/util']; const {RegExp} = global; try { new RegExp['a', 'u']; } catch [err] { global.RegExp = function[pattern, flags] { if [flags && flags.includes['u']] { return new RegExp[rewritePattern[pattern, flags, generateRegexpuOptions[{flags, pattern}]]]; } return new RegExp[pattern, flags]; }; global.RegExp.prototype = RegExp; }9
Pattern Fills
PropertyRequiredDescriptiontypeYValue. 'pattern'Specifies this fill uses patternspatternYSpecifies type of pattern [see below]fgColorNSpecifies the pattern foreground color. Default is black. bgColorNSpecifies the pattern background color. Default is white
Note. If you want to fill a cell using the
const ExcelJS = require['exceljs'];05 pattern, then you don't need to specify
const ExcelJS = require['exceljs'];06. See example above for cell
const ExcelJS = require['exceljs'];07 with a
const ExcelJS = require['exceljs'];05 pattern and a coral
const ExcelJS = require['exceljs'];09
Valid Pattern Types
- none
- solid
- darkGray
- mediumGray
- lightGray
- gray125
- gray0625
- darkHorizontal
- darkVertical
- darkDown
- darkUp
- darkGrid
- darkTrellis
- lightHorizontal
- lightVertical
- lightDown
- lightUp
- lightGrid
- lightTrellis
Gradient Fills
PropertyRequiredDescriptiontypeYValue. 'gradient'Specifies this fill uses gradientsgradientYSpecifies gradient type. One of ['angle', 'path']degreeangleFor 'angle' gradient, specifies the direction of the gradient. 0 is from the left to the right. Các giá trị từ 1 - 359 xoay hướng theo chiều kim đồng hồđường dẫn trung tâmĐối với độ dốc 'đường dẫn'. Specifies the relative coordinates for the start of the path. 'left' and 'top' values range from 0 to 1stopsYSpecifies the gradient colour sequence. Is an array of objects containing position and color starting with position 0 and ending with position 1. Intermediary positions may be used to specify other colours on the path
Caveats
Using the interface above it may be possible to create gradient fill effects not possible using the XLSX editor program. For example, Excel only supports angle gradients of 0, 45, 90 and 135. Similarly the sequence of stops may also be limited by the UI with positions [0,1] or [0,0. 5,1] as the only options. Take care with this fill to be sure it is supported by the target XLSX viewers
Rich Text
Individual cells now support rich text or in-cell formatting. Rich text values can control the font properties of any number of sub-strings within the text value. See Fonts for a complete list of details on what font properties are supported
0
Cell Protection
Cell level protection can be modified using the protection property
1
Supported Protection Properties
PropertyDefaultDescriptionlockedtrueSpecifies whether a cell will be locked if the sheet is protected. hiddenfalseSpecifies whether a cell's formula will be visible if the sheet is protectedConditional Formatting
Conditional formatting allows a sheet to show specific styles, icons, etc depending on cell values or any arbitrary formula
Conditional formatting rules are added at the sheet level and will typically cover a range of cells
Multiple rules can be applied to a given cell range and each rule will apply its own style
If multiple rules affect a given cell, the rule priority value will determine which rule wins out if competing styles collide. The rule with the lower priority value wins. If priority values are not specified for a given rule, ExcelJS will assign them in ascending order
Note: at present, only a subset of conditional formatting rules are supported. Specifically, only the formatting rules that do not require XML rendering inside an element. This means that datasets and three specific icon sets [3Triangles, 3Stars, 5Boxes] are not supported.
2
Supported Conditional Formatting Rule Types
TypeDescriptionexpressionAny custom function may be used to activate the rule. cellIsCompares cell value with supplied formula using specified operatortop10Applies formatting to cells with values in top [or bottom] rangesaboveAverageApplies formatting to cells with values above [or below] averagecolorScaleApplies a coloured background to cells based on where their values lie in the rangeiconSetAdds one of a range of icons to cells based on valuecontainsTextApplies formatting based on whether cell a specific texttimePeriodApplies formatting based on whether cell datetime value lies within a specified rangeExpression
FieldOptionalDefaultDescriptiontype'expression'priorityYdetermines priority ordering of stylesformulaearray of 1 formula string that returns a true/false value. To reference the cell value, use the top-left cell addressstylestyle structure to apply if the formula returns trueCell Is
FieldOptionalDefaultDescriptiontype'cellIs'priorityYdetermines priority ordering of stylesoperatorhow to compare cell value with formula resultformulaearray of 1 formula string that returns the value to compare against each cellstylestyle structure to apply if the comparison returns trueCell Is Operators
OperatorDescriptionequalApply format if cell value equals formula valuegreaterThanApply format if cell value is greater than formula valuelessThanApply format if cell value is less than formula valuebetweenApply format if cell value is between two formula values [inclusive]Tôp 10
FieldOptionalDefaultDescriptiontype'top10'priorityYdetermines priority ordering of stylesrankY10specifies how many top [or bottom] values are included in the formattingpercentYfalseif true, the rank field is a percentage, not an absolutebottomYfalseif true, the bottom values are included instead of the topstylestyle structure to apply if the comparison returns trueAbove Average
FieldOptionalDefaultDescriptiontype'aboveAverage'priorityYdetermines priority ordering of stylesaboveAverageYfalseif true, the rank field is a percentage, not an absolutestylestyle structure to apply if the comparison returns trueColor Scale
FieldOptionalDefaultDescriptiontype'colorScale'priorityYdetermines priority ordering of stylescfvoarray of 2 to 5 Conditional Formatting Value Objects specifying way-points in the value rangecolorcorresponding array of colours to use at given way pointsstylestyle structure to apply if the comparison returns trueIcon Set
FieldOptionalDefaultDescriptiontype'iconSet'priorityYdetermines priority ordering of stylesiconSetY3TrafficLightsname of icon set to useshowValuetrueSpecifies whether the cells in the applied range display the icon and cell value, or the icon onlyreversefalseSpecifies whether the icons in the icon set specified in iconSet are show in reserve order. If custom equals "true" this value must be ignoredcustomfalseSpecifies whether a custom set of icons is usedcfvoarray of 2 to 5 Conditional Formatting Value Objects specifying way-points in the value rangestylestyle structure to apply if the comparison returns trueData Bar
FieldOptionalDefaultDescriptiontype'dataBar'priorityYdetermines priority ordering of stylesminLength0Specifies the length of the shortest data bar in this conditional formatting rangemaxLength100Specifies the length of the longest data bar in this conditional formatting rangeshowValuetrueSpecifies whether the cells in the conditional formatting range display both the data bar and the numeric value or the data bargradienttrueSpecifies whether the data bar has a gradient fillbordertrueSpecifies whether the data bar has a bordernegativeBarColorSameAsPositivetrueSpecifies whether the data bar has a negative bar color that is different from the positive bar colornegativeBarBorderColorSameAsPositivetrueSpecifies whether the data bar has a negative border color that is different from the positive border coloraxisPosition'auto'Specifies the axis position for the data bardirection'leftToRight'Specifies the direction of the data barcfvoarray of 2 to 5 Conditional Formatting Value Objects specifying way-points in the value rangestylestyle structure to apply if the comparison returns trueContains Text
FieldOptionalDefaultDescriptiontype'containsText'priorityYdetermines priority ordering of stylesoperatortype of text comparisontexttext to search forstylestyle structure to apply if the comparison returns trueContains Text Operators
OperatorDescriptioncontainsTextApply format if cell value contains the value specified in the 'text' fieldcontainsBlanksApply format if cell value contains blanksnotContainsBlanksApply format if cell value does not contain blankscontainsErrorsApply format if cell value contains errorsnotContainsErrorsApply format if cell value does not contain errorsTime Period
FieldOptionalDefaultDescriptiontype'timePeriod'priorityYdetermines priority ordering of stylestimePeriodwhat time period to compare cell value tostylestyle structure to apply if the comparison returns trueTime Periods
Time PeriodDescriptionlastWeekApply format if cell value falls within the last weekthisWeekApply format if cell value falls in this weeknextWeekApply format if cell value falls in the next weekyesterdayApply format if cell value is equal to yesterdaytodayApply format if cell value is equal to todaytomorrowApply format if cell value is equal to tomorrowlast7DaysApply format if cell value falls within the last 7 dayslastMonthApply format if cell value falls in last monththisMonthApply format if cell value falls in this monthnextMonthApply format if cell value falls in next monthOutline Levels
Excel supports outlining; where rows or columns can be expanded or collapsed depending on what level of detail the user wishes to view
Mức độ phác thảo có thể được xác định trong thiết lập cột
3
Or directly on the row or column
4
The sheet outline levels can be set on the worksheet
5
Note. adjusting outline levels on rows or columns or the outline levels on the worksheet will incur a side effect of also modifying the collapsed property of all rows or columns affected by the property change. E. g
6
The outline properties can be set on the worksheet
7
Images
Adding images to a worksheet is a two-step process. First, the image is added to the workbook via the addImage[] function which will also return an imageId value. Then, using the imageId, the image can be added to the worksheet either as a tiled background or covering a cell range
Note. As of this version, adjusting or transforming the image is not supported and images are not supported in streaming mode
Add Image to Workbook
The Workbook. addImage function supports adding images by filename or by Buffer. Note that in both cases, the extension must be specified. Valid extension values include 'jpeg', 'png', 'gif'
8
Add image background to worksheet
Using the image id from Workbook. addImage, the background to a worksheet can be set using the addBackgroundImage function
9
Add image over a range
Using the image id from Workbook. addImage, an image can be embedded within the worksheet to cover a range. The coordinates calculated from the range will cover from the top-left of the first cell to the bottom right of the second
0
Using a structure instead of a range string, it is possible to partially cover cells
Note that the coordinate system used for this is zero based, so the top-left of A1 will be { col. 0, row. 0 }. Fractions of cells can be specified by using floating point numbers, e. g. the midpoint of A1 is { col. 0. 5, row. 0. 5 }
1
The cell range can also have the property 'editAs' which will control how the image is anchored to the cell[s] It can have one of the following values
ValueDescriptionundefinedIt specifies the image will be moved and sized with cellsoneCellThis is the default. Image will be moved with cells but not sizedabsoluteImage will not be moved or sized with cells2
Add image to a cell
You can add an image to a cell and then define its width and height in pixels at 96dpi
3
Add image with hyperlinks
You can add an image with hyperlinks to a cell, and defines the hyperlinks in image range
4
Sheet Protection
Worksheets can be protected from modification by adding a password
5
Worksheet protection can also be removed
6
See for details on how to modify individual cell protection
Note. While the protect[] function returns a Promise indicating that it is async, the current implementation runs on the main thread and will use approx 600ms on an average CPU. This can be adjusted by setting the spinCount, which can be used to make the process either faster or more resilient
Sheet Protection Options
FieldDefaultDescriptionselectLockedCellstrueLets the user select locked cellsselectUnlockedCellstrueLets the user select unlocked cellsformatCellsfalseLets the user format cellsformatColumnsfalseLets the user format columnsformatRowsfalseLets the user format rowsinsertRowsfalseLets the user insert rowsinsertColumnsfalseLets the user insert columnsinsertHyperlinksfalseLets the user insert hyperlinksdeleteRowsfalseLets the user delete rowsdeleteColumnsfalseLets the user delete columnssortfalseLets the user sort dataautoFilterfalseLets the user filter data in tablespivotTablesfalseLets the user use pivot tablesspinCount100000The number of hash iterations performed when protecting or unprotectingFile I/O
XLSX
Reading XLSX
7
Writing XLSX
8
CSV
Reading CSV
Options supported when reading CSV files
FieldRequiredTypeDescriptiondateFormatsNArrayChỉ định định dạng mã hóa ngày của dayjs. mapNFunctionCustom Array. prototype. map[] callback function for processing data. sheetNameNStringSpecify worksheet name. parserOptionsNObjectparseOptions options @fast-csv/format module to write csv data9
The CSV parser uses fast-csv to read the CSV file. The formatterOptions in the options passed to the above write function will be passed to the @fast-csv/format module to write csv data. Please refer to the fast-csv README. md for details
Dates are parsed using the npm module dayjs. If a dateFormats array is not supplied, the following dateFormats are used
- 'YYYY-MM-DD[T]HH. mm. ss'
- 'MM-DD-YYYY'
- 'YYYY-MM-DD'
Please refer to the for details on how to structure a dateFormat
Writing CSV
Options supported when writing to a CSV file
FieldRequiredTypeDescriptiondateFormatNStringSpecify the date encoding format of dayjs. dateUTCNBooleanSpecify whether ExcelJS usesconst ExcelJS = require['exceljs'];10 to convert time zone for parsing dates. encodingNStringSpecify file encoding format. [Only applies to
const ExcelJS = require['exceljs'];11. ]includeEmptyRowsNBooleanSpecifies whether empty rows can be written. mapNFunctionCustom Array. prototype. map[] callback function for processing row values. sheetNameNStringSpecify worksheet name. sheetIdNNumberSpecify worksheet ID. formatterOptionsNObjectformatterOptions options @fast-csv/format module to write csv data
const workbook = new ExcelJS.Workbook[];0
The CSV parser uses fast-csv to write the CSV file. The formatterOptions in the options passed to the above write function will be passed to the @fast-csv/format module to write csv data. Please refer to the fast-csv README. md for details
Dates are formatted using the npm module dayjs. If no dateFormat is supplied, dayjs. ISO_8601 is used. When writing a CSV you can supply the boolean dateUTC as true to have ExcelJS parse the date without automatically converting the timezone using
const ExcelJS = require['exceljs'];12
Streaming I/O
The File I/O documented above requires that an entire workbook is built up in memory before the file can be written. While convenient, it can limit the size of the document due to the amount of memory required
A streaming writer [or reader] processes the workbook or worksheet data as it is generated, converting it into file form as it goes. Typically this is much more efficient on memory as the final memory footprint and even intermediate memory footprints are much more compact than with the document version, especially when you consider that the row and cell objects are disposed once they are committed
The interface to the streaming workbook and worksheet is almost the same as the document versions with a few minor practical differences
- Once a worksheet is added to a workbook, it cannot be removed
- Once a row is committed, it is no longer accessible since it will have been dropped from the worksheet
- unMergeCells[] is not supported
Note that it is possible to build the entire workbook without committing any rows. When the workbook is committed, all added worksheets [including all uncommitted rows] will be automatically committed. However in this case, little will have been gained over the Document version
Streaming XLSX
Streaming XLSX Writer[#contents]The streaming XLSX workbook writer is available in the ExcelJS. stream. xlsx namespace
The constructor takes an optional options object with the following fields
FieldDescriptionstreamSpecifies a writable stream to write the XLSX workbook to. filenameIf stream not specified, this field specifies the path to a file to write the XLSX workbook to. useSharedStringsSpecifies whether to use shared strings in the workbook. Default isconst ExcelJS = require['exceljs'];13. useStylesSpecifies whether to add style information to the workbook. Các kiểu có thể thêm một số chi phí hoạt động. Mặc định là
const ExcelJS = require['exceljs'];13. zip mà ExcelJS chuyển nội bộ tới Archiver. Mặc định là
const ExcelJS = require['exceljs'];15
Nếu cả luồng và tên tệp đều không được chỉ định trong các tùy chọn, trình ghi sổ làm việc sẽ tạo một đối tượng StreamBuf sẽ lưu trữ nội dung của sổ làm việc XLSX trong bộ nhớ. Đối tượng StreamBuf này, có thể được truy cập thông qua sổ làm việc thuộc tính. luồng, có thể được sử dụng để truy cập trực tiếp các byte theo luồng. read[] hoặc chuyển nội dung sang luồng khác
const workbook = new ExcelJS.Workbook[];1
Nói chung, giao diện của trình ghi XLSX phát trực tuyến giống như sổ làm việc Tài liệu [và trang tính] được mô tả ở trên, trên thực tế, các đối tượng hàng, ô và kiểu đều giống nhau
Tuy nhiên có một số khác biệt
Xây dựng
Như đã thấy ở trên, WorkbookWriter thường sẽ yêu cầu luồng đầu ra hoặc tệp được chỉ định trong hàm tạo
Committing Data
When a worksheet row is ready, it should be committed so that the row object and contents can be freed. Typically this would be done as each row is added
const workbook = new ExcelJS.Workbook[];2
The reason the WorksheetWriter does not commit rows as they are added is to allow cells to be merged across rows
const workbook = new ExcelJS.Workbook[];3
As each worksheet is completed, it must also be committed
const workbook = new ExcelJS.Workbook[];4
To complete the XLSX document, the workbook must be committed. If any worksheet in a workbook are uncommitted, they will be committed automatically as part of the workbook commit
const workbook = new ExcelJS.Workbook[];5Streaming XLSX Reader[#contents]
The streaming XLSX workbook reader is available in the ExcelJS. stream. xlsx namespace
The constructor takes a required input argument and an optional options argument
ArgumentDescriptioninput [required]Specifies the name of the file or the readable stream from which to read the XLSX workbook. options [optional]Specifies how to handle the event types occuring during the read parsing. options. entriesSpecifies whether to emit entries [const ExcelJS = require['exceljs'];16] or not [
const ExcelJS = require['exceljs'];17]. Default is
const ExcelJS = require['exceljs'];16. options. sharedStringsSpecifies whether to cache shared strings [
const ExcelJS = require['exceljs'];19], which inserts them into the respective cell values, or whether to emit them [
const ExcelJS = require['exceljs'];16] or ignore them [
const ExcelJS = require['exceljs'];17], in both of which case the cell value will be a reference to the shared string's index. Default is
const ExcelJS = require['exceljs'];19. options. hyperlinksSpecifies whether to cache hyperlinks [
const ExcelJS = require['exceljs'];19], which inserts them into their respective cells, whether to emit them [
const ExcelJS = require['exceljs'];16] or whether to ignore them [
const ExcelJS = require['exceljs'];17]. Default is
const ExcelJS = require['exceljs'];19. options. stylesSpecifies whether to cache styles [
const ExcelJS = require['exceljs'];19], which inserts them into their respective rows and cells, or whether to ignore them [
const ExcelJS = require['exceljs'];17]. Default is
const ExcelJS = require['exceljs'];19. options. worksheetsSpecifies whether to emit worksheets [
const ExcelJS = require['exceljs'];16] or not [
const ExcelJS = require['exceljs'];17]. Default is
const ExcelJS = require['exceljs'];16
const workbook = new ExcelJS.Workbook[];6
Please note that
const ExcelJS = require['exceljs'];33 returns an array of rows rather than each row individually for performance reasons. https. //github. com/nodejs/node/issues/31979Iterating over all events[#contents]
Events on workbook are 'worksheet', 'shared-strings' and 'hyperlinks'. Events on worksheet are 'row' and 'hyperlinks'
const workbook = new ExcelJS.Workbook[];7Readable stream[#contents]
Mặc dù chúng tôi đặc biệt khuyến khích sử dụng phép lặp không đồng bộ, nhưng chúng tôi cũng hiển thị giao diện phát trực tuyến để tương thích ngược
const workbook = new ExcelJS.Workbook[];8Browser
A portion of this library has been isolated and tested for use within a browser environment
Do tính chất phát trực tuyến của trình đọc sổ làm việc và trình ghi sổ làm việc, những thứ này chưa được đưa vào. Only the document based workbook may be used [see for details]
For example code using ExcelJS in the browser take a look at the spec/browser folder in the github repo
Gói sẵn
The following files are pre-bundled and included inside the dist folder
- exceljs. js
- exceljs. min. js
The following value types are supported
Null Value
Enum. Excel. ValueType. Null
A null value indicates an absence of value and will typically not be stored when written to file [except for merged cells]. It can be used to remove the value from a cell
E. g
const workbook = new ExcelJS.Workbook[];9
Merge Cell
liệt kê. Excel. ValueType. Merge
A merge cell is one that has its value bound to another 'master' cell. Assigning to a merge cell will cause the master's cell to be modified
Number Value
Enum. Excel. ValueType. Number
A numeric value
E. g
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];0
String Value
Enum. Excel. ValueType. String
A simple text string
E. g
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];1
Date Value
Enum. Excel. ValueType. Date
A date value, represented by the JavaScript Date type
E. g
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];2
Hyperlink Value
Enum. Excel. ValueType. Hyperlink
A URL with both text and link value
E. g
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];3
Formula Value
Enum. Excel. ValueType. Formula
An Excel formula for calculating values on the fly. Note that while the cell type will be Formula, the cell may have an effectiveType value that will be derived from the result value
Note that ExcelJS cannot process the formula to generate a result, it must be supplied
E. g
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];4
Cells also support convenience getters to access the formula and result
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];5
Shared Formula
Shared formulae enhance the compression of the xlsx document by decreasing the repetition of text within the worksheet xml. The top-left cell in a range is the designated master and will hold the formula that all the other cells in the range will derive from. The other 'slave' cells can then refer to this master cell instead of redefining the whole formula again. Note that the master formula will be translated to the slave cells in the usual Excel fashion so that references to other cells will be shifted down and to the right depending on the slave's offset to the master. For example. if the master cell A2 has a formula referencing A1 then if cell B2 shares A2's formula, then it will reference B1
A master formula can be assigned to a cell along with the slave cells in its range
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];6
A shared formula can be assigned to a cell using a new value form
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];7
This specifies that the cell B2 is a formula that will be derived from the formula in A2 and its result is 10
The formula convenience getter will translate the formula in A2 to what it should be in B2
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];8
Shared formulae can be assigned into a sheet using the 'fillFormula' function
workbook.creator = 'Me'; workbook.lastModifiedBy = 'Her'; workbook.created = new Date[1985, 8, 30]; workbook.modified = new Date[]; workbook.lastPrinted = new Date[2016, 9, 27];9
fillFormula can also use a callback function to calculate the value at each cell
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;0
Formula Type
To distinguish between real and translated formula cells, use the formulaType getter
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;1
Formula type has the following values
NameValueEnums. FormulaType. None0Enums. FormulaType. Master1Enums. Loại công thức. Chia sẻ2Công thức mảng
Cách thể hiện công thức dùng chung mới trong Excel là công thức mảng. Trong biểu mẫu này, ô chính là ô duy nhất chứa bất kỳ thông tin nào liên quan đến công thức. Nó chứa 'mảng' shareType cùng với phạm vi ô mà nó áp dụng và công thức sẽ được sao chép. Các ô còn lại là các ô thông thường với các giá trị thông thường
Ghi chú. công thức mảng không được dịch theo cách công thức được chia sẻ. Vì vậy, nếu ô chủ A2 đề cập đến A1, thì ô phụ B2 cũng sẽ đề cập đến A1
E. g
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;2
Hàm fillFormula cũng có thể được sử dụng để điền vào công thức mảng
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;3
Giá trị văn bản đa dạng thức
Enum. Excel. ValueType. RichText
Rich, styled text
E. g
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;4
Boolean Value
Enum. Excel. ValueType. Boolean
E. g
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;5
Error Value
Enum. Excel. ValueType. Error
E. g
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;6
The current valid Error text values are
NameValueExcel. ErrorValue. NotApplicable#N/AExcel. ErrorValue. Tham chiếu #REF. Excel. ErrorValue. Tên#TÊN?Excel. ErrorValue. DivZero#DIV/0. Excel. ErrorValue. Null#NULL. Excel. ErrorValue. Value#VALUE. Excel. ErrorValue. Num#NUM. Interface ChangesEvery effort is made to make a good consistent interface that doesn't break through the versions but regrettably, now and then some things have to change for the greater good
0. 1. 0
Worksheet. eachRow
The arguments in the callback function to Worksheet. eachRow have been swapped and changed; it was function[rowNumber,rowValues], now it is function[row, rowNumber] which gives it a look and feel more like the underscore [_. each] function and priorities the row object over the row number
Worksheet. getRow
This function has changed from returning a sparse array of cell values to returning a Row object. This enables accessing row properties and will facilitate managing row styles and so on
The sparse array of cell values is still available via Worksheet. getRow[rowNumber]. các giá trị;
0. 1. 1
cell. model
cell. styles renamed to cell. style
0. 2. 44
Promises returned from functions switched from Bluebird to native node Promise which can break calling code if they rely on Bluebird's extra features
To mitigate this the following two changes were added to 0. 3. 0
- A more fully featured and still browser compatible promise lib is used by default. This lib supports many of the features of Bluebird but with a much lower footprint
- An option to inject a different Promise implementation. See section for more details
ExcelJS now supports dependency injection for the promise library. You can restore Bluebird promises by including the following code in your module
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;7
Please note. I have tested ExcelJS with bluebird specifically [since up until recently this was the library it used]. From the tests I have done it will not work with Q
CaveatsDist Folder
Before publishing this module, the source code is transpiled and otherwise processed before being placed in a dist/ folder. This README identifies two files - a browserified bundle and minified version. No other contents of the dist/ folder are guaranteed in any way other than the file specified as "main" in the package. json
Known IssuesTesting with Puppeteer
The test suite included in this lib includes a small script executed in a headless browser to validate the bundled packages. At the time of this writing, it appears that this test does not play nicely in the Windows Linux subsystem
For this reason, the browser test can be disabled by the existence of a file named . disable-test-browser
// Set workbook dates to 1904 date system workbook.properties.date1904 = true;8
Splice vs Merge
If any splice operation affects a merged cell, the merge group will not be moved correctly
Lịch sử phát hànhVersionChanges0. 0. 9- Sửa lỗi
- "" text characters properly rendered in xlsx
- Sửa lỗi
- Nhiều dữ liệu văn bản hơn được ghi đúng vào xml [bao gồm văn bản, siêu liên kết, kết quả công thức và mã định dạng]
- Nhận dạng mã định dạng ngày tốt hơn
- Đã sửa lỗi điều kiện cuộc đua tiềm ẩn khi ghi zip
- Một số tái cấu trúc nội bộ
- Sửa lỗi
- Bây giờ xử lý 10 trang tính trở lên trong một sổ làm việc
- theme1. xml file properly added and referenced
- Sửa lỗi
- More compatible theme1. xml included in XLSX file
- Sửa lỗi
- More compatible theme1. xml included in XLSX file
- Fixed filename case issue
- Sửa lỗi
- Added docProps files to satisfy Mac Excel users
- Fixed filename case issue
- Fixed worksheet id issue
- Sửa lỗi
- Handles File Not Found error
- Sửa lỗi
- Fixed Vertical Middle Alignment Issue
- At long last ExcelJS can support writing massive XLSX files in a scalable memory efficient manner. Performance has been optimised and even smaller spreadsheets can be faster to write than the document writer. Options have been added to control the use of shared strings and styles as these can both have a considerable effect on performance
- Access the last editable row in a worksheet
- For streaming writers, this method commits the row [and any previous rows] to the stream. Committed rows will no longer be editable [and are typically deleted from the worksheet object]. For Document type workbooks, this method has no effect
- One Billion Cells
- Achievement Unlocked. A simple test using ExcelJS has created a spreadsheet with 1,000,000,000 cells. Made using random data with 100,000,000 rows of 10 cells per row. Tôi chưa thể xác thực tệp vì Excel sẽ không mở tệp và tôi vẫn chưa triển khai trình đọc phát trực tuyến nhưng tôi hoàn toàn tin tưởng rằng nó tốt vì 1.000.000 hàng đã tải được.
- Sửa lỗi
- Merge Cell Styles
- Merged cells now persist [and parse] their styles
- Merge Cell Styles
- At long last ExcelJS can support writing massive XLSX files in a scalable memory efficient manner. Performance has been optimised and even smaller spreadsheets can be faster to write than the document writer. Options have been added to control the use of shared strings and styles as these can both have a considerable effect on performance
- Access the last editable row in a worksheet
- For streaming writers, this method commits the row [and any previous rows] to the stream. Committed rows will no longer be editable [and are typically deleted from the worksheet object]. For Document type workbooks, this method has no effect
- Sửa lỗi
- Worksheets with Ampersand Names
- Worksheet names are now xml-encoded and should work with all xml compatible characters
- Worksheets with Ampersand Names
- &
- Rows and Columns now support the hidden attribute
- New function to add an array of rows [either array or object form] to the end of a worksheet
- Sửa lỗi
- invalid signature. 0x80014. Thanks to hasanlussa for the PR
- Cells can now have assigned names which may then be used in formulas
- Converted Bluebird. defer[] to new Bluebird[function[resolve, reject]{}]. Thanks to user Nishchit for the Pull Request
- Cells can now define validations that controls the valid values the cell can have
- Giá trị văn bản đa dạng thức
- Cells now support in-cell formatting - Thanks to Peter ADAM
- Fixed typo in README - Thanks to MRdNk
- Fixing emit in worksheet-reader - Thanks to Alan Gunning
- Clearer Docs - Thanks to miensol
- Fixed "read property 'richText' of undefined error. Thanks to james075
- Refactoring Complete. All unit and integration tests pass
- Thanks to cricri for the contribution
- Further refactoring of worksheet writer
- Thanks to cricri again for the contribution
- Fix for exceljs might be vulnerable for regular expression denial of service. Kudos to yonjah and Josh Emerson for the resolution
- Fix for Multiple Sheets opens in 'Group' mode in Excel. My bad - overzealous sheet view code
- Also fix for empty sheet generating invalid xlsx
- Fix for exceljs might be vulnerable for regular expression denial of service. Kudos to yonjah and Josh Emerson for the resolution
- Fixed Multiple Sheets opens in 'Group' mode in Excel again. Added
- Also fix for empty sheet generating invalid xlsx
- Added . Thanks to Jackkum for the PR
- New Property. Print Area
- Merged Fix a bug on phonetic characters. This fixes an issue related to reading workbooks with phonetic text in. Note phonetic text is not properly supported yet - just properly ignored. Thanks to zephyrrider and gen6033 for the contribution
- Merged Fix regression #150. Stream API fails to write XLSX files. Apologies for the regression. Thanks to danieleds for the fix
- Merged Fix a bug on phonetic characters. This fixes an issue related to reading workbooks with phonetic text in. Note phonetic text is not properly supported yet - just properly ignored. Thanks to zephyrrider and gen6033 for the contribution
- Merged Update xlsx. js #119. Điều này sẽ làm cho việc phân tích cú pháp linh hoạt hơn đối với các tài liệu văn phòng mở. Cảm ơn nvitaterna vì sự đóng góp
- Các thay đổi được hợp nhất từ exceljs/exceljs#127 được áp dụng cho phiên bản mới nhất #179. Sửa lỗi phân tích cú pháp các giá trị tên đã xác định. Cảm ơn agdevbridge và priitliivak vì sự đóng góp
- Hợp nhất các tab màu cho worksheet-writer #135. Đã sửa đổi hành vi để in cảnh báo không dùng nữa khi tabColor đã chuyển sang tùy chọn. của cải. Cảm ơn ethanlook vì sự đóng góp
- Merged Throw legible error when failing Value. getType[] #136. Thanks to wulfsolter for the contribution
- Honourable mention to contributors whose PRs were fixed before I saw them
- haoliangyu
- người đánh cá
- Đã hợp nhất Quay trở lại JSON. stringify[] nếu ô không xác định. Nhập #137 với một số sửa đổi. Nếu một giá trị ô được gán cho một đối tượng javascript không thể nhận dạng, thì giá trị được lưu trữ trong các tệp xlsx và csv sẽ được chuỗi hóa JSON. Lưu ý rằng nếu tệp được đọc lại, sẽ không có nỗ lực nào được thực hiện để phân tích cú pháp văn bản JSON được xâu chuỗi hóa. Cảm ơn wulfsolter vì sự đóng góp
- Bản sửa lỗi bảo vệ ô đã hợp nhất #166. Điều này không có nghĩa là hỗ trợ đầy đủ cho các ô được bảo vệ chỉ đơn thuần là trình phân tích cú pháp không bị nhầm lẫn bởi xml bổ sung. Cảm ơn jayflo vì sự đóng góp
- Đã thêm các chức năng để xóa ô, hàng và cột khỏi trang tính. Được mô phỏng theo phương thức ghép mảng, các hàm này cho phép xóa ô, hàng và cột [và chèn tùy chọn]. Xem và để biết chi tiết
Ghi chú.
- Cập nhật hợp nhất border-xform. js #184Các cạnh đường viền không có kiểu sẽ được phân tích cú pháp và hiển thị dưới dạng không có đường viền. Cảm ơn skumarnk2 vì sự đóng góp
- Hợp nhất Chuyển dạng xem tới trình soạn thảo trang tính #187. Bây giờ cũng chuyển lượt xem cho người viết trang tính. Cảm ơn Temetz vì sự đóng góp
- Hợp nhất Không thoát ký tự xml khi sử dụng chuỗi chia sẻ #189. Sửa lỗi trong chuỗi chia sẻ. Cảm ơn tkirda vì sự đóng góp
- Hợp nhất Sửa lỗi nhỏ [Cập nhật bản đồ siêu liên kết. js] #190Cảm ơn lszlkss vì sự đóng góp
- Đã hợp nhất sửa lỗi đánh máy trên chế độ xem trang tính tùy chọn showGridLines #196 "showGridlines" phải là "showGridLines". Cảm ơn gadiaz1 vì sự đóng góp
- Đã hợp nhất sự kiện kết thúc Fire thay vì sự kiện kết thúc trên luồng ghi #199 và Lắng nghe sự kiện kết thúc trên luồng zip thay vì luồng trung gian #200. Khắc phục sự cố với các sự kiện hoàn thành luồng. Cảm ơn junajan vì sự đóng góp
- Hợp nhất Khắc phục sự cố #178 #201. Thêm các thuộc tính sau vào sổ làm việc
- chức vụ
- môn học
- từ khóa
- thể loại
- sự miêu tả
- Công ty
- giám đốc
- Hợp nhất Khắc phục sự cố #163. thuộc tính "spans" của thành phần hàng là tùy chọn #203. Bây giờ phân tích cú pháp xlsx sẽ xử lý các tài liệu không có hàng kéo dài. Cảm ơn arturas-vitkauskas vì sự đóng góp
- Hợp nhất Khắc phục sự cố 206 #208. Khắc phục sự cố đọc tệp xlsx đã được in. Đồng thời thêm thuộc tính "lastPrinted" vào Sổ làm việc. Cảm ơn arturas-vitkauskas vì sự đóng góp
- Đã hợp nhất Cho phép tạo kiểu ô không có giá trị. #210. Bao gồm các ô loại Null có kiểu trong phân tích kết xuất. Cảm ơn oferns vì sự đóng góp
- Đã hợp nhất Sửa lỗi "Nút xml không mong muốn trong parseOpen" trong tài liệu LibreOffice cho các thuộc tính dc. ngôn ngữ và cp. sửa đổi #212. Cảm ơn jessica-jordan vì sự đóng góp
- Đã sửa lỗi Lấy số cột/hàng #74. hiện có các thuộc tính rowCount và columnCount [và các biến thể thực tế], Row có cellCount
- Bản sửa lỗi trình đọc Luồng đã hợp nhất #217. Cảm ơn kturney vì sự đóng góp
- Đã hợp nhất Sửa thứ tự đầu ra của Thuộc tính Trang tính #225. Cảm ơn kekeym vì sự đóng góp
- Đã hợp nhất xóa trang tính trống[0] khỏi _worksheets #231. Cám ơn pookong đã đóng góp
- Đã hợp nhất không bỏ qua chuỗi trống trong chuỗi được chia sẻ để các chỉ mục khớp với nhau #232. Một lần nữa cảm ơn pookong vì sự đóng góp
- Đã hợp nhất sử dụng các chuỗi được chia sẻ để ghi trực tuyến #233. Một lần nữa cảm ơn pookong vì sự đóng góp
- Hợp nhất Thêm nhận xét cho vấn đề #216 #236. Cảm ơn jsalwen vì sự đóng góp
- Hợp nhất Bắt đầu dựa trên hỗ trợ cho các ngày dựa trên năm 1904 #237. Đã sửa lỗi xử lý ngày trong tài liệu với cờ 1904 được đặt. Cảm ơn holm vì sự đóng góp
- Merged Stops Cảnh báo Bluebird về lời hứa không được đáp lại #245. Cảm ơn robinbullocks4rb vì sự đóng góp
- Merged Added missing dependency. col-cache. #247. Cảm ơn Manish2005 vì sự đóng góp
- Trình duyệt tương thích
- Vâng chủ yếu. Tôi đã thêm một thư mục con của trình duyệt có chứa gói được trình duyệt hóa và một chỉ mục. js có thể được sử dụng để tạo một cái khác. Xem phần để biết chi tiết
- Đã sửa lỗi chủ đề bị hỏng. xml. Xin lỗi vì đã để điều đó thông qua
- Hợp nhất [SỬA LỖI] công thức xác thực dữ liệu không xác định #253. Cảm ơn jayflo vì sự đóng góp
- Hợp nhất đã thêm một giải pháp [có thể một phần] cho vấn đề 99. tôi không thể tạo bài kiểm tra thích hợp #255. Bản sửa lỗi này Quá ít dữ liệu hoặc trang tính trống tạo tệp excel không đúng định dạng #99. Cảm ơn mminuti vì sự đóng góp
- Giảm phụ thuộc
- Tạm biệt lodash, tạm biệt bluebird. Gói rút gọn hiện chỉ còn hơn một nửa so với phiên bản đầu tiên
- Trang tính đã hợp nhất với siêu liên kết và xác thực dữ liệu bị hỏng #256. Cảm ơn simon-stoic vì sự đóng góp
- Hợp nhất Loại trừ các điều khiển ký tự khỏi đầu ra XML. Bản sửa lỗi #234 #262. Cảm ơn holm vì sự đóng góp
- Đã hợp nhất Thêm hỗ trợ cho số nhận dạng #259. Điều này sửa lỗi XLSX bị hỏng do ký tự ascii "tab dọc" trong ô #234. Cảm ơn NOtherDev vì sự đóng góp
- Đã giải quyết Thay đổi vi phạm khi xóa bluebird #266. Xin lỗi vì bất kỳ sự bất tiện nào
- Đã thêm nội dung phụ thuộc vào thư viện Promise. Xem phần để biết thêm chi tiết
- Hợp nhất Cập nhật phụ thuộc #279. Cảm ơn holm vì sự đóng góp
- Các bản sửa lỗi nhỏ đã hợp nhất để xử lý luồng #267. Cảm ơn holm vì sự đóng góp
- Đã thêm các bài kiểm tra tự động trong phantomjs cho mã được trình duyệt
- Đã sửa lỗi ô Boolean có giá trị = "true" được trả về là 1 #278. Bản sửa lỗi liên quan đến việc thêm hai loại Giá trị cuộc gọi mới
- Các ô Boolean trước đây sẽ trả về 1 hoặc 0 giờ sẽ trả về true hoặc false
- Các ô lỗi trước đây trả về giá trị chuỗi giờ sẽ trả về cấu trúc lỗi
- Đã sửa lỗi Mã chính xác - setters không trả về giá trị #280
- Đã giải quyết vấn đề v0. 3. 1 phá thiên thạch build #288
- Hợp nhất Thêm hỗ trợ cho cp. nội dungStatus #285. Cảm ơn holm vì sự đóng góp
- Đã hợp nhất Sửa các ký tự hợp lệ trong XML [cho phép \n và \r khi lưu] #286. Cảm ơn Rycochet vì sự đóng góp
- Đã sửa lỗi siêu liên kết với các đối số truy vấn làm hỏng sổ làm việc #275. Mục tiêu siêu liên kết không được thoát trước khi sắp xếp theo thứ tự trong xml
Giải quyết các vấn đề sau
- Văn bản và đường viền màu trắng được thay đổi thành màu đen #290
- Mất định dạng/bảng tổng hợp từ tệp đã tải #261
- Màu đặc trở thành màu đen #272
Về chủ đề. các tệp chủ đề được lưu trữ bên trong bộ chứa xlsx chứa thông tin quan trọng về màu sắc, kiểu, v.v. và nếu thông tin chủ đề từ tệp xlsx đã tải bị mất, kết quả có thể không dự đoán được và không mong muốn. Để giải quyết vấn đề này, khi Sổ làm việc ExcelJS phân tích cú pháp tệp XLSX, nó sẽ giữ nguyên mọi tệp chủ đề mà nó tìm thấy và bao gồm chúng khi ghi vào XLSX mới. Nếu hành vi này không được mong muốn, lớp Workbook sẽ hiển thị hàm clearThemes[] sẽ loại bỏ nội dung chủ đề. Lưu ý rằng hành vi này chỉ được triển khai trong lớp Sổ làm việc dựa trên tài liệu, không phải Trình đọc và Trình ghi được phát trực tuyến
- Tham chiếu lỗi hỗ trợ đã hợp nhất trong phạm vi ô #294. Cảm ơn holm vì sự đóng góp
- Sự cố hợp nhất với các ô được sao chép #297. Sự hợp nhất này thêm hỗ trợ cho các công thức được chia sẻ. Cảm ơn muscapades vì sự đóng góp
- Hợp nhất Đúng chính tả #304. Cảm ơn toalien đã đóng góp
- Hợp nhất Đã thêm hỗ trợ cho các bộ lọc tự động #306. Điều này thêm vào Worksheet. Cảm ơn C4rmond4i vì sự đóng góp
- Đã khôi phục NodeJS 4. 0. 0 tương thích bằng cách loại bỏ mã phá hủy. lời xin lỗi của tôi cho bất kỳ sự bất tiện
- Chuyển sang mã được dịch mã để phân phối. Điều này sẽ đảm bảo khả năng tương thích với 4. 0. 0 trở lên từ đây trở đi. Và nó cũng sẽ cho phép sử dụng mã JS biểu cảm hơn nhiều trong thư mục lib
- Giờ đây, hình ảnh có thể được thêm vào trang tính dưới dạng nền lát gạch hoặc trải dài trên một phạm vi. Ghi chú. các tính năng khác như xoay, v.v. chưa được hỗ trợ và sẽ yêu cầu công việc tiếp theo
- Đã hợp nhất Thêm Res Office bị thiếu #319. Cảm ơn mauricio villalobos vì sự đóng góp
- Đã hợp nhất Thêm printTitlesRow Hỗ trợ #320 Xin cảm ơn pseller89 vì sự đóng góp
- Hợp nhất Tránh lỗi trên neo không có phương tiện #327. Cảm ơn đến holm vì sự đóng góp
- Hợp nhất các loại bản sửa lỗi để đọc trực tuyến #332. Cảm ơn đến holm vì sự đóng góp
- Đã hợp nhất Không đặt địa chỉ nếu siêu liên kết r. id không xác định #334. Cảm ơn đến holm vì sự đóng góp
- Vấn đề hợp nhất 296 #343. Điều này khắc phục Sự cố khi viết dòng mới #296. Cảm ơn holly-weisser vì sự đóng góp
- Đã thêm tô sáng cú pháp hợp nhất✨#350. Cảm ơn rmariuzzo vì sự đóng góp
- Đã hợp nhất Khắc phục sự cố từ phải sang trái #356. Sửa lỗi Thêm tùy chọn vào tệp RTL #72 và Thêm tùy chọn để đặt trang tính RTL #126. Xin chân thành cảm ơn alitaheri vì sự đóng góp này
- Bản sửa lỗi hợp nhất #345 TypeError. Không thể đọc thuộc tính 'date1904' của #364 không xác định. Điều này sửa lỗi TypeError. Không thể đọc thuộc tính 'date1904' của #345 không xác định. Cảm ơn Diluka vì sự đóng góp này
- Đã hợp nhất Thêm tính năng RowBreaks. #389. Cảm ơn brucejo75 vì sự đóng góp này
- Các trường mô hình null của Bộ bảo vệ hợp nhất - sửa chữa và kiểm tra #403. Cảm ơn thecjharries vì sự đóng góp này. Cũng xin cảm ơn Ryc O'Chet đã giúp đánh giá
- Đã hợp nhất Thêm một số nhận xét trong readme theo nhập csv #396. Cảm ơn Michael Lelyakin vì sự đóng góp này. Cũng cảm ơn planmar đã giúp xem xét. Điều này cũng đóng csv để truyền phát không hoạt động #395
- Merged Impl #407. Thanks to Ocke Janssen and Kay Ramme for this contribution. This change allows control on how images are anchored to cells.
- Đã hợp nhất Không bị ngắt khi cố gắng nhập tệp zip không phải là tệp Excel [ví dụ:. . số] #423. Cảm ơn Andreas Lind vì sự đóng góp này. Thay đổi này làm cho exceljs linh hoạt hơn khi mở các tệp không phải excel
- Bản sửa lỗi hợp nhất #419. Cập nhật readme. #434. Cảm ơn Vishnu Kyatannawar vì sự đóng góp này
- Merged Don't break when docProps/core.xml contains a tag #436. Thanks to Andreas Lind for this contribution. This change handles core.xml files with empty version tags.
- Đã hợp nhất Thêm Hỗ trợ hình ảnh Base64 cho. phương thức addImage[] #442. Cảm ơn James W Mann vì sự đóng góp này
- Đã hợp nhất thời điểm cập nhật thành 2. 19. 3 #453. Cảm ơn Markan Patel vì sự đóng góp này
- Hợp nhất Thông tin bổ sung về thuộc tính họ phông chữ #457. Cảm ơn kayayakr vì sự đóng góp này
- Bản sửa lỗi hợp nhất #458 #459. Bản sửa lỗi này Thêm kiểu vào cột khiến nó bị ẩn #458. Cảm ơn Alexander James Phillips vì sự đóng góp này
- Đã hợp nhất Không bị ngắt khi tải tệp Excel có chứa biểu đồ #466. Cảm ơn Andreas Lind vì sự đóng góp này
- Hotfix/sheet order#257 #471 đã hợp nhất. Điều này sửa thứ tự trang tính #257. Cảm ơn Robbi vì sự đóng góp này
- Đồng hóa sửa lỗi #79 phụ thuộc lỗi thời trong giải nén2. Cảm ơn Jules Sam. Randolph vì đã bắt đầu sửa lỗi này và xin chân thành cảm ơn Alexander Kachkaev vì đã tìm ra giải pháp cuối cùng
- Đã hợp nhất ngày Round Excel thành mili giây gần nhất khi chuyển đổi sang ngày javascript #479. Cảm ơn Benoit Jean vì sự đóng góp này
- Sửa lỗi hợp nhất. wb. bảng tính/wb. eachSheet khiến getWorksheet[0] trả về sheet #485. Cảm ơn mah110020 vì sự đóng góp này
- Tính năng hợp nhất/vấn đề 424 #489. Bản sửa lỗi này Không có cách nào để kiểm soát tóm tắtDưới đây hoặc tóm tắtNgay #424. Rất cám ơn Sarah vì sự đóng góp này
- Hợp nhất thêm định nghĩa loại #490. Điều này thêm các định nghĩa kiểu vào ExcelJS. Rất cảm ơn taoqf vì sự đóng góp này
- Đã hợp nhất Thêm Nút 8 và Nút 9 vào thử nghiệm tích hợp liên tục #494. Rất cám ơn Markan Patel vì sự đóng góp này
- Đã hợp nhất bản sửa lỗi README nhỏ #508. Many thanks to Guilherme Bernal for this contribution
- Merged Add support for inlineStr, including rich text #501. Many thanks to linguamatics-pdenes and Rob Scott for their efforts towards this contribution. Since this change is technically a breaking change [the rendered XML for inline strings will change] I'm making this a major release
- Fixed spliceColumns problem when the number of columns are important #520
- Merged Loosen exceljs's dependency requirements for moment #524. Many thanks to nicoladefranceschi for this contribution. This change addresses Ability to use external "moment" package #517
- Addressed Is there a way inserting values in columns. #514. Added a new getter/setter property to Column to get and set column values [see for details]
- Merged Include index. d. ts in published packages #532. To fix TypeScript definitions missing from npm package #525. Many thanks to Kagami Sascha Rosylight for this contribution
- Merged Don't break when docProps/core.xml contains #536. Many thanks to Andreas Lind [and reviewers] for this contribution.
- Merged Try to handle the case where a element is missing an r attribute #537. Many thanks to Andreas Lind for this contribution.
- Merged Add dateUTC flag to CSV Writing #544. Many thanks to Zackery Griesinger for this contribution
- Merged worksheet name is writable #547. Many thanks to xzper for this contribution
- Merged Add CSV write buffer support #549. Many thanks to Jarom Loveridge for this contribution
- Merged Discussion. Customizable row/cell limit #541. Many thanks to Andreas Lind for this contribution
- Merged Get the right text out of hyperlinked formula cells #552. Many thanks to Andreas Lind and Christian Holm for this contribution
- Merged Add test case with a huge file #556. Many thanks to Andreas Lind and Christian Holm for this contribution
- Merged Update README. md to reflect correct functionality of row. addPageBreak[] #557. Many thanks to RajDesai for this contribution
- Merged fix index. d. ts #558. Many thanks to Diluka for this contribution
- Merged List /xl/sharedStrings. xml in [Content_Types]. xml only if one of the … #562. Many thanks to Priidik Vaikla for this contribution
- Merged List /xl/sharedStrings. xml in [Content_Types]. xml only if one of the … #562. Many thanks to Priidik Vaikla for this contribution
- Fixed issue with above where shared strings were used but the content type was not added
- Merged List /xl/sharedStrings. xml in [Content_Types]. xml only if one of the … #562. Many thanks to Priidik Vaikla for this contribution
- Fixed issue with above where shared strings were used but the content type was not added
- Fixed issue 1. 4. 8 broke writing Excel files with useSharedStrings. true #581
- Merged core-xform. Tolerate a missing cp. namespace for the coreProperties element #564. Many thanks to Andreas Lind for this contribution
- Merged Avoid error on malformed address #567. Rất cám ơn Andreas Lind vì sự đóng góp này
- Merged Added a missing Promise in index.d.ts #571. Many thanks to Gabriel Fournier for this contribution. This release should fix Is workbook.commit[] still a promise or not #548
- Merged Issue #488 #574. Many thanks to dljenkins for this contribution. This release should fix Invalid time value Exception #488
- Merged Sheet add state for hidden or show #577. Many thanks to Freddie Hsinfu Huang for this contribution. This release should fix hide worksheet and reorder sheets #226
- Merged Update index. d. ts #582. Many thanks to hankolsen for this contribution
- Merged Decode the x escape notation in shared strings #584. Many thanks to Andreas Lind for this contribution.
- Added . html property to Cells to facilitate html-safe rendering. See for details
- Merged Fix Issue #488 where dt is an invalid date format. #587 to fix Invalid time value Exception #488. Many thanks to Iliya Zubakin for this contribution
- Merged Fix Issue #488 where dt is an invalid date format. #587 to fix Invalid time value Exception #488. Many thanks to Iliya Zubakin for this contribution
- Merged drawing element must be below rowBreaks according to spec or corrupt worksheet #590 Many thanks to Liam Neville for this contribution
- Merged set type optional #595 Many thanks to taoqf for this contribution
- Merged Fix some xlsx stream read xlsx not in guaranteed order problem #578 Many thanks to KMethod for this contribution
- Merged Fix formatting issue in README #599 Many thanks to Vishnu Kyatannawar for this contribution
- Merged Ability to set tooltip for hyperlink #602 Many thanks to Kuznetsov Aleksey for this contribution
- Merged Fix misinterpreted ranges from #636 Many thanks to Andreas Lind for this contribution.
- Merged Add LGTM code quality badges #640 Many thanks to Xavier RENE-CORAIL for this contribution
- Merged Add type definition for Column. values #646 Many thanks to Emil Laine for this contribution. This fixes Column. values is missing TypeScript definitions #645
- Merged Update README. md with load[] option #663 Many thanks to Joanna Walker for this contribution
- Merged fixed packages according to npm audit #677 Many thanks to Manuel Minuti for this contribution
- Merged Update index. d. ts #699 Many thanks to Ray Yen for this contribution
- Merged Replaced node-unzip-2 to unzipper package which is more robust #708 Many thanks to johnmalkovich100 for this contribution
- Merged Read worksheet hidden state #728 Many thanks to Dishu[Lester] Lyu for this contribution
- Merged add Worksheet. state typescript definition fix #714 #736 Many thanks to Ilyes Kechidi for this contribution. This fixes Worksheet State does not exist in index. d. ts #714
- Merged Improvements for images [correct reading/writing possitions] #702. This fixes Image location don't respect Column width #650 and Image position - stretching image #467. Many thanks to Siemienik Paweł for this contribution
- Merged Add Typescript support for formulas without results #619. Many thanks to Loursin for this contribution
- Merged Fix existing row styles when using spliceRows #737. Many thanks to cxam for this contribution
- Merged Consistent code quality #774. Many thanks to Andreas Lubbe for this contribution
- Đã sửa lỗi nối các hàng và cột trên các tên đã xác định
- Đã hợp nhất Thêm hỗ trợ để thêm hình ảnh được neo vào một ô #746. Rất cám ơn Karl von Randow vì sự đóng góp này
- Đã hợp nhất Thêm thuộc tính căn chỉnh dọc #758. Rất cám ơn MikeZyatkov vì sự đóng góp này
- Đã hợp nhất Thay thế lib tạm thời thành tmp #775. Xin chân thành cảm ơn Ivan Sotnikov vì sự đóng góp này
- Đã hợp nhất Thay thế lib tạm thời thành tmp #775. Xin chân thành cảm ơn Andreas Lubbe vì sự đóng góp này
- Bảng tính cập nhật được hợp nhất. kiểu trả về kích thước #793. Xin chân thành cảm ơn Siemienik Paweł vì sự đóng góp này
- Đã hợp nhất Thêm một loại sửa lỗi #795. Xin chân thành cảm ơn Siemienik Paweł vì sự đóng góp này
- Hợp nhất Thêm khả năng thoát khỏi phân tích cú pháp nếu số lượng cột vượt quá giới hạn nhất định #776. Many thanks to Andreas Lind for this contribution
- Đã hợp nhất Thêm hỗ trợ cho các cột lặp lại trên mỗi trang khi in. #799. Rất cám ơn Jasmin Auger vì sự đóng góp này
- Đã hợp nhất Không sử dụng một polyfill hứa hẹn trên các thiết lập hiện đại #815. Xin chân thành cảm ơn Andreas Lubbe vì sự đóng góp này
- Đã hợp nhất sao chép LICENSE vào thư mục dist #807. Rất cảm ơn Yuping Zuo vì sự đóng góp này
- Hợp nhất Tránh từ chối chưa được xử lý đối với lỗi phân tích cú pháp XML #813. Rất cám ơn Andreas Lind vì sự đóng góp này
- Đã hợp nhất [việc vặt] tăng giải nén thành 0. 9. 12 để giải quyết tư vấn npm 886 #819. Rất cám ơn Kreig Zimmerman vì sự đóng góp này
- Tài liệu hợp nhất[README]. cải thiện tài liệu #817. Rất cảm ơn Yuping Zuo vì sự đóng góp này
Hợp nhất thêm bình luận hỗ trợ #529 #823. Rất cảm ơn ilemei vì sự đóng góp này
Điều này khắc phục các sự cố sau
- Có thể thêm nhận xét trên một ô không?
- Thêm nhận xét vào ô #451
- Excel thêm nhận xét vào ô #503
- Cách thêm Cell comment #529
- Vui lòng thêm ví dụ về cách tôi có thể chèn nhận xét cho ô #707
- Khắc phục sự cố hợp nhất với tệp làm hỏng tên được xác định vùng in #822. Rất cám ơn Julia Donaldson vì sự đóng góp này. Điều này khắc phục sự cố Tên được xác định Phá vỡ/Tệp Excel bị hỏng vào Chế độ sửa chữa #664
- Đã hợp nhất Chỉ giữ tối đa 31 ký tự cho sheetname #831. Rất cám ơn Xuebin He vì sự đóng góp này. Điều này khắc phục sự cố Giới hạn độ dài tên trang tính thành 31 ký tự #398
- Đã hợp nhất thêm tài liệu cn #834 và cập nhật tài liệu cn #852. Rất cảm ơn flydragon vì sự đóng góp này
- Hợp nhất sửa lỗi chính tả nhỏ trong readme #853. Rất cám ơn John Varga vì sự đóng góp này
- Hợp nhất Sửa defaultRowHeight không hoạt động #855. Rất cám ơn autukill vì sự đóng góp này. Điều này sẽ khắc phục chiều cao hàng không áp dụng cho hàng #422, Trang tính. của cải. defaultRowHeight không thể hoạt động. Làm cách nào để đặt chiều cao hàng, giúp đỡ. #634 và Chiều cao hàng mặc định không hoạt động?
- Đã hợp nhất Luôn giữ phông chữ đầu tiên #854. Rất cám ơn Dmitriy Gusev vì sự đóng góp này. Điều này sẽ khắc phục sự khác biệt về tỷ lệ tài liệu [chỉ chiều rộng] sau khi đọc và ghi #816, Không thể phân tích cú pháp phông chữ mặc định từ tài liệu nguồn. #833 và Phông chữ cơ sở sai. Calibri được mã hóa cứng thay vì phông chữ từ tài liệu #849
- zip hợp nhất. cho phép điều chỉnh nén cho hiệu suất hoặc kích thước #862. Rất cảm ơn myfreeer vì sự đóng góp này
- Hợp nhất Feat định cấu hình đầu trang và chân trang #863. Rất cám ơn autukill vì sự đóng góp này
- Đã khắc phục sự cố với defaultRowHeight trong đó giá trị mặc định dẫn đến thuộc tính 'customHeight' được đặt
- Hợp nhất Sửa lỗi định dạng văn bản đầu trang và chân trang trong README. md #874. Rất cám ơn autukill vì sự đóng góp này
- Bảng đã thêm. Xem để biết chi tiết
- sửa chữa hợp nhất. #877 và #880. Rất cám ơn Alexander Heinrich vì sự đóng góp này. Điều này sửa lỗi. Siêu liên kết không có sự cố văn bản viết #877 và lỗi. nhận xét không đúng định dạng gặp sự cố khi ghi #880
- Đã hợp nhất Thêm tùy chọn mức nén vào WorkbookWriterOptions để phát trực tuyến #889. Rất cám ơn Alfredo Benassi vì sự đóng góp này
- Hợp nhất Tính năng/Bảo vệ Tế bào #903 và Tính năng/Bảo vệ Trang tính #907. Rất cảm ơn karabaesh vì những đóng góp này
Thay đổi phiên bản chính
Giới thiệu async/await cho ExcelJS
Các tính năng không đồng bộ và chờ đợi mới của JavaScript có thể giúp ích rất nhiều để làm cho mã dễ đọc và dễ bảo trì hơn. Để tránh nhầm lẫn, đặc biệt với các lời hứa được trả về từ các hàm không đồng bộ, chúng tôi đã phải xóa tùy chọn cấu hình lớp Promise và từ v2 trở đi, ExcelJS sẽ sử dụng Promise gốc. Vì đây có khả năng là một thay đổi đột phá nên chúng tôi sẽ nâng cấp phiên bản chính cho bản phát hành này
thay đổi
- Hợp nhất Giới thiệu async/await #829. Xin chân thành cảm ơn Andreas Lubbe vì sự đóng góp này
- Hợp nhất Cập nhật chỉ mục. d. #930. Rất cám ơn cosmonovallc vì những đóng góp này
- TS hợp nhất. Thêm các loại cho chức năng addTable #940. Rất cám ơn egmen vì những đóng góp này
- Hợp nhất đã thêm các loại trả về rõ ràng vào định nghĩa loại của Bảng tính. bảo vệ [] và Bảng tính. không bảo vệ[] #926. Rất cảm ơn Tamas Czinege vì những đóng góp này
- Bỏ phụ thuộc vào thư viện Promise
Thay đổi phiên bản chính khác
Javascript đã thay đổi rất nhiều trong những năm qua và các mô-đun và công nghệ xung quanh nó cũng vậy. Cuối cùng, phiên bản chính này của ExcelJS thay đổi cấu trúc của các tạo phẩm xuất bản
Xuất chính hiện là Nguồn Javascript gốc
Trước bản phát hành này, mã ES5 được dịch mã đã được xuất dưới dạng gói chính. Từ bây giờ, gói chính đến trực tiếp từ thư mục lib/. Điều này có nghĩa là một số phụ thuộc đã bị loại bỏ, bao gồm cả các polyfill
ES5 và Browserify vẫn được bao gồm
Để hỗ trợ những người vẫn yêu cầu mã sẵn sàng ES5 [e. g. dưới dạng phần phụ thuộc trong ứng dụng web], mã nguồn sẽ vẫn được dịch mã và có sẵn trong dist/es5