Ver Mensaje Individual
  #1  
Antiguo 14-07-2014
Avatar de jafera
jafera jafera is offline
Miembro
 
Registrado: may 2007
Ubicación: Llagostera (Girona)
Posts: 582
Reputación: 17
jafera Va por buen camino
Creacion de hoja excel desde consulta IBSQL

Hola a todos.

Tengo el siguiente código que en Delphi 6 funciona perfectamente:

Código Delphi [-]
procedure TF_GeneracioFullPagament.BtnExcelClick(Sender: TObject);
var
        RangeE: Excel2000.Range;
        I, Row: Integer;
        Bookmark: TBookmarkStr;
begin
        IBExcel1.Close;
        IBExcel1.SQL[6] := 'AND C.ANIO='+ComboBox1.Text;
        IBExcel1.Open;
        ExcelApplication1.Visible [0] := True;
        ExcelApplication1.Workbooks.Add (NULL, 0);
        RangeE := ExcelApplication1.ActiveCell;
        for I := 0 to IBExcel1.Fields.Count - 1 do
        begin
                RangeE.Value := IBExcel1.Fields [i].DisplayLabel;
                RangeE := RangeE.Next;
        end;
                IBExcel1.DisableControls;
        try
                Bookmark := IBExcel1.Bookmark;
                try
                        IBExcel1.First;
                        Row := 2;
                        while not IBExcel1.EOF do
                        begin
                                RangeE := ExcelApplication1.Range ['A' + IntToStr (Row),'A' + IntToStr (Row)];
                                for I := 0 to IBExcel1.Fields.Count - 1 do
                                begin
                                        RangeE.Value := IBExcel1.Fields [i].AsString;
                                        RangeE := RangeE.Next;
                                end;
                                begin
                                        IBExcel1.Next;
                                        Inc (Row);
                                        ExcelApplication1.Range['G1','G'+IntToStr(Row)].NumberFormat := '@';
                                        ExcelApplication1.Range['J1','J'+IntToStr(Row)].NumberFormat := '0.00';
                                        ExcelApplication1.Range['K1','K'+IntToStr(Row)].NumberFormat := '0.00';
                                        ExcelApplication1.Range['L1','L'+IntToStr(Row)].NumberFormat := '0.00';
                                        ExcelApplication1.Range['M1','M'+IntToStr(Row)].NumberFormat := '0.00';
                                        ExcelApplication1.Range['N1','N'+IntToStr(Row)].NumberFormat := '0.00';
                                end;
                        end;
                finally
                        IBExcel1.Bookmark := Bookmark;
                end;
        finally
                IBExcel1.EnableControls;
        end;
        RangeE := ExcelApplication1.Range ['A1', 'N' + IntToStr (Row - 1)];
        RangeE.AutoFormat (3, NULL, NULL, NULL, NULL, NULL, NULL);
end;
Cuando intento recompilar la aplicación en Delphi XE5, me da un error en la declaración de la variable RangeE:Excel2000.Range.

He visto que ahora la propiedad Range se llama ExcelRange, es correcto?

Si le declaro la variable como RangeE:ExcelXP, ExcelRange empieza a desencadenar un seguido de errores en las declaraciones siguientes como por ejemplo RangeE.Value := IBExcel1.Fields [i].AsString; donde me dice que := found expected [

No se, estoy un poco perdido.
Hay otra forma más simple de pasar una consulta IB a Excel?

Gracias por adelantado

Josep
Responder Con Cita