Methods
(
source code)
Permits to create an empty Excel file
Parameters:
String|Array
sheetnames Optional, Default: "Sheet1"
You can provide the names of the sheets in an array
Example:
var myExcel = new ExcelPlus();
myExcel.createFile(["Sheet 1", "Sheet 2"]);
(
source code)
createSheet(sheet, select)
This function permits to create a new empty sheet
Parameters:
String
sheet
The name of the sheet to create
Boolean
select Optional, Default: true
If you want to automatically select this sheet
(
source code)
This function permits to delete a sheet
Parameters:
String
sheet
The name of the sheet to delete (by default the selected one)
(
source code)
This function returns an array of the sheet names (the key is the sheet #)
Returns:
Array
The different sheets related to the Excel file
(
source code)
This function will read the data provided, to give more flexibility than openLocal() and openRemote()
Parameters:
Any
fileData
The data that you want to parse
Example:
var ep=ExcelPlus();
var header = dataURI.substr(0, dataURI.indexOf(","));
var data = dataURI.substr(dataURI.indexOf(","));
var type = header.match(/;base64/) ? "base64" : "binary";
ep.open(data, {type:type});
ep.read("A1"); // -> show the content of cell A1
(
source code)
The HTML code for the input[file] will be <object id="file-object"></object>
Parameters:
String
params.idButton Optional, Default: "file-object"
This is the ID of the <object> tag in your code
String
params.flashPath Optional, Default: "./"
You must provide the absolute or relative path to the Flash files (swfobject.js, FileToDataURI.swf and expressInstall.swf)
String
params.labelButton Optional, Default: "Load a file"
This is the label for the button
Function
params.onReady
The function that will be called when the file has been loaded
(
source code)
This function read a remote Excel file
Parameters:
String
url
The url of the Excel file (make sure it follows the cross domain security)
Function
onReady
This function is called when the Excel file has been read, and 'passed' will return true (success) or false (failed)
(
source code)
This function permits to read a cell or a range
Parameters:
String
range
can be a range (e.g. "A1:D1"), or a single cell (e.g. "A1")
Boolean
options.parseDate Optional, Default: false
When TRUE, the Date cells will be returned as a JS Date object; if FALSE it will be returned as a text and as it's shown into the Excel file
Boolean
options.propertiesOnly Optional, Default: false
When it's true it will return an object with all properties has defined by sheetjs/XLSX-JS instead of return the cell value
Returns:
Date|String|Array|Object
if it's a range then it returns a 2D array (the first one is the rows, and the second one is the columns), if it's a cell then it returns the value of the cell, or the object if options.propertiesOnly is true
(
source code)
This function will read the all of the used range (we assume that the content starts at A1)
Parameters:
Boolean
options.parseDate Optional, Default: false
If a Date is found then it will try to parse the date to return a JS Date object
Boolean
options.properties Optional, Default: false
When it's true it will return an object with all properties has defined by sheetjs/XLSX-JS instead of return the cell value
Returns:
Array
it returns a 2D array; the first one is the rows, and the second one is the columns
(
source code)
This function permits to reset the current ExcelPlus object
(
source code)
saveAs(filename, options)
This function permits de save the current book to a real Excel file (only for Modern Browsers and IE10+)
Parameters:
String
filename
The name of the file, .e.g "book1.xlsx"
Boolean
options.compression Optional, Default: true
Permits to compress the file
(
source code)
It actually uses the `XLSX.write()` function
Parameters:
String
ext Optional, Default: "xlsx"
It's the extension type ('xlsx', 'xlsm' or 'xlsb')
String
type Optional, Default: "base64"
It can be "base64" or "binary"
Returns:
String|Binary
The encoded content of the Excel file
(
source code)
This function selects the specific sheet
Parameters:
String|Number
sheet
If it's a number (starting from 1) that reprents the sheet position in the Excel file, otherwise it must be the name of the sheet (case sensitive)
(
source code)
write(options, sheet, cell, content, style)
Write values into the workbook
Parameters:
String
sheet Optional
You can give the name of the sheet where to write, or the current selected sheet will be use, or the first sheet will be used
String
cell Optional
You can specify the cell reference (e.g. "A1")
String|Boolean|Number|Date|Array
content
If it's an arrya then we ignore the "cell" param (e.g. [ [ "Content Cell A1", "Content Cell B1" ] [ "Content Cell A2", "Content Cell B2" ] ], otherwise the "cell" needs to be provided
Object
style Optional
To add a style to a cell
(
source code)
writeCell(cell, content, style)
Write a value into a cell for the current selected sheet
Parameters:
String
cell
The cell reference (e.g. "A1")
String|Number|Date|Boolean
content
This is the value for the cell (could be `null`)
(
source code)
Write on the next available row for the current selected sheet
Parameters:
Array
content
This is the values for each cell of the row (could be `null`)
Example:
ep.writeRow(["Paris 1", "75001", "France"]);
(
source code)
Write a full row for the current selected sheet
Parameters:
String
row
The row reference (e.g. "1" for the first row in the sheet)
Array
content
This is the values for each cell of the row (could be `null`)
Example:
ep.writeRow(1, ["City", "Postal Code", "Country"]);
ep.writeRow(2, ["Montpellier", "34000", "France"]);