Hola Ecfisa!
Antes que nada gracias por tu ayuda.
Sabes que estuve probando tu recomendación y me parece mucho mejor que todos esos try anidados...
El problema es que no pude solucionar nada! haaha
Código Delphi
[-]
procedure Tform2.ExportaExcel(pStringGrid : TstringGrid; c0,r0,c1,r1 : Integer);
var ExLin, ExCol, i, Linea, AuxInteger : Integer;
AuxFloat : Extended;
AuxFecha : tDatetime;
c : TCursor;
Excel, ExcelDoc, WS : Variant;
begin
c := Screen.Cursor;
Screen.Cursor := crHourGlass;
with pStringGrid do begin
try
coinitialize(nil);
Excel := CreateOleObject('Excel.Application');
ExcelDoc := Excel.Workbooks.Add;
WS := ExcelDoc.ActiveSheet;
Excel.Visible := true;
ExCol := 0;
for i := c0 to c1 do begin
inc(ExCol);
ws.Cells.Item[1, ExCol]:= cells[i, 0];
end;
for linea := r0 to r1 do begin
inc(ExLin);
ExCol := 0;
for i := c0 to c1 do begin
inc(ExCol);
if TryStrToInt(StringGrid1.Cells[i, linea-1], AuxInteger) then
ws.Cells.Item[ExLin, ExCol] := AuxInteger
else if TryStrToFloat(StringGrid1.Cells[i, linea-1],AuxFloat) then
ws.Cells.Item[ExLin, ExCol]:= AuxFloat
else
ws.Cells.Item[ExLin, ExCol]:= StringGrid1.Cells[i,linea-1];
end;
end;
ws.cells.entirecolumn.autofit;
finally
screen.Cursor := c;
end;
end;end;
Ya no salta error pero no me exporta correctamente... decidí darme a la busqueda de otras soluciones y encontre una, por medio de la ayuda de OLE... Como lo explica muy claramente roman en este hilo:
http://www.clubdelphi.com/foros/showthread.php?t=22649
Bueno muchas gracias de cualquier forma!