EXCEL_WRITE

Command Name
and Syntax

Example

Description/Remarks

EXCEL_WRITE
value_type
,
value_format
,
cell_alignment
,
row_number
,
column_number
,
"cell_value"

EXCEL_WRITE 2, 64, 122,
4, 1, "Lower Spec"

 

This formula writes the header "Lower Spec" into the cell in row 4, column 1, with font set to Arial 10pt bold, with text centered and with borders on all four sides of the cell.

 

 

EXCEL_WRITE 1, 0, 0,
4, 2, STAT_STR 42

 

This formula writes the value of the lower specification (a number formatted as a string) into the cell in row 4, column 2, formatted in Arial 10pt and general alignment.

 

See also: Creating a file in Microsoft Excel format.

This command writes a numeric, text, or date/time value to the specified cell in the new file created by the EXCEL_CREATE command.  

Note:  If you need to add an Excel formula to the spreadsheet, use the EXCELCOM_WRITE command instead of the EXCEL_WRITE command..

The following parameters are required when writing to a cell:

Value_type

This parameter tells Excel whether to format the cell for numbers, text, or date/time values.  Valid settings are:

0 : Integer

1 : Number

2 : Text

3 : Date/Time
Note:
 To correctly display a date or time value on the spreadsheet, the value_format must include one of the date or time formats (numbers 12-21).  
See below for instructions on setting the value_format.

Value_format

This parameter sets fonts and Excel formatting options for the contents of the cell.  Examples of these settings are available here.

Valid font settings are:

0 : Arial 10pt font

64 : Arial 10pt Bold font

128 : Arial 10pt Bold and Underline font

192 : Courier 12pt Italic font

Valid format settings are:

0 : 'General' format

1 : '0' format

2 : '0.00' format

3 : '#,##0' format

4 : '#,##0.00' format

5 : '#,##0\ "$";\-#,##0\ "$"' format

6 : '#,##0\ "$";[Red]\-#,##0\ "$"' format

7 : '#,##0.00\ "$";\-#,##0.00\ "$"' format

8 : '#,##0.00\ "$";[Red]\-#,##0.00\ "$"' format

9 : '0%' format

10 : '0.00%' format

11 : '0.00E+00' format

12 : 'dd/mm/yy' format

13 : 'dd/\ mmm\ yy' format

14 : 'dd/\ mmm' format

15 : 'mmm\ yy' format

16 : 'h:mm\ AM/PM' format

17 : 'h:mm:ss\ AM/PM' format

18 : 'hh:mm' format

19 : 'hh:mm:ss' format

20 : 'dd/mm/yy\ hh:mm' format

21 : 'yyyy/mm/dd\ hh:mm:ss' format

To apply both a font and a format to one cell, sum the values of those settings.  For example, to apply bold font and date formatting, you would sum their individual values (64+12=76) and specify a value_format of 76.

Cell_alignment

This parameter sets the alignment, borders and shading for the cell.  The values of individual settings are:

0 : No special formatting
(General Alignment, no borders, no shading)

1 : Align Left

2 : Center

3 : Align Right

4 : Fill Cell
(Repeats the contents of the cell until the cell is full.  If blank cells to the right also have the Fill alignment, they are filled as well.  Especially useful when filling cells with periods, dashes, etc.)

8 : Left Border

16 : Right Border

32 : Top Border

64 : Bottom Border

128 : Shaded

To apply multiple settings to one cell, sum the values of those settings.  For example, to center the text and add all four borders, you would sum their individual values (2+8+16+32+64=122) and specify a cell_alignment of 122.

Row_number

Specify the row number of the cell to be written.  Rows are counted 1, 2, 3, etc., just as they are labeled in Microsoft Excel.

Column_number

Specify the column number of the cell to be written.  Columns are counted 1, 2, 3, etc., and correspond to Microsoft Excel columns A, B, C, etc.  

Cell_value

The text or number to be displayed in the cell.  

Note: This value must be formatted as a string, even if the value_type is set to 0 (integer) or 1 (numeric).  

Tip: You can use the CSTR command to format a number as a string.