Excel XLSX parser/generator written in JavaScript with Node.js and browser support, jQuery/d3-style method chaining, encryption, and a focus on keeping existing workbook features and styles in tact.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#table-of-contents Table of Contents
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#installation
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#nodejs
npm install xlsx-populate
Note that xlsx-populate uses ES6 features so only Node.js v4+ is supported.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#browser
A functional browser example can be found in
examples/browser/index.html.
xlsx-populate is written first for Node.js. We use
browserifyand
babelifyto transpile and pack up the module for use in the browser.
You have a number of options to include the code in the browser. You can download the combined, minified code from the browser directory in this repository or you can install with bower:
bower install xlsx-populate
After including the module in the browser, it is available globally as
XlsxPopulate
Alternatively, you can require this module using
. Since xlsx-populate uses ES6 features, you will also need to use
with
babel-preset-envhttps://juejin.im/entry/5b34268fe51d4558bc58ebe5#usage
xlsx-populate has an
extensive APIfor working with Excel workbooks. This section reviews the most common functions and use cases. Examples can also be found in the examples directory of the source code.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#populating-data
To populate data in a workbook, you first load one (either blank, from data, or from file). Then you can access sheets and cells within the workbook to manipulate them.
const XlsxPopulate = require('xlsx-populate');
// Load a new blank workbook
XlsxPopulate.fromBlankAsync()
.then(workbook => {
// Modify the workbook.
workbook.sheet("Sheet1").cell("A1").value("This is neat!");
// Write to file.
return workbook.toFileAsync("./out.xlsx");
});
You can pull data out of existing workbooks using
Cell.valueas a getter without any arguments:
const XlsxPopulate = require('xlsx-populate');
// Load an existing workbook
XlsxPopulate.fromFileAsync("./Book1.xlsx")
.then(workbook => {
// Modify the workbook.
const value = workbook.sheet("Sheet1").cell("A1").value();
// Log the value.
console.log(value);
});
Note: in cells that contain values calculated by formulas, Excel will store the calculated value in the workbook. The
valuemethod will return the value of the cells at the time the workbook was saved. xlsx-populate will not recalculate the values as you manipulate the workbook and will not write the values to the output.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#ranges
xlsx-populate also supports ranges of cells to allow parsing/manipulation of multiple cells at once.
const r = workbook.sheet(0).range("A1:C3");
// Set all cell values to the same value:
r.value(5);
// Set the values using a 2D array:
r.value([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]);
// Set the values using a callback function:
r.value((cell, ri, ci, range) => Math.random());
A common use case is to simply pull all of the values out all at once. You can easily do that with the
Sheet.usedRangemethod.
// Get 2D array of all values in the worksheet.
const values = workbook.sheet("Sheet1").usedRange().value();
Alternatively, you can set the values in a range with only the top-left cell in the range:
workbook.sheet(0).cell("A1").value([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]);
The set range is returned.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rows-and-columns
You can access rows and columns in order to change size, hide/show, or access cells within:
// Get the B column, set its width and unhide it (assuming it was hidden).
sheet.column("B").width(25).hidden(false);
const cell = sheet.row(5).cell(3); // Returns the cell at C5.
xlsx-populate supports a number of options for managing sheets.
You can get a sheet by name or index or get all of the sheets as an array:
// Get sheet by index
const sheet1 = workbook.sheet(0);
// Get sheet by name
const sheet2 = workbook.sheet("Sheet2");
// Get all sheets as an array
const sheets = workbook.sheets();
You can add new sheets:
// Add a new sheet named 'New 1' at the end of the workbook
const newSheet1 = workbook.addSheet('New 1');
// Add a new sheet named 'New 2' at index 1 (0-based)
const newSheet2 = workbook.addSheet('New 2', 1);
// Add a new sheet named 'New 3' before the sheet named 'Sheet1'
const newSheet3 = workbook.addSheet('New 3', 'Sheet1');
// Add a new sheet named 'New 4' before the sheet named 'Sheet1' using a Sheet reference.
const sheet = workbook.sheet('Sheet1');
const newSheet4 = workbook.addSheet('New 4', sheet);
Note: the sheet rename method does not rename references to the sheet so formulas, etc. can be broken. Use with caution!
You can rename sheets:
// Rename the first sheet.
const sheet = workbook.sheet(0).name("new sheet name");
You can move sheets:
// Move 'Sheet1' to the end
workbook.moveSheet("Sheet1");
// Move 'Sheet1' to index 2
workbook.moveSheet("Sheet1", 2);
// Move 'Sheet1' before 'Sheet2'
workbook.moveSheet("Sheet1", "Sheet2");
The above methods can all use sheet references instead of names as well. And you can also move a sheet using a method on the sheet:
// Move the sheet before 'Sheet2'
sheet.move("Sheet2");
You can delete sheets:
// Delete 'Sheet1'
workbook.deleteSheet("Sheet1");
// Delete sheet with index 2
workbook.deleteSheet(2);
// Delete from sheet reference
workbook.sheet(0).delete();
You can get/set the active sheet:
// Get the active sheet
const sheet = workbook.activeSheet();
// Check if the current sheet is active
sheet.active() // returns true or false
// Activate the sheet
sheet.active(true);
// Or from the workbook
workbook.activeSheet("Sheet2");
Excel supports creating defined names that refer to addresses, formulas, or constants. These defined names can be scoped to the entire workbook or just individual sheets. xlsx-populate supports looking up defined names that refer to cells or ranges. (Dereferencing other names will result in an error.) Defined names are particularly useful if you are populating data into a known template. Then you do need to know the exact location.
// Look up workbook-scoped name and set the value to 5.
workbook.definedName("some name").value(5);
// Look of a name scoped to the first sheet and set the value to "foo".
workbook.sheet(0).definedName("some other name").value("foo");
You can also create, modify, or delete defined names:
// Create/modify a workbook-scope defined name
workbook.definedName("some name", "TRUE");
// Delete a sheet-scoped defined name:
workbook.sheet(0).definedName("some name", null);
You can search for occurrences of text in cells within the workbook or sheets and optionally replace them.
// Find all occurrences of the text "foo" in the workbook and replace with "bar".
workbook.find("foo", "bar"); // Returns array of matched cells
// Find the matches but don't replace.
workbook.find("foo");
// Just look in the first sheet.
workbook.sheet(0).find("foo");
// Check if a particular cell matches the value.
workbook.sheet("Sheet1").cell("A1").find("foo"); // Returns true or false
Like
String.replace, the find method can also take a RegExp search pattern and replace can take a function callback:
// Use a RegExp to replace all lowercase letters with uppercase
workbook.find(/[a-z]+/g, match => match.toUpperCase());
xlsx-populate supports a wide range of cell formatting. See the
for the various options.
To set/set a cell style:
// Set a single style
cell.style("bold", true);
// Set multiple styles
cell.style({ bold: true, italic: true });
// Get a single style
const bold = cell.style("bold"); // true
// Get multiple styles
const styles = cell.style(["bold", "italic"]); // { bold: true, italic: true }
Similarly for ranges:
// Set all cells in range with a single style
range.style("bold", true);
// Set with a 2D array
range.style("bold", [[true, false], [false, true]]);
// Set with a callback function
range.style("bold", (cell, ri, ci, range) => Math.random() > 0.5);
// Set multiple styles using any combination
range.style({
bold: true,
italic: [[true, false], [false, true]],
underline: (cell, ri, ci, range) => Math.random() > 0.5
});
If you are setting styles for many cells, performance is far better if you set for an entire row or column:
// Set a single style
sheet.row(1).style("bold", true);
// Set multiple styles
sheet.column("A").style({ bold: true, italic: true });
// Get a single style
const bold = sheet.column(3).style("bold");
// Get multiple styles
const styles = sheet.row(5).style(["bold", "italic"]);
Note that the row/column style behavior mirrors Excel. Setting a style on a column will apply that style to all existing cells and any new cells that are populated. Getting the row/column style will return only the styles that have been applied to the entire row/column, not the styles of every cell in the row or column.
Some styles take values that are more complex objects:
cell.style("fill", {
type: "pattern",
pattern: "darkDown",
foreground: {
rgb: "ff0000"
},
background: {
theme: 3,
tint: 0.4
}
});
There are often shortcuts for the setters, but the getters will always return the full objects:
cell.style("fill", "0000ff");
const fill = cell.style("fill");
/*
fill is now set to:
{
type: "solid",
color: {
rgb: "0000ff"
}
}
*/
Number formats are one of the most common styles. They can be set using the
numberFormat
style.
cell.style("numberFormat", "0.00");
Information on how number format codes work can be found
here. You can also look up the desired format code in Excel:
- Right-click on a cell in Excel with the number format you want.
- Click on "Format Cells..."
- Switch the category to "Custom" if it is not already.
- The code in the "Type" box is the format you should copy.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#dates
Excel stores date/times as the number of days since 1/1/1900 (
sort of). It just applies a number formatting to make the number appear as a date. So to set a date value, you will need to also set a number format for a date if one doesn't already exist in the cell:
cell.value(new Date(2017, 1, 22)).style("numberFormat", "dddd, mmmm dd, yyyy");
When fetching the value of the cell, it will be returned as a number. To convert it to a date use
XlsxPopulate.numberToDate:
const num = cell.value(); // 42788
const date = XlsxPopulate.numberToDate(num); // Wed Feb 22 2017 00:00:00 GMT-0500 (Eastern Standard Time)
const num = cell.value(); // 42788
const date = XlsxPopulate.numberToDate(num); // Wed Feb 22 2017 00:00:00 GMT-0500 (Eastern Standard Time)
// Set the data validation
cell.dataValidation({
type: 'list',
allowBlank: false,
showInputMessage: false,
prompt: false,
promptTitle: 'String',
showErrorMessage: false,
error: 'String',
errorTitle: 'String',
operator: 'String',
formula1: '$A:$A',//Required
formula2: 'String'
});
//Here is a short version of the one above.
cell.dataValidation('$A:$A');
// Get the data validation
const obj = cell.dataValidation(); // Returns an object
// Remove the data validation
cell.dataValidation(null); //Returns the cell
// Set all cells in range with a single shared data validation
range.dataValidation({
type: 'list',
allowBlank: false,
showInputMessage: false,
prompt: false,
promptTitle: 'String',
showErrorMessage: false,
error: 'String',
errorTitle: 'String',
operator: 'String',
formula1: 'Item1,Item2,Item3,Item4',//Required
formula2: 'String'
});
//Here is a short version of the one above.
range.dataValidation('Item1,Item2,Item3,Item4');
// Get the data validation
const obj = range.dataValidation(); // Returns an object
// Remove the data validation
range.dataValidation(null); //Returns the Range
Please note, the data validation gets applied to the entire range, not each Cell in the range.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#method-chaining
xlsx-populate uses method-chaining similar to that found in
jQuery d3. This lets you construct large chains of setters as desired:
workbook
.sheet(0)
.cell("A1")
.value("foo")
.style("bold", true)
.relativeCell(1, 0)
.formula("A1")
.style("italic", true)
.workbook()
.sheet(1)
.range("A1:B3")
.value(5)
.cell(0, 0)
.style("underline", "double");
Hyperlinks are also supported on cells using the
Cell.hyperlinkmethod. The method will not style the content to look like a hyperlink. You must do that yourself:
// Set a hyperlink
cell.value("Link Text")
.style({ fontColor: "0563c1", underline: true })
.hyperlink("http://example.com");
// Get the hyperlink
const value = cell.hyperlink(); // Returns 'http://example.com'
You can serve the workbook from
expressor other web servers with something like this:
router.get("/download", function (req, res, next) {
// Open the workbook.
XlsxPopulate.fromFileAsync("input.xlsx")
.then(workbook => {
// Make edits.
workbook.sheet(0).cell("A1").value("foo");
// Get the output
return workbook.outputAsync();
})
.then(data => {
// Set the output file name.
res.attachment("output.xlsx");
// Send the workbook.
res.send(data);
})
.catch(next);
});
Usage in the browser is almost the same. A functional example can be found in
. The library is exposed globally as
XlsxPopulate
. Existing workbooks can be loaded from a file:
// Assuming there is a file input in the page with the id 'file-input'
var file = document.getElementById("file-input").files[0];
// A File object is a special kind of blob.
XlsxPopulate.fromDataAsync(file)
.then(function (workbook) {
// ...
});
You can also load from AJAX if you set the responseType to 'arraybuffer':
var req = new XMLHttpRequest();
req.open("GET", "http://...", true);
req.responseType = "arraybuffer";
req.onreadystatechange = function () {
if (req.readyState === 4 && req.status === 200){
XlsxPopulate.fromDataAsync(req.response)
.then(function (workbook) {
// ...
});
}
};
req.send();
To download the workbook, you can either export as a blob (default behavior) or as a base64 string. You can then insert a link into the DOM and click it:
workbook.outputAsync()
.then(function (blob) {
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
// If IE, you must uses a different method.
window.navigator.msSaveOrOpenBlob(blob, "out.xlsx");
} else {
var url = window.URL.createObjectURL(blob);
var a = document.createElement("a");
document.body.appendChild(a);
a.href = url;
a.download = "out.xlsx";
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}
});
Alternatively, you can download via a data URI, but this is not supported by IE:
workbook.outputAsync("base64")
.then(function (base64) {
location.href = "data:" + XlsxPopulate.MIME_TYPE + ";base64," + base64;
});
xlsx-populate uses
promisesto manage async input/output. By default it uses the
Promise
defined in the browser or Node.js. In browsers that don't support promises (IE) a
polyfill is used via JSZip// Get the current promise library in use.
// Helpful for getting a usable Promise library in IE.
var Promise = XlsxPopulate.Promise;
If you prefer, you can override the default
Promise
library used with another ES6 compliant library like
bluebirdconst Promise = require("bluebird");
const XlsxPopulate = require("xlsx-populate");
XlsxPopulate.Promise = Promise;
XLSX Agile encryption and descryption are supported so you can read and write password-protected workbooks. To read a protected workbook, pass the password in as an option:
XlsxPopulate.fromFileAsync("./Book1.xlsx", { password: "S3cret!" })
.then(workbook => {
// ...
});
Similarly, to write a password encrypted workbook:
workbook.toFileAsync("./out.xlsx", { password: "S3cret!" });
The password option is supported in all output methods. N.B. Workbooks will only be encrypted if you supply a password when outputting even if they had a password when reading.
Encryption support is also available in the browser, but take care! Any password you put in browser code can be read by anyone with access to your code. You should only use passwords that are supplied by the end-user. Also, the performance of encryption/decryption in the browser is far worse than with Node.js. IE, in particular, is extremely slow. xlsx-populate is bundled for browsers with and without encryption support as the encryption libraries increase the size of the bundle a lot.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#missing-features
There are many, many features of the XLSX format that are not yet supported. If your use case needs something that isn't supported please open an issue to show your support. Better still, feel free to
contributea pull request!
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#submitting-an-issue
If you happen to run into a bug or an issue, please feel free to
submit an issue. I only ask that you please include sample JavaScript code that demonstrates the issue. If the problem lies with modifying some template, it is incredibly difficult to debug the issue without the template. So please attach the template if possible. If you have confidentiality concerns, please attach a different workbook that exhibits the issue or you can send your workbook directly to
dtjohnsonafter creating the issue.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#contributing
Pull requests are very much welcome! If you'd like to contribute, please make sure to read this section carefully first.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#how-xlsx-populate-works
An XLSX workbook is essentially a zip of a bunch of XML files. xlsx-populate uses
JSZipto unzip the workbook and
sax-jsto parse the XML documents into corresponding objects. As you call methods, xlsx-populate manipulates the content of those objects. When you generate the output, xlsx-populate uses
xmlbuilder-jsto convert the objects back to XML and then uses JSZip to rezip them back into a workbook.
The way in which xlsx-populate manipulates objects that are essentially the XML data is very different from the usual way parser/generator libraries work. Most other libraries will deserialize the XML into a rich object model. That model is then manipulated and serialized back into XML upon generation. The challenge with this approach is that the Office Open XML spec is
HUGE. It is extremely difficult for libraries to be able to support the entire specification. So these other libraries will deserialize only the portion of the spec they support and any other content/styles in the workbook they don't support are lost. Since xlsx-populate just manipulates the XML data, it is able to preserve styles and other content while still only supporting a fraction of the spec.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#setting-up-your-environment
You'll need to make sure
v4+ is installed (as xlsx-populate uses ES6 syntax). You'll also need to install
gulpnpm install -g gulp
Make sure you have
gitinstalled. Then follow
this guideto see how to check out code, branch, and then submit your code as a pull request. When you check out the code, you'll first need to install the npm dependencies. From the project root, run:
npm install
The default gulp task is set up to watch the source files for updates and retest while you edit. From the project root just run:
gulp
You should see the test output in your console window. As you edit files the tests will run again and show you if you've broken anything. (Note that if you've added new files you'll need to restart gulp for the new files to be watched.)
Now write your code and make sure to add
Jasmineunit tests. When you are finished, you need to build the code for the browser. Do that by running the gulp build command:
gulp build
Verify all is working, check in your code, and submit a pull request.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#pull-request-checklist
To make sure your code is consistent and high quality, please make sure to follow this checklist before submitting a pull request:
- Your code must follow the getter/setter pattern using a single function for both. Check
or usearguments.length
to distinguish.ArgHandler
- You must use valid JSDoc comments on all methods and classes. Use
for private methods and@private
for any public methods that are internal to xlsx-populate and should not be included in the public API docs.@ignore
- You must adhere to the configured ESLint linting rules. You can configure your IDE to display rule violations live or you can run
to see them.gulp lint
- Use ES6 syntax. (This should be enforced by ESLint.)
- Make sure to have full unit test coverage for your code.
- Make sure all tests pass successfully.
- Whenever possible, do not modify/break existing API behavior. This module adheres to the semantic versioning standard . So any breaking changes will require a major release.
- If your feature needs more documentation than just the JSDoc output, please add to the docs/template.md README file.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#gulp-tasks
as a build tool. There are a number of tasks:
- browser - Transpile and build client-side JavaScript project bundle using and
- lint - Check project source code style using
- unit - Run unit tests.
- unit-browser - Run the unit tests in real browsers using Karma
- e2e-parse - End-to-end tests of parsing data out of sample workbooks that were created in Microsoft Excel.
- e2e-generate - End-to-end tests of generating workbooks using xlsx-populate. To verify the workbooks were truly generated correctly they need to be opened in Microsoft Excel and verified. This task automates this verification using the .NET Excel Interop library with Edge.js acting as a bridge between Node.js and C#. Note that these tests will only run on Windows with Microsoft Excel and the Primary Interop Assemblies installed
- e2e-browser - End-to-end tests of usage of the browserify bundle in real browsers using Karma.
- blank - Convert a blank XLSX template into a JS buffer module to support fromBlankAsync
- docs - Build this README doc by combining docs/template.md, API docs generated with jsdoc-to-markdown , and a table of contents generated with markdown-toc
- watch - Watch files for changes and then run associated gulp task. (Used by the default task.)
- build - Run all gulp tasks, including linting and tests, and build the docs and browser bundle.
- default - Run blank, unit, and docs tasks and watch the source files for those tasks for changes.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#style-reference
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#styles-1
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#color Color
An object representing a color.
Property | ||
---|---|---|
[rgb] | | RGB color code (e.g. ). Either rgb or theme is required. |
[theme] | | Index of a theme color. Either rgb or theme is required. |
[tint] | | Optional tint value of the color from -1 to 1. Particularly useful for theme colors. 0.0 means no tint, -1.0 means 100% darken, and 1.0 means 100% lighten. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#borders Borders
An object representing all of the borders.
[left] | ||
[right] | ||
[top] | ||
[bottom] | ||
[diagonal] |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#border
An object representing an individual border.
style | | Style of the given border. |
color | ||
[direction] | | For diagonal border, the direction of the border(s) from left to right. Allowed values: |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#solidfill SolidFill
An object representing a solid fill.
type | | |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#patternfill
An object representing a pattern fill.
| ||
pattern | | Name of the pattern. Allowed values: , |
foreground | ||
background |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#gradientfill GradientFill
An object representing a gradient fill.
| ||
[gradientType] | | Type of gradient. Allowed values: (default), . With a path gradient, a path is drawn between the top, left, right, and bottom values and a graident is draw from that path to the outside of the cell. |
stops | | |
stops[].position | | The position of the stop from 0 to 1. |
stops[].color | ||
[angle] | | If linear gradient, the angle of clockwise rotation of the gradient. |
| If path gradient, the left position of the path as a percentage from 0 to 1. | |
| If path gradient, the right position of the path as a percentage from 0 to 1. | |
| If path gradient, the top position of the path as a percentage from 0 to 1. | |
| If path gradient, the bottom position of the path as a percentage from 0 to 1. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#api-reference
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#classes Classes
- Cell
- A cell
- Column
- A column.
- FormulaError
- A formula error (e.g. #DIV/0!).
- Range
- A range of cells.
- Row
- A row.
- Sheet
- A worksheet.
- Workbook
- A workbook.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#objects Objects
- XlsxPopulate :
object
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#constants Constants
- _
- OOXML uses the CFB file format with Agile Encryption. The details of the encryption are here: msdn.microsoft.com/en-us/libra… Helpful guidance also take from this Github project: github.com/nolze/ms-of…
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cell
Kind: global class
-
- instance
- .active() ⇒
boolean
- .active(active)
Cell
- .address([opts])
string
- .column()
Column
- .clear()
Cell
- .columnName()
number
- .columnNumber()
number
- .find(pattern, [replacement])
boolean
- .formula()
string
- .formula(formula)
Cell
- .hyperlink()
|string
undefined
- .hyperlink(hyperlink)
Cell
- .dataValidation()
object
undefined
- .dataValidation(dataValidation)
Cell
- .tap(callback)
Cell
- .thru(callback)
*
- .rangeTo(cell)
Range
- .relativeCell(rowOffset, columnOffset)
Cell
- .row()
Row
- .rowNumber()
number
- .sheet()
Sheet
- .style(name)
*
- .style(names)
object.<string, *>
- .style(name, value)
Cell
-
Range
- .style(styles)
Cell
- .style(style)
Cell
- .value()
string
boolean
number
Date
undefined
- .value(value)
Cell
-
Range
- .workbook()
Workbook
- .active() ⇒
- inner
- ~tapCallback
undefined
- ~thruCallback
*
- ~tapCallback
- instance
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellactive--boolean cell.active() ⇒ boolean
boolean
Gets a value indicating whether the cell is the active cell in the sheet.
Kind: instance method of
Cell
Returns:
boolean
- True if active, false otherwise.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellactiveactive--cell cell.active(active) ⇒ Cell
Cell
Make the cell the active cell in the sheet.
Cell
Cell
- The cell.
Param | ||
---|---|---|
active | | Must be set to . Deactivating directly is not supported. To deactivate, you should activate a different cell instead. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#celladdressopts--string cell.address([opts]) ⇒ string
string
Get the address of the column.
Cell
string
- The address
[opts] | | Options |
[opts.includeSheetName] | | Include the sheet name in the address. |
[opts.rowAnchored] | | Anchor the row. |
[opts.columnAnchored] | | Anchor the column. |
[opts.anchored] | | Anchor both the row and the column. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellcolumn--column cell.column() ⇒ Column
Column
Gets the parent column of the cell.
Cell
Column
- The parent column.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellclear--cell cell.clear() ⇒ Cell
Cell
Clears the contents from the cell.
Cell
Cell
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellcolumnname--number cell.columnName() ⇒ number
number
Gets the column name of the cell.
Cell
number
- The column name.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellcolumnnumber--number cell.columnNumber() ⇒ number
number
Gets the column number of the cell (1-based).
Cell
number
- The column number.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellfindpattern-replacement--boolean cell.find(pattern, [replacement]) ⇒ boolean
boolean
Find the given pattern in the cell and optionally replace it.
Cell
boolean
- A flag indicating if the pattern was found.
| The pattern to look for. Providing a string will result in a case-insensitive substring search. Use a RegExp for more sophisticated searches. | |
[replacement] | | The text to replace or a String.replace callback function. If pattern is a string, all occurrences of the pattern in the cell will be replaced. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellformula--string cell.formula() ⇒ string
string
Gets the formula in the cell. Note that if a formula was set as part of a range, the getter will return 'SHARED'. This is a limitation that may be addressed in a future release.
Cell
string
- The formula in the cell.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellformulaformula--cell cell.formula(formula) ⇒ Cell
Cell
Sets the formula in the cell.
Cell
Cell
formula | | The formula to set. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellhyperlink--string--undefined cell.hyperlink() ⇒ string
undefined
string
undefined
Gets the hyperlink attached to the cell.
Cell
string
undefined
- The hyperlink or undefined if not set.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellhyperlinkhyperlink--cell cell.hyperlink(hyperlink) ⇒ Cell
Cell
Set or clear the hyperlink on the cell.
Cell
Cell
hyperlink | | The hyperlink to set or undefined to clear. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#celldatavalidation--object--undefined cell.dataValidation() ⇒ object
undefined
object
undefined
Gets the data validation object attached to the cell.
Cell
object
undefined
- The data validation or undefined if not set.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#celldatavalidationdatavalidation--cell cell.dataValidation(dataValidation) ⇒ Cell
Cell
Set or clear the data validation object of the cell.
Cell
Cell
dataValidation | | Object or null to clear. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#celltapcallback--cell cell.tap(callback) ⇒ Cell
Cell
Invoke a callback on the cell and return the cell. Useful for method chaining.
Cell
Cell
callback | | The callback function. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellthrucallback-- cell.thru(callback) ⇒ *
*
Invoke a callback on the cell and return the value provided by the callback. Useful for method chaining.
Cell
*
- The return value of the callback.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellrangetocell--range cell.rangeTo(cell) ⇒ Range
Range
Create a range from this cell and another.
Cell
Range
- The range.
cell | | The other cell or cell address to range to. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellrelativecellrowoffset-columnoffset--cell cell.relativeCell(rowOffset, columnOffset) ⇒ Cell
Cell
Returns a cell with a relative position given the offsets provided.
Cell
Cell
- The relative cell.
rowOffset | | The row offset (0 for the current row). |
columnOffset | | The column offset (0 for the current column). |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellrow--row cell.row() ⇒ Row
Row
Gets the parent row of the cell.
Cell
Row
- The parent row.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellrownumber--number cell.rowNumber() ⇒ number
number
Gets the row number of the cell (1-based).
Cell
number
- The row number.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellsheet--sheet cell.sheet() ⇒ Sheet
Sheet
Gets the parent sheet.
Cell
Sheet
- The parent sheet.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellstylename-- cell.style(name) ⇒ *
*
Gets an individual style.
Cell
*
- The style.
name | | The name of the style. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellstylenames--objectstring- cell.style(names) ⇒ object.<string, *>
object.<string, *>
Gets multiple styles.
Cell
object.<string, *>
- Object whose keys are the style names and values are the styles.
names | | The names of the style. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellstylename-value--cell cell.style(name, value) ⇒ Cell
Cell
Sets an individual style.
Cell
Cell
| ||
| The value to set. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellstylename--range Range
Range
Sets the styles in the range starting with the cell.
Cell
Range
- The range that was set.
| ||
| 2D array of values to set. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellstylestyles--cell cell.style(styles) ⇒ Cell
Cell
Sets multiple styles.
Cell
Cell
styles | | Object whose keys are the style names and values are the styles to set. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellstylestyle--cell cell.style(style) ⇒ Cell
Cell
Sets to a specific style
Cell
Cell
| Style object given from stylesheet.createStyle |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellvalue--string--boolean--number--date--undefined cell.value() ⇒ string
boolean
number
Date
undefined
string
boolean
number
Date
undefined
Gets the value of the cell.
Cell
string
boolean
number
Date
undefined
- The value of the cell.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellvaluevalue--cell cell.value(value) ⇒ Cell
Cell
Sets the value of the cell.
Cell
Cell
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellvalue--range Range
Range
Sets the values in the range starting with the cell.
Cell
Range
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellworkbook--workbook cell.workbook() ⇒ Workbook
Workbook
Gets the parent workbook.
Cell
Workbook
- The parent workbook.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#celltapcallback--undefined Cell~tapCallback ⇒ undefined
undefined
Callback used by tap.
Kind: inner typedef of
Cell
| The cell |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#cellthrucallback---1 Cell~thruCallback ⇒ *
*
Callback used by thru.
Cell
*
- The value to return from thru.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#column
-
-
string
- .cell(rowNumber)
Cell
-
string
-
number
- .hidden()
boolean
- .hidden(hidden)
Column
-
Sheet
-
*
-
object.<string, *>
-
Cell
-
Cell
-
Cell
- .width()
undefined
number
- .width(width)
Column
-
Workbook
-
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnaddressopts--string column.address([opts]) ⇒ string
string
Column
string
| ||
| ||
| Anchor the address. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columncellrownumber--cell column.cell(rowNumber) ⇒ Cell
Cell
Get a cell within the column.
Column
Cell
- The cell in the column with the given row number.
rowNumber | | The row number. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columncolumnname--string column.columnName() ⇒ string
string
Get the name of the column.
Column
string
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columncolumnnumber--number column.columnNumber() ⇒ number
number
Get the number of the column.
Column
number
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnhidden--boolean column.hidden() ⇒ boolean
boolean
Gets a value indicating whether the column is hidden.
Column
boolean
- A flag indicating whether the column is hidden.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnhiddenhidden--column column.hidden(hidden) ⇒ Column
Column
Sets whether the column is hidden.
Column
Column
- The column.
hidden | | A flag indicating whether to hide the column. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnsheet--sheet column.sheet() ⇒ Sheet
Sheet
Get the parent sheet.
Column
Sheet
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnstylename-- column.style(name) ⇒ *
*
Column
*
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnstylenames--objectstring- column.style(names) ⇒ object.<string, *>
object.<string, *>
Column
object.<string, *>
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnstylename-value--cell column.style(name, value) ⇒ Cell
Cell
Column
Cell
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnstylestyles--cell column.style(styles) ⇒ Cell
Cell
Column
Cell
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnstylestyle--cell column.style(style) ⇒ Cell
Cell
Column
Cell
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnwidth--undefined--number column.width() ⇒ undefined
number
undefined
number
Gets the width.
Column
undefined
number
- The width (or undefined).
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnwidthwidth--column column.width(width) ⇒ Column
Column
Sets the width.
Column
Column
width | | The width of the column. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#columnworkbook--workbook column.workbook() ⇒ Workbook
Workbook
Get the parent workbook.
Column
Workbook
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerror
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrorerror--string formulaError.error() ⇒ string
string
Get the error code.
FormulaError
string
- The error code.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrordiv0--formulaerror FormulaError.DIV0 : FormulaError
FormulaError
#DIV/0! error.
Kind: static property of
FormulaError
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrorna--formulaerror FormulaError.NA : FormulaError
FormulaError
#N/A error.
FormulaError
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrorname--formulaerror FormulaError.NAME : FormulaError
FormulaError
#NAME? error.
FormulaError
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrornull--formulaerror FormulaError.NULL : FormulaError
FormulaError
#NULL! error.
FormulaError
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrornum--formulaerror FormulaError.NUM : FormulaError
FormulaError
#NUM! error.
FormulaError
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrorref--formulaerror FormulaError.REF : FormulaError
FormulaError
#REF! error.
FormulaError
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#formulaerrorvalue--formulaerror FormulaError.VALUE : FormulaError
FormulaError
#VALUE! error.
FormulaError
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#range
-
-
-
string
- .cell(ri, ci)
Cell
- .autoFilter()
Range
- .cells()
Array.<Array.<Cell>>
-
Range
- .endCell()
Cell
- .forEach(callback)
Range
-
string
undefined
-
Range
- .map(callback)
Array.<Array.<*>>
- .merged()
boolean
- .merged(merged)
Range
-
object
undefined
-
Range
- .reduce(callback, [initialValue])
*
-
Sheet
- .startCell()
Cell
-
Array.<Array.<*>>
-
Object.<string, Array.<Array.<*>>>
-
Range
-
Range
-
Range
-
Range
-
Range
-
Range
-
*
-
Array.<Array.<*>>
- .value(callback)
Range
- .value(values)
Range
-
Range
-
Workbook
-
-
- ~forEachCallback
undefined
- ~mapCallback
*
- ~reduceCallback
*
-
undefined
-
*
- ~forEachCallback
-
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeaddressopts--string range.address([opts]) ⇒ string
string
Get the address of the range.
Range
string
- The address.
| ||
| ||
[opts.startRowAnchored] | | Anchor the start row. |
[opts.startColumnAnchored] | | Anchor the start column. |
[opts.endRowAnchored] | | Anchor the end row. |
[opts.endColumnAnchored] | | Anchor the end column. |
| Anchor all row and columns. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangecellri-ci--cell range.cell(ri, ci) ⇒ Cell
Cell
Gets a cell within the range.
Range
Cell
ri | | Row index relative to the top-left corner of the range (0-based). |
ci | | Column index relative to the top-left corner of the range (0-based). |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeautofilter--range range.autoFilter() ⇒ Range
Range
Sets sheet autoFilter to this range.
Range
Range
- This range.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangecells--arrayarraycell range.cells() ⇒ Array.<Array.<Cell>>
Array.<Array.<Cell>>
Get the cells in the range as a 2D array.
Range
Array.<Array.<Cell>>
- The cells.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeclear--range range.clear() ⇒ Range
Range
Clear the contents of all the cells in the range.
Range
Range
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeendcell--cell range.endCell() ⇒ Cell
Cell
Get the end cell of the range.
Range
Cell
- The end cell.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeforeachcallback--range range.forEach(callback) ⇒ Range
Range
Call a function for each cell in the range. Goes by row then column.
Range
Range
| Function called for each cell in the range. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeformula--string--undefined range.formula() ⇒ string
undefined
string
undefined
Gets the shared formula in the start cell (assuming it's the source of the shared formula).
Range
string
undefined
- The shared formula.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeformulaformula--range range.formula(formula) ⇒ Range
Range
Sets the shared formula in the range. The formula will be translated for each cell.
Range
Range
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangemapcallback--arrayarray range.map(callback) ⇒ Array.<Array.<*>>
Array.<Array.<*>>
Creates a 2D array of values by running each cell through a callback.
Range
Array.<Array.<*>>
- The 2D array of return values.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangemerged--boolean range.merged() ⇒ boolean
boolean
Gets a value indicating whether the cells in the range are merged.
Range
boolean
- The value.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangemergedmerged--range range.merged(merged) ⇒ Range
Range
Sets a value indicating whether the cells in the range should be merged.
Range
Range
merged | | True to merge, false to unmerge. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangedatavalidation--object--undefined range.dataValidation() ⇒ object
undefined
object
undefined
Gets the data validation object attached to the Range.
Range
object
undefined
- The data validation object or undefined if not set.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangedatavalidationdatavalidation--range range.dataValidation(dataValidation) ⇒ Range
Range
Set or clear the data validation object of the entire range.
Range
Range
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangereducecallback-initialvalue-- range.reduce(callback, [initialValue]) ⇒ *
*
Reduces the range to a single value accumulated from the result of a function called for each cell.
Range
*
- The accumulated value.
| ||
[initialValue] | | The initial value. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangesheet--sheet range.sheet() ⇒ Sheet
Sheet
Gets the parent sheet of the range.
Range
Sheet
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestartcell--cell range.startCell() ⇒ Cell
Cell
Gets the start cell of the range.
Range
Cell
- The start cell.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestylename--arrayarray range.style(name) ⇒ Array.<Array.<*>>
Array.<Array.<*>>
Gets a single style for each cell.
Range
Array.<Array.<*>>
- 2D array of style values.
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestylenames--objectstring-arrayarray range.style(names) ⇒ Object.<string, Array.<Array.<*>>>
Object.<string, Array.<Array.<*>>>
Gets multiple styles for each cell.
Range
Object.<string, Array.<Array.<*>>>
- Object whose keys are style names and values are 2D arrays of style values.
| The names of the styles. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestylename--range Range
Range
Set the style in each cell to the result of a function called for each.
Range
Range
| ||
| The callback to provide value for the cell. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestylename--range-1 Range
Range
Sets the style in each cell to the corresponding value in the given 2D array of values.
Range
Range
| ||
| The style values to set. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestylename-value--range range.style(name, value) ⇒ Range
Range
Set the style of all cells in the range to a single style value.
Range
Range
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestylestyles--range range.style(styles) ⇒ Range
Range
Set multiple styles for the cells in the range.
Range
Range
| Object whose keys are style names and values are either function callbacks, 2D arrays of style values, or a single value for all the cells. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangestylestyle--range range.style(style) ⇒ Range
Range
Range
Range
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangetapcallback--range range.tap(callback) ⇒ Range
Range
Invoke a callback on the range and return the range. Useful for method chaining.
Range
Range
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangethrucallback-- range.thru(callback) ⇒ *
*
Invoke a callback on the range and return the value provided by the callback. Useful for method chaining.
Range
*
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangevalue--arrayarray range.value() ⇒ Array.<Array.<*>>
Array.<Array.<*>>
Get the values of each cell in the range as a 2D array.
Range
Array.<Array.<*>>
- The values.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangevaluecallback--range range.value(callback) ⇒ Range
Range
Set the values in each cell to the result of a function called for each.
Range
Range
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangevaluevalues--range range.value(values) ⇒ Range
Range
Sets the value in each cell to the corresponding value in the given 2D array of values.
Range
Range
values | | The values to set. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangevaluevalue--range range.value(value) ⇒ Range
Range
Set the value of all cells in the range to a single value.
Range
Range
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeworkbook--workbook range.workbook() ⇒ Workbook
Workbook
Range
Workbook
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangeforeachcallback--undefined Range~forEachCallback ⇒ undefined
undefined
Callback used by forEach.
Range
| The cell. | |
| The relative row index. | |
| The relative column index. | |
range | | The range. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangemapcallback-- Range~mapCallback ⇒ *
*
Callback used by map.
Range
*
- The value to map to.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangereducecallback-- Range~reduceCallback ⇒ *
*
Callback used by reduce.
Range
*
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangetapcallback--undefined Range~tapCallback ⇒ undefined
undefined
Range
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rangethrucallback---1 Range~thruCallback ⇒ *
*
Range
*
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#row
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowaddressopts--string row.address([opts]) ⇒ string
string
Get the address of the row.
Row
string
| ||
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowcellcolumnnameornumber--cell row.cell(columnNameOrNumber) ⇒ Cell
Cell
Get a cell in the row.
Row
Cell
columnNameOrNumber | | The name or number of the column. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowheight--undefined--number row.height() ⇒ undefined
number
undefined
number
Gets the row height.
Row
undefined
number
- The height (or undefined).
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowheightheight--row row.height(height) ⇒ Row
Row
Sets the row height.
Row
Row
- The row.
height | | The height of the row. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowhidden--boolean row.hidden() ⇒ boolean
boolean
Gets a value indicating whether the row is hidden.
Row
boolean
- A flag indicating whether the row is hidden.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowhiddenhidden--row row.hidden(hidden) ⇒ Row
Row
Sets whether the row is hidden.
Row
Row
| A flag indicating whether to hide the row. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowrownumber--number row.rowNumber() ⇒ number
number
Gets the row number.
Row
number
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowsheet--sheet row.sheet() ⇒ Sheet
Sheet
Gets the parent sheet of the row.
Row
Sheet
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowstylename-- row.style(name) ⇒ *
*
Row
*
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowstylenames--objectstring- row.style(names) ⇒ object.<string, *>
object.<string, *>
Row
object.<string, *>
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowstylename-value--cell row.style(name, value) ⇒ Cell
Cell
Row
Cell
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowstylestyles--cell row.style(styles) ⇒ Cell
Cell
Row
Cell
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowstylestyle--cell row.style(style) ⇒ Cell
Cell
Row
Cell
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#rowworkbook--workbook row.workbook() ⇒ Workbook
Workbook
Row
Workbook
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheet
-
-
boolean
-
Sheet
- .activeCell()
Cell
- .activeCell(cell)
Sheet
- .activeCell(rowNumber, columnNameOrNumber)
Sheet
- .cell(address)
Cell
- .cell(rowNumber, columnNameOrNumber)
Cell
- .column(columnNameOrNumber)
Column
- .definedName(name)
undefined
string
Cell
Range
Row
Column
- .definedName(name, refersTo)
Workbook
- .delete()
Workbook
-
Array.<Cell>
- .gridLinesVisible()
boolean
- .gridLinesVisible(selected)
Sheet
-
boolean
string
-
Sheet
- .move([indexOrBeforeSheet])
Sheet
- .name()
string
- .name(name)
Sheet
- .range(address)
Range
- .range(startCell, endCell)
Range
- .range(startRowNumber, startColumnNameOrNumber, endRowNumber, endColumnNameOrNumber)
Range
-
Sheet
- .autoFilter(range)
Sheet
- .row(rowNumber)
Row
- .tabColor()
undefined
Color
-
Color
string
number
- .tabSelected()
boolean
- .tabSelected(selected)
Sheet
- .usedRange()
Range
undefined
-
Workbook
-
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetactive--boolean sheet.active() ⇒ boolean
boolean
Gets a value indicating whether the sheet is the active sheet in the workbook.
Sheet
boolean
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetactiveactive--sheet sheet.active(active) ⇒ Sheet
Sheet
Make the sheet the active sheet in the workkbok.
Sheet
Sheet
- The sheet.
| . Deactivating directly is not supported. To deactivate, you should activate a different sheet instead. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetactivecell--cell sheet.activeCell() ⇒ Cell
Cell
Get the active cell in the sheet.
Sheet
Cell
- The active cell.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetactivecellcell--sheet sheet.activeCell(cell) ⇒ Sheet
Sheet
Set the active cell in the workbook.
Sheet
Sheet
| The cell or address of cell to activate. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetactivecellrownumber-columnnameornumber--sheet sheet.activeCell(rowNumber, columnNameOrNumber) ⇒ Sheet
Sheet
Set the active cell in the workbook by row and column.
Sheet
Sheet
| The row number of the cell. | |
| The column name or number of the cell. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetcelladdress--cell sheet.cell(address) ⇒ Cell
Cell
Gets the cell with the given address.
Sheet
Cell
address | | The address of the cell. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetcellrownumber-columnnameornumber--cell sheet.cell(rowNumber, columnNameOrNumber) ⇒ Cell
Cell
Gets the cell with the given row and column numbers.
Sheet
Cell
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetcolumncolumnnameornumber--column sheet.column(columnNameOrNumber) ⇒ Column
Column
Gets a column in the sheet.
Sheet
Column
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetdefinednamename--undefined--string--cell--range--row--column sheet.definedName(name) ⇒ undefined
string
Cell
Range
Row
Column
undefined
string
Cell
Range
Row
Column
Gets a defined name scoped to the sheet.
Sheet
undefined
string
Cell
Range
Row
Column
- What the defined name refers to or undefined if not found. Will return the string formula if not a Row, Column, Cell, or Range.
| The defined name. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetdefinednamename-refersto--workbook sheet.definedName(name, refersTo) ⇒ Workbook
Workbook
Set a defined name scoped to the sheet.
Sheet
Workbook
- The workbook.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetdelete--workbook sheet.delete() ⇒ Workbook
Workbook
Deletes the sheet and returns the parent workbook.
Sheet
Workbook
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetfindpattern-replacement--arraycell sheet.find(pattern, [replacement]) ⇒ Array.<Cell>
Array.<Cell>
Find the given pattern in the sheet and optionally replace it.
Sheet
Array.<Cell>
- The matching cells.
| ||
| The text to replace or a String.replace callback function. If pattern is a string, all occurrences of the pattern in each cell will be replaced. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetgridlinesvisible--boolean sheet.gridLinesVisible() ⇒ boolean
boolean
Gets a value indicating whether this sheet's grid lines are visible.
Sheet
boolean
- True if selected, false if not.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetgridlinesvisibleselected--sheet sheet.gridLinesVisible(selected) ⇒ Sheet
Sheet
Sets whether this sheet's grid lines are visible.
Sheet
Sheet
selected | | True to make visible, false to hide. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheethidden--boolean--string sheet.hidden() ⇒ boolean
string
boolean
string
Gets a value indicating if the sheet is hidden or not.
Sheet
boolean
string
- True if hidden, false if visible, and 'very' if very hidden.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheethiddenhidden--sheet sheet.hidden(hidden) ⇒ Sheet
Sheet
Set whether the sheet is hidden or not.
Sheet
Sheet
| True to hide, false to show, and 'very' to make very hidden. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetmoveindexorbeforesheet--sheet sheet.move([indexOrBeforeSheet]) ⇒ Sheet
Sheet
Move the sheet.
Sheet
Sheet
[indexOrBeforeSheet] | | The index to move the sheet to or the sheet (or name of sheet) to move this sheet before. Omit this argument to move to the end of the workbook. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetname--string sheet.name() ⇒ string
string
Get the name of the sheet.
Sheet
string
- The sheet name.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetnamename--sheet sheet.name(name) ⇒ Sheet
Sheet
Set the name of the sheet. Note: this method does not rename references to the sheet so formulas, etc. can be broken. Use with caution!
Sheet
Sheet
| The name to set to the sheet. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetrangeaddress--range sheet.range(address) ⇒ Range
Range
Gets a range from the given range address.
Sheet
Range
| The range address (e.g. 'A1:B3'). |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetrangestartcell-endcell--range sheet.range(startCell, endCell) ⇒ Range
Range
Gets a range from the given cells or cell addresses.
Sheet
Range
startCell | | The starting cell or cell address (e.g. 'A1'). |
endCell | | The ending cell or cell address (e.g. 'B3'). |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetrangestartrownumber-startcolumnnameornumber-endrownumber-endcolumnnameornumber--range sheet.range(startRowNumber, startColumnNameOrNumber, endRowNumber, endColumnNameOrNumber) ⇒ Range
Range
Gets a range from the given row numbers and column names or numbers.
Sheet
Range
startRowNumber | | The starting cell row number. |
startColumnNameOrNumber | | The starting cell column name or number. |
endRowNumber | | The ending cell row number. |
endColumnNameOrNumber | | The ending cell column name or number. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetautofilter--sheet sheet.autoFilter() ⇒ Sheet
Sheet
Unsets sheet autoFilter.
Sheet
Sheet
- This sheet.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetautofilterrange--sheet sheet.autoFilter(range) ⇒ Sheet
Sheet
Sets sheet autoFilter to a Range.
Sheet
Sheet
| The autoFilter range. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetrowrownumber--row sheet.row(rowNumber) ⇒ Row
Row
Gets the row with the given number.
Sheet
Row
- The row with the given number.
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheettabcolor--undefined--color sheet.tabColor() ⇒ undefined
Color
undefined
Color
Get the tab color. (See style
.)
Sheet
undefined
Color
- The color or undefined if not set.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheettabcolor--color--string--number Color
string
number
Color
string
number
Sets the tab color. (See style
Sheet
Color
string
number
- color - Color of the tab. If string, will set an RGB color. If number, will set a theme color.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheettabselected--boolean sheet.tabSelected() ⇒ boolean
boolean
Gets a value indicating whether this sheet is selected.
Sheet
boolean
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheettabselectedselected--sheet sheet.tabSelected(selected) ⇒ Sheet
Sheet
Sets whether this sheet is selected.
Sheet
Sheet
| True to select, false to deselected. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetusedrange--range--undefined sheet.usedRange() ⇒ Range
undefined
Range
undefined
Get the range of cells in the sheet that have contained a value or style at any point. Useful for extracting the entire sheet contents.
Sheet
Range
undefined
- The used range or undefined if no cells in the sheet are used.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#sheetworkbook--workbook sheet.workbook() ⇒ Workbook
Workbook
Sheet
Workbook
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbook
-
- .activeSheet()
Sheet
- .activeSheet(sheet)
Workbook
- .addSheet(name, [indexOrBeforeSheet])
Sheet
-
undefined
string
Cell
Range
Row
Column
-
Workbook
- .deleteSheet(sheet)
Workbook
-
boolean
- .moveSheet(sheet, [indexOrBeforeSheet])
Workbook
- .outputAsync([type])
string
Uint8Array
ArrayBuffer
Blob
Buffer
- .outputAsync([opts])
string
Uint8Array
ArrayBuffer
Blob
Buffer
- .sheet(sheetNameOrIndex)
Sheet
undefined
- .sheets()
Array.<Sheet>
- .property(name)
*
- .property(names)
object.<string, *>
- .property(name, value)
Workbook
- .property(properties)
Workbook
- .properties()
CoreProperties
- .toFileAsync(path, [opts])
Promise.<undefined>
- .activeSheet()
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookactivesheet--sheet workbook.activeSheet() ⇒ Sheet
Sheet
Get the active sheet in the workbook.
Workbook
Sheet
- The active sheet.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookactivesheetsheet--workbook workbook.activeSheet(sheet) ⇒ Workbook
Workbook
Set the active sheet in the workbook.
Workbook
Workbook
sheet | | The sheet or name of sheet or index of sheet to activate. The sheet must not be hidden. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookaddsheetname-indexorbeforesheet--sheet workbook.addSheet(name, [indexOrBeforeSheet]) ⇒ Sheet
Sheet
Add a new sheet to the workbook.
Workbook
Sheet
- The new sheet.
| The name of the sheet. Must be unique, less than 31 characters, and may not contain the following characters: \ / * [ ] : ? | |
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookdefinednamename--undefined--string--cell--range--row--column workbook.definedName(name) ⇒ undefined
string
Cell
Range
Row
Column
undefined
string
Cell
Range
Row
Column
Gets a defined name scoped to the workbook.
Workbook
undefined
string
Cell
Range
Row
Column
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookdefinednamename-refersto--workbook workbook.definedName(name, refersTo) ⇒ Workbook
Workbook
Set a defined name scoped to the workbook.
Workbook
Workbook
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookdeletesheetsheet--workbook workbook.deleteSheet(sheet) ⇒ Workbook
Workbook
Delete a sheet from the workbook.
Workbook
Workbook
| The sheet or name of sheet or index of sheet to move. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookfindpattern-replacement--boolean workbook.find(pattern, [replacement]) ⇒ boolean
boolean
Find the given pattern in the workbook and optionally replace it.
Workbook
boolean
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookmovesheetsheet-indexorbeforesheet--workbook workbook.moveSheet(sheet, [indexOrBeforeSheet]) ⇒ Workbook
Workbook
Move a sheet to a new position.
Workbook
Workbook
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookoutputasynctype--string--uint8array--arraybuffer--blob--buffer workbook.outputAsync([type]) ⇒ string
Uint8Array
ArrayBuffer
Blob
Buffer
string
Uint8Array
ArrayBuffer
Blob
Buffer
Generates the workbook output.
Workbook
string
Uint8Array
ArrayBuffer
Blob
Buffer
- The data.
[type] | | The type of the data to return: base64, binarystring, uint8array, arraybuffer, blob, nodebuffer. Defaults to 'nodebuffer' in Node.js and 'blob' in browsers. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookoutputasyncopts--string--uint8array--arraybuffer--blob--buffer workbook.outputAsync([opts]) ⇒ string
Uint8Array
ArrayBuffer
Blob
Buffer
string
Uint8Array
ArrayBuffer
Blob
Buffer
Workbook
string
Uint8Array
ArrayBuffer
Blob
Buffer
| ||
[opts.type] | | |
[opts.password] | | The password to use to encrypt the workbook. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbooksheetsheetnameorindex--sheet--undefined workbook.sheet(sheetNameOrIndex) ⇒ Sheet
undefined
Sheet
undefined
Gets the sheet with the provided name or index (0-based).
Workbook
Sheet
undefined
- The sheet or undefined if not found.
sheetNameOrIndex | | The sheet name or index. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbooksheets--arraysheet workbook.sheets() ⇒ Array.<Sheet>
Array.<Sheet>
Get an array of all the sheets in the workbook.
Workbook
Array.<Sheet>
- The sheets.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookpropertyname-- workbook.property(name) ⇒ *
*
Gets an individual property.
Workbook
*
- The property.
| The name of the property. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookpropertynames--objectstring- workbook.property(names) ⇒ object.<string, *>
object.<string, *>
Gets multiple properties.
Workbook
object.<string, *>
- Object whose keys are the property names and values are the properties.
| The names of the properties. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookpropertyname-value--workbook workbook.property(name, value) ⇒ Workbook
Workbook
Sets an individual property.
Workbook
Workbook
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookpropertyproperties--workbook workbook.property(properties) ⇒ Workbook
Workbook
Sets multiple properties.
Workbook
Workbook
properties | | Object whose keys are the property names and values are the values to set. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbookproperties--coreproperties workbook.properties() ⇒ CoreProperties
CoreProperties
Get access to core properties object
Workbook
CoreProperties
- The core properties.
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#workbooktofileasyncpath-opts--promiseundefined workbook.toFileAsync(path, [opts]) ⇒ Promise.<undefined>
Promise.<undefined>
Write the workbook to file. (Not supported in browsers.)
Workbook
Promise.<undefined>
- A promise.
path | | The path of the file to write. |
| ||
| The password to encrypt the workbook. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulate--object XlsxPopulate : object
object
Kind: global namespace
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulatepromise--promise XlsxPopulate.Promise : Promise
Promise
The Promise library.
XlsxPopulate
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulatemime_type--string XlsxPopulate.MIME_TYPE : string
string
The XLSX mime type.
XlsxPopulate
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulateformulaerror--formulaerror XlsxPopulate.FormulaError : FormulaError
FormulaError
Formula error class.
XlsxPopulate
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulatedatetonumberdate--number XlsxPopulate.dateToNumber(date) ⇒ number
number
Convert a date to a number for Excel.
Kind: static method of
XlsxPopulate
number
- The number.
date | | The date. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulatefromblankasync--promiseworkbook XlsxPopulate.fromBlankAsync() ⇒ Promise.<Workbook>
Promise.<Workbook>
Create a new blank workbook.
XlsxPopulate
Promise.<Workbook>
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulatefromdataasyncdata-opts--promiseworkbook XlsxPopulate.fromDataAsync(data, [opts]) ⇒ Promise.<Workbook>
Promise.<Workbook>
Loads a workbook from a data object. (Supports any supported
JSZip data typesXlsxPopulate
Promise.<Workbook>
data | | The data to load. |
| ||
| The password to decrypt the workbook. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulatefromfileasyncpath-opts--promiseworkbook XlsxPopulate.fromFileAsync(path, [opts]) ⇒ Promise.<Workbook>
Promise.<Workbook>
Loads a workbook from file.
XlsxPopulate
Promise.<Workbook>
| The path to the workbook. | |
| ||
|
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#xlsxpopulatenumbertodatenumber--date XlsxPopulate.numberToDate(number) ⇒ Date
Date
Convert an Excel number to a date.
XlsxPopulate
Date
- The date.
number | | The number. |
https://juejin.im/entry/5b34268fe51d4558bc58ebe5#_
Kind: global constant
原文发布时间为:2018年06月29日
原文作者:掘金
本文来源:
https://juejin.im/entry/5b34268fe51d4558bc58ebe5 掘金 https://juejin.im/entry/5b3a29f95188256228041f46如需转载请联系原作者