Ver Mensaje Individual
  #7  
Antiguo 12-07-2006
zvf zvf is offline
Miembro
 
Registrado: abr 2006
Posts: 158
Reputación: 19
zvf Va por buen camino
Gracias a su ayuda, ya tengo claro como exportar los datos a una hoja de exel. Pero me queda una duda:
¿Como puedo decirle en que hoja lo ponga?, es decir si quiero que algunos datos los ponga en la hoja1 y otros en la hoja2 y asi sucesivamente.
Hasta ahorita tengo el siguiente codigo, que solamente me inserta todos los datos del stringGrid en la hoja1.


Código Delphi [-]
procedure TForm1.ExportaExcel(const StringGrid1 : TstringGrid; const c0,r0,c1,r1 : Integer);
var i, Linea : Integer;
    c : TCursor;
    Excel, ExcelDoc, WS : Variant;
begin
  c             := Screen.Cursor;
  Screen.Cursor := crHourGlass;
  with StringGrid1 do begin
    try
      coinitialize(nil);
      Excel         := CreateOleObject('Excel.Application');
      ExcelDoc      := Excel.Workbooks.Add;
      WS            := ExcelDoc.ActiveSheet;
      Excel.Visible := true;
      for linea:=r0 to r1 do begin
       for i := c0 to c1 do begin
        ws.Cells.Item[linea+1, i+1]:= cells[i, linea];
       end;
      end;
      ws.cells.entirecolumn.autofit;
    finally
      screen.Cursor := c;
    end;
  end;
end;

¿Que me faltaria agregarle para lograr lo que quiero?
Responder Con Cita