Buenas a todos.
Como comenté en algún otro post, hice el cambio de D6 a DXE5, no sin tener más de un problema con la conversión de código.
De momento todos los problemas se han ido solucionando y aplicando mejoras en el código a fin de aligerar un poco los ejecutables que han crecido enormemente en relación a los viejos D6.
El problema con el que no doy la solución por ahora es la exportación a excel del contenido de una sql a fin de que sea transparente al usuario.
Hasta el momento usaba el código siguiente:
Código Delphi
[-]procedure TF_GeneracioFullPagament.BtnExcelClick(Sender: TObject);
var
RangeE: Excel2000.ExcelRange; 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;
y no le gusta las lineas:
[dcc32 Warning] Inici.pas(9): W1005 Unit 'Vcl.FileCtrl' is specific to a platform
[dcc32 Warning] GenerarFullPagament.pas(263): W1002 Symbol 'ExcelRange' is specific to a platform
[dcc32 Error] GenerarFullPagament.pas(280): E2010 Incompatible types: 'AnsiString' and 'System.TArray<System.Byte>'
[dcc32 Error] GenerarFullPagament.pas(304): E2010 Incompatible types: 'System.TArray<System.Byte>' and 'AnsiString'
He cambiado los servers a XP en lugar de 2000 y el código queda así:
Código Delphi
[-]procedure TF_GeneracioFullPagament.BtnExcelClick(Sender: TObject);
var
RangeE: ExcelXP.ExcelRange;
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;
Y ahora me da error en las lineas:
[dcc32 Error] GenerarFullPagament.pas(275): E2029 '[' expected but ':=' found
[dcc32 Error] GenerarFullPagament.pas(275): E2010 Incompatible types: 'Procedure' and 'string'
[dcc32 Error] GenerarFullPagament.pas(280): E2010 Incompatible types: 'AnsiString' and 'System.TArray<System.Byte>'
[dcc32 Error] GenerarFullPagament.pas(289): E2029 '[' expected but ':=' found
[dcc32 Error] GenerarFullPagament.pas(289): E2010 Incompatible types: 'Procedure' and 'string'
[dcc32 Error] GenerarFullPagament.pas(304): E2010 Incompatible types: 'System.TArray<System.Byte>' and 'AnsiString'
Alguien me puede iluminar un poco?
Llevo dias dándole vueltas y no encuentro por dónde atajarlo.
Saludos
Josep