XL.Sheet.CellWriteText
----------------------

Writes a string into cell.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XL](component_XL.md) | [3.5](newinversion35.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XL.Sheet.CellWriteText"; BookRef; SheetIndex; Row; Column; Text { ; Format } ) 

**MBS**( **"XL.Sheet.CellWriteText";** /\* Writes a string into cell. \*/  
**$BookRef**; /\* The reference number for the workbook.e.g. $ref \*/   
**$SheetIndex**; /\* The index of the sheet. This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-1.e.g. 0 \*/   
**$Row**; /\* The row for the cell. First row has index 0. \*/   
**$Column**; /\* The column for the cell. First column has index 0. \*/   
**$Text**; /\* The new text to write.e.g. "hello" \*/   
**$Format**) /\* Optional; The format for the cell. This is index from 0 to XL.GetFormatCount-1 in the book's list of formats.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| BookRef | The reference number for the workbook. | $ref |  |
| SheetIndex | The index of the sheet. This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-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 |  |
| Text | The new text to write. | "hello" |  |
| Format | The format for the cell. This is index from 0 to XL.GetFormatCount-1 in the book's list of formats. | 0 | Optional |

### Result

Returns OK or error message.

### Description

Writes a string into cell.  
### Examples

Loads book, writes some cells and saves back to container field:

 #Load template excel file   
Set Variable \[$bookRef ; Value:MBS ( "[XL.LoadBook](XLLoadBook.md)"; XL::ExcelFile )\]  
Set Variable \[$sheet ; Value:0\]  
\#First row   
Set Variable \[$row ; Value:4\]  
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)"; $BookRef ; $sheet ; $row ; 0; 1 )\]  
Set Variable \[$r ; Value:MBS ( "XL.Sheet.CellWriteText"; $BookRef ; $sheet ; $row ; 1; "Cherries" )\]  
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)"; $BookRef ; $sheet ; $row ; 2; 5 )\]  
\#Second row   
Set Variable \[$row ; Value:5\]  
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)"; $BookRef ; $sheet ; $row ; 0; 2 )\]  
Set Variable \[$r ; Value:MBS ( "XL.Sheet.CellWriteText"; $BookRef ; $sheet ; $row ; 1; "Banana" )\]  
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)"; $BookRef ; $sheet ; $row ; 2; 3,5 )\]  
\#Third row   
Set Variable \[$row ; Value:6\]  
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)"; $BookRef ; $sheet ; $row ; 0; 3 )\]  
Set Variable \[$r ; Value:MBS ( "XL.Sheet.CellWriteText"; $BookRef ; $sheet ; $row ; 1; "Oranges" )\]  
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)"; $BookRef ; $sheet ; $row ; 2; 6,25 )\]  
\#Last row   
Set Variable \[$row ; Value:13\]  
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.CellWriteFormula](XLSheetCellWriteFormula.md)"; $BookRef ; $sheet ; $row ; 2; "SUM(C5:C13)" )\]  
\#Save to container and cleanup   
Set Field \[XL::OutputFile ; MBS ("XL.Save"; $bookRef ; "test.xls")\]  
Set Variable \[$r ; Value:MBS ( "[XL.Book.Release](XLBookRelease.md)"; $bookRef )\]  
Set Field \[XL::Result ; $r \]  
Write text with two lines in one cell:

 Set Variable \[$r ; Value:MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; 16; 1; "Bananas¶Apple"; $myFormat )\]  
Write two lines with adjusting the row height:

 # create format with wrap   
