GetCellValueIndexed

What does the option "xF" in GetCellValueIndexed function?


XF stand for "eXtended Format" and it is a number which identifies the format of the cell.
You can then get the real format definition with xls.GetFormat(XF);

It is just a shortcut for reading both the cell format and value at the same time, so you don't need to do 2 calls (GetCellFormat and GetCellValue) 

where to get the parameter value xf?

cf is a return parameter, just set it at -1 before calling GetCellValueIndexed.

for example:
var
  XF: integer;
begin
  XF := -1;
  CellValue := xls.GetCellValueIndexed(row, cIndex, XF)
  // now XF will have the format index of the cell. If you need the format,
  // you can call xls.GetFomat(XF) to get the format definition. If you don't
  // care about the format, just ignore this value.


When you apply the function cell.ValueType. 7 shows the results:
-Empty When ef = 0
- Number when ef = 1
etc
But! When trying to use one file Excel, then in one of the field shows that the XF = 11 and even 16. 
It's like?
The values of the no 11 or 16! Explain.

XF has nothing to do with the value type: It is the format of the cell. (bold font, green background, etc).
Take a look at the section "Cell Formats" in page 2 of http://www.tmssoftware.biz/flexcel/docs/vcl/UsingFlexCelAPI.pdf to see a diragram of how XF formats work.

Say for example you want to know the font name of cell A1. You could use this code:


var
  XF: integer;
  Fmt: TFlxFormat;
  Cell: TCellValue;
begin
  Cell := xls.GetCellValue(1, 1, XF);
  Fmt := Xls.GetFormat(XF);
  ShowMessage(Fmt.Font.Name);




In the code above, you get the format in XF, and the cell value in Cell. Cell.ValueType might be anything: a number, empty, whatever. But it has nothing to do with the format of the cell (XF). If you get 11 and 16 it means that the formats for the cells are different, one has format number 11 and the other 16. The XF value itself has no meaning, you need to call xls.GetFormat(XF) to retrieve the value the XF references.

I am not sure on what you are trying to achieve, but here below there is a little example on how you can read both the format and the value of cell A1. Remember again that cell format and cell value are independent: one cell can have any format, and any value.

http://www.tmssoftware.biz/flexcel/samples/xf.zip
And please remember to look at the "Reading Files" demo to see how to use the TCellValue and XF variables.


Thank you very much, it became a bit clearer!
I have a simple task. The users need to import data from Excel file into the program. Fields determined. That is, 1, 2, 3 is text. 4 field - this number. Field 5 - is the price. A 6 field - is the date (time). Before importing, check the field on the accuracy of the content of the data. How to do it? How to learn to imports, 4 field - this number? With 5 - the price and so on.

As said you can read into the "Reading Files"demo: It shows how to get the numbers, text and dates from an Excel file. But if you prefer,I made a simple demo here which will read an Excel file as you mention and print the values:
http://www.tmssoftware.biz/flexcel/samples/xf2.zip

It will read strings for the 3 first fields, then it will expect a number in fields 4 and 5, and a date in field 6. You can of course add extra validation for stuff you know is impossible (for example dates before year 2000 or so).

Adrian, thank you very much! Part I invented myself, some of you to help! You is the best!