Autor Beitrag
Adam Weishaupt
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: Sa 08.05.04 11:54 
ich soll ein programm schreiben, welches etwa so arbeitet:

man gibt einen suchbegriff ein (in einer edit-komponente) und klickt z.b. auf einen button...
dann ladet das programm von einer .xls-tabelle einen eintrag einer zelle, das den suchbegriff beinhaltet
und zeigt diesen in der komponente: StringGrid an.

beispiel: man hat in einer xls-tabelle seine spiele geordnet.. Name, Genre, Preis.

dann gibt man beim programm ein: SimCity
und schon ladet das programm von der xls-tabelle die zeile wo SimCity steht samt Genre und Preis und schreibt dies in eine zeile des StringGrids

das habe ich bisher geschrieben:

ausblenden volle Höhe 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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
uses ComObj
:

var
  Form1: TForm1;
  Archimedes,Socrates:OLEVariant;
  Philo: Integer;
:



procedure TForm1.Button1Click(Sender: TObject);
const
  xlCellTypeLastCell = $0000000B;
var i,h,y:integer;
begin
try
Philo:=-1;
Archimedes:=CreateOLEObject('Excel.Application');
Archimedes.Visible:=false;
Archimedes.Workbooks.Open(Edit1.Text);
Socrates:=Archimedes.Workbooks[ExtractFilename(Edit1.Text)].Worksheets[1];
Socrates.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
y:=Archimedes.ActiveCell.Row;
for i:=0 to y do begin
  for h:=0 to 3 do begin
<span style="text-decoration: underline">   if Edit2.Text=Archimedes.Cells[h,i] then begin  </span>
      case h of
        0: begin with Tabelle do begin
             Cells[0,Philo+1]:=Archimedes.Cells[0,i];
             Cells[1,Philo+1]:=Archimedes.Cells[1,i];
             Cells[2,Philo+1]:=Archimedes.Cells[2,i];
             Cells[3,Philo+1]:=Archimedes.Cells[3,i];
           end; end;
        1: begin with Tabelle do begin
             Cells[1,Philo+1]:=Archimedes.Cells[1,i];
             Cells[2,Philo+1]:=Archimedes.Cells[2,i];
             Cells[3,Philo+1]:=Archimedes.Cells[3,i];
             Cells[0,Philo+1]:=Archimedes.Cells[0,i];
           end; end;
        2: begin with Tabelle do begin
             Cells[2,Philo+1]:=Archimedes.Cells[2,i];
             Cells[3,Philo+1]:=Archimedes.Cells[3,i];
             Cells[0,Philo+1]:=Archimedes.Cells[0,i];
             Cells[1,Philo+1]:=Archimedes.Cells[1,i];
           end; end;
        3: begin with Tabelle do begin
             Cells[3,Philo+1]:=Archimedes.Cells[3,i];
             Cells[0,Philo+1]:=Archimedes.Cells[0,i];
             Cells[1,Philo+1]:=Archimedes.Cells[1,i];
             Cells[2,Philo+1]:=Archimedes.Cells[2,i];
           end; end;
        end;
      end;
    end;
  end;
finally
Archimedes.Workbooks.Close;
end;
end;


hier die variablendefinitionen:
Archimedes = die per Edit1.text geladene Excel
y = die letzte beschriebene zeile der Excel
h,i = schleifenvariablen.. h fuer Column, i fuer Row


bei der unterstrichenen zeile kommt ein fehler O_o weiss jemand, warum?
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Sa 08.05.04 12:07 
Zitat:
ein fehler O_o


O_o?
Adam Weishaupt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: Sa 08.05.04 12:17 
LOOOOOOOOOOOOOL

gute antwort :-P :eyecrazy:
wenn das so weitergeht.....

:autsch:
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Sa 08.05.04 12:21 
Was ist O_o?
Adam Weishaupt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: Sa 08.05.04 16:09 
ist doch egal o_O

O_o = :eyecrazy: :shock: :roll: :?!?:

die 4 dinge ^^