\#   
Set Variable \[ $textFormat ; Value: MBS ( "[XL.Book.AddFormat](XLBookAddFormat.md)"; $book ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetWrap](XLFormatSetWrap.md)"; $book ; $textFormat ; 1) \]   
\#   
\# put in text with Char(10) for new line   
\#   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 1; "First line" &amp; Char(10) &amp; "Second line"; $textFormat ) \]   
\#   
\# make line higher   
Set Variable \[ $r ; Value: MBS ( "[XL.Sheet.SetRow](XLSheetSetRow.md)"; $book ; $sheet ; $row ; 20 ) \]  
Create header row:

 #   
\# define a font:   
\#   
Set Variable \[ $headerFont ; Value: MBS ( "[XL.Book.AddFont](XLBookAddFont.md)"; $book ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Font.SetSize](XLFontSetSize.md)"; $book ; $headerFont ; 12) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Font.SetName](XLFontSetName.md)"; $book ; $headerFont ; "Century Gothic") \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Font.SetBold](XLFontSetBold.md)"; $book ; $headerFont ; 1) \]   
\#   
\# define a format:   
\#   
Set Variable \[ $headerFormat ; Value: MBS ( "[XL.Book.AddFormat](XLBookAddFormat.md)"; $book ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetFont](XLFormatSetFont.md)"; $book ; $headerFormat ; $headerFont ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetFillPattern](XLFormatSetFillPattern.md)"; $book ; $headerFormat ; 1) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetPatternForegroundColor](XLFormatSetPatternForegroundColor.md)"; $book ; $headerFormat ; MBS ( "[XL.Color.Pack](XLColorPack.md)"; $book ; 200; 200; 200) ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetAlignH](XLFormatSetAlignH.md)"; $book ; $headerFormat ; 2 /\* center \*/ ) \]   
\#   
Set Variable \[ $r ; Value: MBS ( "[XL.Sheet.SetRow](XLSheetSetRow.md)"; $book ; $sheet ; $row ; 20 ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 0; "Account" ; $headerFormat ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 1; "Account Group" ; $headerFormat ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 2; "Report Name" ; $headerFormat ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 3; "Date TS" ; $headerFormat ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 4; "Text" ; $headerFormat ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 5; "Text2" ; $headerFormat ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.CellWriteText"; $book ; $sheet ; $row ; 6; "Text3" ; $headerFormat ) \]  
### See also

- [XL.Sheet.CellWriteComments](XLSheetCellWriteComments.md)
- [XL.Sheet.CellWriteDates](XLSheetCellWriteDates.md)
- [XL.Sheet.CellWriteMatrix](XLSheetCellWriteMatrix.md)
- [XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)
- [XL.Sheet.CellWriteNumbers](XLSheetCellWriteNumbers.md)
- [XL.Sheet.CellWriteTexts](XLSheetCellWriteTexts.md)
- [XL.Sheet.SetCellFormats](XLSheetSetCellFormats.md)
- [XL.Sheet.SetCol](XLSheetSetCol.md)
- [XL.Sheet.SetProtect](XLSheetSetProtect.md)
- [XL.Table.SetColumnName](XLTableSetColumnName.md)

### Release notes

- **Version 15.0**
    - Added DoBlanksForEmptyText parameter to [XL.Sheet.CellWriteTexts](https://www.mbsplugins.eu/XLSheetCellWriteTexts.shtml) function.
- **Version 12.2**
    - Fixed issue with [XL.Sheet.CellWriteText](https://www.mbsplugins.eu/XLSheetCellWriteText.shtml) to allow you to pass empty value to not change format.
- **Version 10.3**
    - Added [XL.Sheet.CellWriteTextAsNumber](https://www.mbsplugins.eu/XLSheetCellWriteTextAsNumber.shtml), [XL.Sheet.GetFirstFilledCol](https://www.mbsplugins.eu/XLSheetGetFirstFilledCol.shtml), [XL.Sheet.GetFirstFilledRow](https://www.mbsplugins.eu/XLSheetGetFirstFilledRow.shtml), [XL.Sheet.GetLastFilledCol](https://www.mbsplugins.eu/XLSheetGetLastFilledCol.shtml) and [XL.Sheet.GetLastFilledRow](https://www.mbsplugins.eu/XLSheetGetLastFilledRow.shtml) functions.
- **Version 9.1**
    - Fixed a problem with [XL.Sheet.CellWriteTexts](http://www.mbsplugins.eu/XLSheetCellWriteTexts.shtml) function and empty entries in value list.
- **Version 8.0**
    - Added [XL.Sheet.CellReadBooleans](http://www.mbsplugins.eu/XLSheetCellReadBooleans.shtml), [XL.Sheet.CellReadComments](http://www.mbsplugins.eu/XLSheetCellReadComments.shtml), [XL.Sheet.CellReadDates](http://www.mbsplugins.eu/XLSheetCellReadDates.shtml), [XL.Sheet.CellReadFormulas](http://www.mbsplugins.eu/XLSheetCellReadFormulas.shtml), [XL.Sheet.CellReadNumbers](http://www.mbsplugins.eu/XLSheetCellReadNumbers.shtml), [XL.Sheet.CellReadTexts](http://www.mbsplugins.eu/XLSheetCellReadTexts.shtml), [XL.Sheet.CellWriteBlanks](http://www.mbsplugins.eu/XLSheetCellWriteBlanks.shtml), [XL.Sheet.CellWriteBooleans](http://www.mbsplugins.eu/XLSheetCellWriteBooleans.shtml), [XL.Sheet.CellWriteComments](http://www.mbsplugins.eu/XLSheetCellWriteComments.shtml), [XL.Sheet.CellWriteDates](http://www.mbsplugins.eu/XLSheetCellWriteDates.shtml), [XL.Sheet.CellWriteFormulas](http://www.mbsplugins.eu/XLSheetCellWriteFormulas.shtml), [XL.Sheet.CellWriteNumbers](http://www.mbsplugins.eu/XLSheetCellWriteNumbers.shtml), [XL.Sheet.CellWriteTexts](http://www.mbsplugins.eu/XLSheetCellWriteTexts.shtml), [XL.Sheet.GetCellErrors](http://www.mbsplugins.eu/XLSheetGetCellErrors.shtml), [XL.Sheet.GetCellFormats](http://www.mbsplugins.eu/XLSheetGetCellFormats.shtml), [XL.Sheet.RemoveComments](http://www.mbsplugins.eu/XLSheetRemoveComments.shtml) and [XL.Sheet.SetCellFormats](http://www.mbsplugins.eu/XLSheetSetCellFormats.shtml).

### Example Databases

- [XL/AutoFilter](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/AutoFilter.shtml#1ScriptAnchor_)
- [XL/Change Column Names](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Change%20Column%20Names.shtml#4ScriptAnchor_)
- [XL/Conditional Formatting](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Conditional%20Formatting.shtml#1ScriptAnchor_)
- [XL/Edit Sheet](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Edit%20Sheet.shtml#1ScriptAnchor_)
- [XL/Export records](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Export%20records.shtml#2ScriptAnchor_)
- [XL/Writing data](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Writing%20data.shtml#5ScriptAnchor_)
- [XL/XL Import and Export](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/XL%20Import%20and%20Export.shtml#4ScriptAnchor_)

### Blog Entries

- [MBS Plugin Advent calendar: 13 - XL](https://www.mbsplugins.de/archive/2023-12-13/MBS_Plugin_Advent_calendar_13_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.2pr3](https://www.mbsplugins.de/archive/2022-04-21/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New column names in an Excel document](https://www.mbsplugins.de/archive/2019-05-14/New_column_names_in_an_Excel_d/monkeybreadsoftware_blog_filemaker)
- [How to use XL functions with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2015-02-09/How_to_use_XL_functions_with_M/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2022, Seite 22 bis 23](https://filemaker-magazin.de/neuigkeit/4196-Appetithappen-FMM_202205)

This function checks for a license.

Created 18th August 2014 , last changed 7th February 2020

  
[XL.Sheet.CellWriteStyledText](XLSheetCellWriteStyledText.md) - [XL.Sheet.CellWriteTextAsNumber](XLSheetCellWriteTextAsNumber.md)

[HTML Version](XLSheetCellWriteText.shtml)