FlexCel Studio for VCL/LCL
ContentsIndex
PreviousUpNext
TFlexCelImport.SetCellString Method (integer, integer, UTF16String)

Converts a string to the best Excel datatype, and the enters it into a cell.

Pascal
procedure SetCellString(Row: integer; Col: integer; const Text: UTF16String); overload;
C++
__fastcall SetCellString(int Row, int Col, const UTF16String Text);
Parameters 
Description 
Row: integer 
Row for the cell. (1 based) 
Col: integer 
Column for the cell (1 based) 
const Text: UTF16String 
String with the value you want to enter. 

When using CellValue to set a cell value, you have to know the datatype you want to enter. That is, if you have a string s:="1/1/2002" and call CellValue[1,1]:=s; The cell A1 will end up with a string "1/1/2002" and not with a date. The same if you have a string holding a number. 

 

SetCellString tries to solve this problem. When you call SetCellString(1,1,s) FlexCel will evaluate: 

  1. If s contains a valid number: If it does, it will enter the number into the cell, and not the string s.
 

  1. If s contains a boolean: If s equals the words "TRUE" or "FALSE" (or whatever you define on the constants TxtTrue and TxtFalse) it will enter the boolean into the cell
 

  1. If s contains a date: If s is a valid date (according to your windows settings) it will enter a number into the cell and format the cell as a date. (see Using FlexCelImport )
 

  1. In any other case, it will enter the string s into the cell.
 

There is an overloaded version of this method, that lets you specify the original format you want for the cell.

Copyright (c) 2002-2008 TMS Software. All rights reserved.
What do you think about this topic? Send feedback!