Hola LuisAlf.
Mirando el enlace pareciera que se trata de determinar el tipo de dato almacenado en cada celda (comprendida en un rango) del
TStringGrid para pasarlo al tipo correspondiente a la planilla de Excel.
No utilizo Excel por lo que no tengo forma de probarlo, pero yo haría las comprobaciones de este modo:
Código Delphi
[-]
var
DTimeAux: TDateTime;
IntAux: Integer;
FloatAux: Extended;
...
begin
...
if TryStrToDateTime(StringGrid1.Cells[i, linea-1], DTimeAux) then
ws.Cells.Item[ExLin, ExCol]:= DTimeAux
else if TryStrToInt(StringGrid1.Cells[i, linea-1], IntAux) then
ws.Cells.Item[ExLin, ExCol] := IntAux
else if TryStrToFloat(StringGrid1.Cells[i, linea-1],FloatAux) then
ws.Cells.Item[ExLin, ExCol]:= FloatAux
else
ws.Cells.Item[ExLin, ExCol]:= Cells[i,ARow];
...
Me parece un modo más natural que el tratamiento mediante
try/
except.
Una forma mas reducida (no sé si funcione, tendrías que probar) , sería:
Código Delphi
[-]
...
if not TryStrToDateTime(StringGrid1.Cells[i, linea-1], ws.Cells.Item[ExLin, ExCol]) then
else if not TryStrToInt(StringGrid1.Cells[i, linea-1], ws.Cells.Item[ExLin, ExCol]) then
else if not TryStrToFloat(StringGrid1.Cells[i, linea-1], ws.Cells.Item[ExLin, ExCol]) then
else
ws.Cells.Item[ExLin, ExCol]:= Cells[i,ARow];
...
Saludos.