Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 7.3   7.4   7.5   8.0   8.1   8.2   8.3   8.4   8.5   8.6    Statistic  

XL.Sheet.CellWriteNumber

Writes a number into cell.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
XL 3.5 Yes Yes Yes Yes Yes
MBS( "XL.Sheet.CellWriteNumber"; bookRef; sheetIndex; Row; Column; Value { ; Format } )   More

Parameters

Parameter Description Example value
bookRef The reference to the workbook. Please use XL.LoadBook to load a file. $ref
sheetIndex The index of the sheet. This number ranges from 0 to XL.Book.SheetCount-1. 0
Row The row for the cell. First row has index 0. $row
Column The column for the cell. First column has index 0. $column
Value The new value to write. 123
Format Optional
The format for the cell. This is index from 0 to XL.GetFormatCount-1 in the book's list of formats.
0

Result

Returns OK or error message.

Description

Writes a number into cell.

Examples

Create Excel file with some date value:

#create new xls file
Set Variable [$book; Value:MBS( "XL.NewBook"; 0 )]
#create date format
Set Variable [$dateFormat; Value:MBS( "XL.Book.AddFormat"; $book)]
Set Variable [$dateFormatID; Value:MBS( "XL.Book.AddCustomNumFormat"; $book; "mmmm\ d\,\ yyyy")]
Set Variable [$r; Value:MBS( "XL.Format.SetNumFormat"; $book; $dateFormat; $dateFormatID)]
#create sheet
Set Variable [$sheet; Value:MBS( "XL.Book.AddSheet"; $book; "Sales Receipt")]
#Write date
Set Variable [$d; Value:MBS( "XL.Date.Pack"; $book; 2013; 10; 21)]
Set Variable [$r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 4; 4; $d; $dateFormat)]
#
Set Field [Writing data::Output; MBS("XL.Book.Save"; $book; "test.xls")]
Set Variable [$r; Value:MBS("XL.Book.Release"; $book)]

Writes sheet with red font:

#create new xls file
Set Variable [$book; Value:MBS( "XL.NewBook"; 0 )]
#create fonts
Set Variable [$redColor; Value:MBS( "XL.Color.Pack"; $book; 255; 0; 0)]
Set Variable [$redFont; Value:MBS( "XL.Book.AddFont"; $book)]
Set Variable [$r; Value:MBS( "XL.Font.SetColor"; $book; $redFont; $redColor)]
#
#create formats
Set Variable [$redFormat; Value:MBS( "XL.Book.AddFormat"; $book)]
Set Variable [$r; Value:MBS( "XL.Format.SetFont"; $book; $redFormat; $redFont)]
#
#create sheet
Set Variable [$sheet; Value:MBS( "XL.Book.AddSheet"; $book; "Sales Receipt")]
#
#add number in red
Set Variable [$r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 5; 3; 123; $redFormat)]
#
Set Field [Writing data::Output; MBS("XL.Book.Save"; $book; "test.xls")]
Set Variable [$r; Value:MBS("XL.Book.Release"; $book)]

Use a number format:

# create new format
Set Variable [$format; Value:MBS( "XL.Book.AddFormat"; $book)]
# use existing number format
Set Variable [$r; Value:MBS( "XL.Format.SetNumFormat"; $book; $format; 7)]
# and use format
Set Variable [$r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 5; 3; 123; $format)]

Write to a time formatted cell a time value:

MBS("XL.Sheet.CellWriteNumber"; $BookRef; $sheet; $row; $col; GetAsNumber(ExcelTest::TimeField)/(24*60*60))

See also

Example Databases

Created 18th August 2014, last changed 11st August 2017


XL.Sheet.CellWriteFormulas   -   XL.Sheet.CellWriteNumbers

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins