Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.01.10 09:22 
Hi, Delpher,

wie kann ich mit folgendem Code verschiedene DBGrids (z.B. DBGrid1, DBGrid3, DBGrid4 ..) übergeben?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.ExcelxClick(Sender: TObject);                          //popupx, DBGx
begin        // kein extractfilename(changefileext(TbLk.TableName, '.xls'));  = z.B. QLk
  fname := concat(label30.caption, 'OUTXLS\' +
             TQuery(TDBGrid(TPopupMenu(TMenuItem(sender).GetParentComponent).popupComponent).Datasource.Dataset).Name +
               '.xls');
  if Excel_vorhanden then
  begin
    if fileexists(fname) then  excelstart(self);    
    if not fileexists(fname) or exneu then
    begin                       
      screen.Cursor := crHourGlass;
      Excel_Layout1(self);      
      Qx2Excel(TQuery(TDBGrid(TPopupMenu(TMenuItem(sender).GetParentComponent).popupComponent).Datasource.DataSet));
////      Excel_Layout2(?Grid?);  //// welches DBGrid?
      excel.activeworkbook.saveas(fname);
      screen.Cursor := crDefault;
    end;
    excel.visible := true;
  end;
end;


Danke für Hilfe / Aufklärung,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Sa 23.01.10 09:39 
Indem du Excel_Layout2 mehrere Parameter DBGrid gibst? Das ist doch eine Funktion von dir oder nicht?

ausblenden Delphi-Quelltext
1:
procedure Excel_Layout2(G1: TDBGrid; G2: TDBGird=nil; ...);					

oder als Array

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.01.10 10:43 
Ne, leider nicht, aber zur Aufklärung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
procedure TForm1.Excel_Layout2(Grid: TControl);
var  sg: TStringGrid;
    dbg: TDBGrid;
begin
  {excel.range['A1', 'A'+inttostr(rce+1)].select;       // 1. Excel-Spalte
  excel.selection.Font.bold := true; ... }


  if rre < 26 then excel.range['A1', chr(rre+64)+'1'].select  // 1. Excel-Zeile
  else             excel.range['A1', 'Z1'].select;
  excel.selection.Font.bold := true; excel.selection.Font.color := clblack;
  excel.selection.interior.color := clLtGray;

  if rre < 26 then excel.range['A1', chr(rre+64)+ '1'+ inttostr(rce)].select
  else             excel.range['A1', 'Z1'].select;                     // gesamte Tabelle

  if (grid is tStringGrid) then
  begin                                                          
    sg := (grid as TStringGrid); excel.selection.font.size := sg.Canvas.Font.Size;
  end;
  if (grid is TDBGrid) then    //excel.selection.Font.size := 8; // zu starr,
  begin
    dbg := (grid as TDBGrid);    excel.selection.font.size := dbg.Canvas.Font.Size;
  end;
  excel.cells[rce+5,2] := fname;
  excel.cells[rce+6,2] := 'Erstellt: ' + datetostr(date)+ ' um: ' + timetostr(time);
end;


Jetzt müsste mein Problem klarer sein.

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.01.10 10:52 
Ich hab's:
Der Aufruf ist:

ausblenden Delphi-Quelltext
1:
Excel_Layout2(TDBGrid(TPopupMenu(TMenuItem(sender).GetParentComponent).popupComponent));					


Bis denne, Detlef

_________________
ut vires desint, tamen est laudanda voluntas