Skip to content
Ilya S. Eliseev edited this page Apr 23, 2014 · 5 revisions

methods

public function data($cellAddress, $data = null, $t = "s")

This function reads or sets data on specified cell. Parameters are:

  • $cellAddress – cell address in format notation A1 or R1C1;
  • $data – if set, this function sets this data to specified cell;
  • $t – stands for type of data to set: o s – strings o all other types are ignored. This function returns cell value right before this method was called. Some notes about data type conversion:
  • Strings are set and retrieved as is. Multilingual contents should be encoded as UTF-8 without BOM. Rich text is possible, according to spreadsheetML specification.
  • Numbers are set as is. It can be integer, double or string with period (“.”) as decimal separator.
  • Date/time values are to be set as strings formatted according to locale you need. Current version of eiseXLSX doesn’t support date formatting on write and values of this kind are stored as strings. Values of date/time type are retrieved as ‘Y-m-d H:i:s’ (e.g. 2014-03-01 22:15:45).

public function cloneRow($ySrc, $yDest)

This function clones row from position at $ySrc to the position specified in $yDest These position indexes are actual row numbers as you can see in Excel.

public function getRowCount()

This method returns row count of currently selected sheet of workbook.

public function findSheetByName($name)

This function loops through sheets to find the sheet with external name (specified on its tab) passed by parameter $name. If the sheet is found, it returns its sheetId (internal identifier). Otherwise, it returns null. Located sheetId can be passed as the parameter to method selectSheet() for further data manipulation.

public function selectSheet($id)

This method switches active sheet to the one with sheetId specified in $id parameter. If sheet with supplied sheetId cannot be found in this workbook, this function thrown an exception. If you need to obtain sheetId by sheet name, use findSheetByName($name) method. public function cloneSheet($originSheetId, $newSheetName = '') This method makes exact clone of sheet with sheetId of $originSheetId with new name specified in $newSheetName parameter. WARNING! This method prevents link between cell data and shared strings XML file. So any change in text fields in new sheet may reflect data in the origin!

public function renameSheet($sheetId, $newName)

This function changes the name of sheet with $sheetId to $newName. public function removeSheet($id) This function removes sheet with sheetId supplied by $id parameter.

public function fill($cellAddress, $fillColor)

This function sets cell background color as specified in $fillColor parameter. Parameters are:

  • $cellAddress – address of the cell to be painted in A1 or R1C1 format
  • $fillColor – color specified as string in W3C format: #RRGGBB (hex pairs for Red, Greeen and Blue channels). This function returns SimpleXMLElement object that corresponds to specified cell.

public function getFillColor($cellAddress)

This function retrieves current paint color of cell specified in $cellAddress parameter in W3C format #RRGGBB (hex pairs for Red, Green and Blue channels). WARNING: Alpha channel that might be used by Excel in some cases is not supported in current version of eiseXLSX.

public function Output($fileName = "", $dest = "D")

This method dumps in-memory XMLs to file or send it to user. It collects all data SimpleXML objects into zip archive and then sends this archive to user (if specified). It works similar to Ouput() method of FPDF class widely used by developer for output document creation. Parameters: $fileName – string with the file name. $dest – string that can have any of the following values:

  • “I” (to be discontinued as no longer supported way to work with Excel sheets) inline – workbook is sent to user with ‘Content-disposition: inline’ header. It is deprecated as it is no longer effective with all the modern browsers and platforms;
  • “D” – workbook is to be sent to user with ‘Content-disposition: attachment;filename=’ where is basename of $fileName parameter.
  • “F” – workbook will saved on the server as the file named as specified in $fileName parameter.

Error handling

In case of any error XLSX methods are throwing an eiseXLSX_Exception objects.