Menu

setCellValue

This command requires extra license.

A child command for modifyWorkbook that sets a new value for a cell on the workbook. This will overwrite any existing value in the cell.

Parent commands

  • modifyWorkbook
    Required. This parent defines the workbook that is modified.

Attributes

cell

Required
Value type
EL-evaluated
Yes String Yes
Defines the cell that receives the new value. The resolved String is expected to specify the column and row, like "D44" for the cell in column D, row 44.
sheet

Required
Value type
EL-evaluated
Yes String Yes
Defines the sheet where the target cell is in. The resolved String is expected to be a name of a sheet in the workbook.
value

Required
Value type
EL-evaluated
Yes Any Yes
Defines the new value of the cell. If the resolved value is a Number or a Boolean, the cell's type is set to numeric or boolean, as appropriate. If the value is an empty String, the cell's value is set to null. If it's a value of any other type, that value is converted into a String and the cell type set to text.

Examples

Add one setCellValue command for every cell whose value you wish to modify.

<modifyWorkbook var="modifiedWorkbook" workbook="${workbook}">
  <setCellValue cell="B4" sheet="Sheet1" value="${differentValue}">
  <setCellValue cell="C4" sheet="Sheet1" value="${differentMultiplier}">

If you're setting fixed values into cells, be particularly careful when setting numbers. A number that is not wrapped with the EL-expression notation is actually a String, and String values do not function as the numbers they may look like when they are components of formula cells' calculations. So, if you'd like to set a cell's value as the number 22 for example, set the value attribute into ${22}, not 22.  

Comments

0 comments