Autor Beitrag
uranop
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149

Win XP, Win 7, Slackware 11, FreeBSD
D6E, php
BeitragVerfasst: Do 24.07.08 06:31 
Hi Leute ..

mal wieder excel time : )

Ich habe hier folgenden Code gefunden >>> www.delphipraxis.net/post918977.html

Der soll den Inhalt einer ListView in ne xls schmeissen ...

soweit so gut .. Vielleicht liegt es momentan am Kaaffemangel aaaber ...

Das was da "portiert" werden soll, haette ich gerne ab Zelle A:35 bzw cells[35,1]
Ich habe grade aber nicht den plan wie ich dem code schnibbl da das bei bringen kann ...
ne idee ?
uranop Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149

Win XP, Win 7, Slackware 11, FreeBSD
D6E, php
BeitragVerfasst: Do 24.07.08 07:45 
2 tassen kaffe und die lösung steht ...

wers wissen will so gehts sehr easy

vorraus gesetzt man hat in der form schon ne gefüllte Listview

z.b. hiermit

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:
procedure TForm4.Image2Click(Sender: TObject);
const
 xlLeft = -4131;
var
  Excel : Variant;
  strPfad : string;
  Tage, Stunden, Minuten, Sekunden: Integer;
  y: integer;
begin
  Excel := CreateOleObject('Excel.Application');
  excel.Application.SheetsInNewWorkBook := 1; //Die Anzahl der Sheets
  Excel.Workbooks.Add;
  Excel.Sheets[1].Name := Edit1.Text ;
  excel.ActiveSheet.PageSetup.Zoom := false;
  excel.ActiveSheet.PageSetup.FitToPagesWide := 1;  // Y
  excel.ActiveSheet.PageSetup.FitToPagesTall := 2; // Y
  excel.Workbooks[1].WorkSheets[1].Columns.Columns[1].ColumnWidth := 30;
  excel.Workbooks[1].WorkSheets[1].Columns.Columns[2].HorizontalAlignment := xlLeft;

.
.
.
.


  for y := 0 to (ListView1.Items.Count -1) do
  begin
  Excel.Sheets[Edit1.Text].Cells[(y + 35),1].value := ListView1.Items.Item[y].Caption;
  end;
     // xls speich0rn
  strPfad := ExtractFilePath(ParamStr(0)); //ExtractFilePath(Application.ExeName);
  Excel.ActiveWorkbook.SaveAs(strPfad + '.\geraetebuecher\' + Edit1.Text + '_HW.xls');
  Excel.Quit; //Beendet Excel

  end;

Und finish