PreviousNext
Help > Programming with LAUNCHER Office > LNCCMD commands > Commands list > XLCELLS Command
XLCELLS Command

Allows you to perform actions on a cell or group of cells.

- Read the value

- Change the value

- Change the formula of the cell

- Change the format

- Assign a name

- Edit properties

- Read a property 

 

Syntax

 

CHGVAR

VAR(&CMD) VALUE('XLCELLS')

CHGVAR

VAR(&PARM1) VALUE('
[Ref="Cells reference"]
[;Sheet="Sheet name"]
[;Row= Row number or displacement]
[;Col= Column number or displacement]
[;RowCnt= Number of selected rows]
[;ColCnt= Number of selected columns]
[;RefTo= "
End of selected area reference " ]
[;NextOutLine="Levels"]
[;SetValue=True/False ]
[;SetFormula=True/False ]
[;Format="
Format to be assigned "]
[;Name="
Name to be assigned "]
[;Comment="Comment"]
[;GetValue=True/False]
[;GetText=True/False]
[;GetProp("Property")]
[;GetSize=True/False]
[;Select=True/False]
[;Clear=True/False]
[;Freeze=True/False]
[;Calculate=True/False]
[;Merge=xlColumn|xlNone|xlAll]
[;Prop(Property)= Property value]
[;DateFmt(Date format)]
[;NumFmt(Numbers format)]

[;IgnoreError=True/False]
[;Unicode=True/False]
')

CHGVAR

VAR(&PARM2) VALUE('Value assigned to cells')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

Parameters

Parameters

 

Parm1


Ref: The reference to the cell can be given in the form:

- Syntax $B$3. Example: $B$3 denotes column B, row 3.

- Syntax CL. C to designate the column and L to designate the row. Example: B3 designates row 3, and column 2 (B).

- Symbolic name given to a cell or group of cells.

- "." will designate the active cell.

Sheet: Specifies the name of the sheet to be addressed.
If a cell name is indicated by Ref, then the Sheet keyword is not useful.
Otherwise, if the Sheet keyword is missing, the active sheet is addressed.

Row, Col: These two keywords represent respectively:

- The coordinates (Line, Column) of a cell, if Ref is absent.

- The relative coordinates in rows and columns from the base referenced by "Ref =" when it is present. The upper left cell has relative coordinates (1,1).

RowCnt, ColCnt: These two keywords represent respectively the number of rows and columns selected, from the reference given by Ref or by (Row, Col).
These keywords can not be used if RefTo is specified.

RefTo: Reference to the cell at the bottom right of the selected area. This reference is given by key words Ref, Row and Col, in a quoted string.
This keyword can not be specified if RowCnt or ColCnt are specified.

NextOutline: When this option is specified, LAUNCHER Office searches for the next row from the active cell, with a hierarchy level matching the criteria.
Rows have different hierarchy levels when subtotals have been applied to the sheet.
In the NextOutline="x-y" syntax, x represents the minimum hierarchy level, y the maximum level.
Example: The following syntax looks for the following subtotal row and applies background color and character formats:

NEXTOUTLINE="1-2";SELECT;IgnoreError; PROP(INTERIOR.COLOR)=RGB(200;200;200); PROP(Font.Bold)= True

SetValue : Indicates that the Parm2 parameter contains a value to assign to the cell.

SetFormula : Indicates that the Parm2 parameter contains the text of a formula to apply to the cell.

Format: Allows you to set the format of the cell or group of cells.

Name: Give a name to the cell or group of cells.

Comment: Add a comment to the cell. This comment is displayed by Excel when we fly over the cell with the mouse.

 

GetValue: Indicates that you want to receive the internal value of the cell, not the displayed value. The value will be returned in the &RESULT parameter.

GetText: Indicates that you want to receive the displayed value of the cell. The displayed value may differ from the internal value.
For example, if the cell has a "Percentage" format, the internal value "0.10" will be displayed "10.00%".
The value will be returned in the & RESULT parameter.

GetProp ("Property"): Returns the value of a property assigned to cells in the referenced region.
Examples:
Prop ("Address") returns the coordinates of the referenced region.
Prop ("Font.color") returns the color of the characters.

GetSize: Returns in &RESULT the size of the region referenced by Ref.
The size is returned in &RESULT under the form:
lllll; ccccc
lllll represents the number of lines on 5 digits,
cccc is the number of columns in 5 digits.

Select: True indicates that the cell or group of cells should be selected.

Clear: True clears the cell.

Freeze: True replaces the expressions with their calculated values.

Calculate: True recalculates the entire workbook.

Merge: When this keyword is specified, the merge of the cells in the selection is changed.
Merge can take one of the following symbolic values, expressed without quotation marks:

xlAll: All cells in the selection are merged into a single cell.
xlColumn: The cells in each row of the selection are merged to form a merged cell per line.
xlNone: The merge is deleted.
Be careful, if merged cells contain values, Excel displays a message asking for confirmation of the loss of these values.
Use the XLSETPROP command, with "DisplayAlerts = false" to disable the display of this message.

Prop(): allows to modify a property of the pointed cells.
The keyword "Prop" can appear several times in Parm1.
Example: Change the background color, and the alignment
Prop(Interior.color)=RGB(100,0,0);Prop(HorizontalAlignment)=xlCenter.

IgnoreError: If this option is true, in the event of an error, no message will be generated, and the value "*ERROR" will be returned in &RESULT.

 

DateFmt(format) : When a date value is provided in the "Parm2" parameter, this keyword indicates in what format this value is.
The dd, mm, yy and yyyy strings will be used to denote, respectively, the day, the month, the year on 2 digits and the year on 4 digits.
By default, Excel considers dates in the format 'mm/dd yyyy'

Examples:
DateFmt (dd/mm/yyyy) indicates that the date is provided in Day-Month-Year format, separated by '/'.
DateFmt (yyyymmdd), the date is in the format Year-Month-Day, without separator.

NumFmt (format) : When a decimal number, without a decimal point, is provided in the "Parm2" parameter, this key word indicates how many decimal places have this number.
Example:
Parm2 = '123456';
NumFmt(2) indicates that the value sent is: 1234.56.

Unicode: When Unicode is true, the value read by GetValue, GetText, or written by SetValue is in the Unicode character set of Windows.
To write a value in Unicode, &PARM2 must contain a Unicode string, which can be converted by the program LNCCVTWCS.
When reading a value, the &RESULT parameter will contain a value in Unicode, which can be converted with LNCCVTWCS.

 

Parm2

If one of the keywords SetValue or SetFormula is set into Parm1, then Parm2 contains the value for the cell or the formula.

If Unicode is true, &PARM2 value must be in Unicode character set,
and parameter &OPT must set to 'W'.

 

Opt

When option Unicode is true, &OPT must be set to 'W'.

&PARM2 must be coded in the Windows Unicode character set.

 

 

Examples

  

 

/* Read the value of cell B2 */
/* and assign it a new value */

CHGVAR

VAR(&CMD) VALUE('XLCELLS')

CHGVAR

VAR(&PARM1) VALUE('Ref="$B$2";SetValue=True;GetText=True')

CHGVAR

VAR(&PARM2) VALUE(&NEWVAL)

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

/* &RESULT contient l’ancienne valeur de B2 */

 

 

/* Change the format of the cell Row 10, Column 5*/

CHGVAR

VAR(&CMD) VALUE('XLCELLS')

CHGVAR

VAR(&PARM1) VALUE('Row=10;Col=5;Format="# ##0,00"')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

 

 

 

/* Write a Chinese text in a cell */

 

/* Convert from chinese CCSID to unicode Windows */

CHGVAR

VAR(&WCS_LEN) VALUE(512)

CHGVAR

VAR(&CCSID) VALUE(835)

CALL

PGM(LNCCVTWCS) PARM(&HANDLE '*TO ' &PARM2 &WCS_LEN +

&CHINA &CHINA_LEN &CCSID &RES_SIZE)

 

 

CHGVAR

VAR(&CMD) VALUE('XLCELLS')

CHGVAR

VAR(&PARM1) VALUE('Ref="$B$2";SetValue=True;Unicode=True')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD 'W' &PARM1 +

&PARM2 &RESULT)

 

 

 

 

/* Select an area of 3 rows, 5 columns */
/* From the cell named "Table". */

CHGVAR

VAR(&CMD) VALUE('XLCELLS')

CHGVAR

VAR(&PARM1) VALUE('Ref="Table";RowCnt=3;ColCnt=5;Select')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

 

 

 

/* Select a zone */
/* from the cell named "Table" */
/* to the cell named "FinTable". */

CHGVAR

VAR(&CMD) VALUE('XLCELLS')

CHGVAR

VAR(&PARM1) VALUE('Ref="Table";RefTo="FinTable";Select')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

 

 

 

/* Select a zone */
/* from the cell named "Table" */
/* to the cell Line 12, column 20. */

CHGVAR

VAR(&CMD) VALUE('XLCELLS')

CHGVAR

VAR(&PARM1) VALUE('Ref="Table";+
RefTo="Row=12;Col=20";Select')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

              /* Apply formula */

LNCCMD CMD(XLCELLS)

PARM1('Ref="H8";setformula=True;calculate=True')

PARM2('=IF(ISERROR(-1+D5/E5)," ",-1+D5/E5)')

 

Note

To use the Font.Color property, it is necessary to use Windows color codes.

Color constants:

 

Constants values:

 

 

PROP(Font.Color)=vbMagenta

PROP(Font.Color)=INT(255) //red

 

You can also use BGR code with the RGB function:

 

PROP(Font.Color)=RGB(255,0,0) //blue

PROP(Font.Color)=RGB(0,255,0) // green

PROP(Font.Color)=RGB(0,0,255) // red