Cell Time Format

Hi,

 
I use Flexcel for many years, it's a powerfull component.
 
I use the property TExcelManager..Cell[ Row  , Col  ] to insert Time Variable (for exemple : 10:25) in my excel file.
 
That works perfectly. But now i would make fonction (Addition) in my excel fil with this Time Variable.
 
I have in my Excel file Template passed my cell who are Time Variable  format to "hh:mm".
 
But when my Excel file are correctly charged i look at my result of my fonction in a other cell is 00:00.
 
When a double click in the cells that contain the different Time Variable and press ENTER ( to valide her) it seems that the Time Format is applicate and the fonction works perfectly and so give me the result of the addition of my different Time Variable.
 
Can we make any think to not make the validation of each cell that have a Time Format???
 
Thanks for your helping
 
Nicolas.

Hi,

I am not sure on how you are entering the data. There is no TExcelManager class in FlexCel, but we do have a FlexCelImport.Cell[Row, Col]

If that is what you are using (and TExcelManager is a wrapper over FlexCelImport) then you need to set a number in the cell.
If you do 
FlexCelImport[row, col] := '10:30';
you will be entering the string "10:30", not the hour 10:30 into the cell. It will actually have a numeric value of 00:00 as you seem to have. Also, if you edit the cell in Excel and press enter, it will be converted by Excel to a real number, but that's just because Excel "guesses" that you are entering a number and not a string and does the conversion for you. In FlexCel, we don't do that kind of automatic conversions, since they can be very confusing when you are entering values with a program, not with an interactive application like Excel. In FlexCel, if you enter a string it will enter a string. (unless you use FlexCelImport.SetCellString)

But well, the way to enter this should be to enter the time as a number. The number is the fraction of the day the time represents. For example 12:00 is 0.5    0 is 0 and 24:00 is 1.
10:25 would be 10 * 1/24 + 25/60/24

Or you can use a normal DateTime in delphi, they use the same format as Excel and FlexCel.
Whatever you use, you will end up with a number. (0.434027778 for 10:25)
Once you enter this number in the cell, you need to format the cell as hh:mm and it will show as 10:25

Hope it helps, let me know if something isn't clear.






I have Sold this problem.

I have juste make a copy with the fonction : =CNUM(Feuil1!K20)
 
And with the result i make the addition.
 
It works perfectly thanks for your response.
 
Nicolas