Autor Beitrag
cherry
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 136

WinXP - Professional
RAD Studio 2009
BeitragVerfasst: Mo 05.09.05 12:54 
Hallo..
hab Probleme beim schreiben der Unit die für den Export zuständig ist.

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:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
unit u_ExportEXCEL;

interface
uses classes;

type TXLSExport = class(TObject)
                  private
                     fs : TFilestream;
                  public
                     constructor Create(filename : string);
                     destructor  Destroy; override;
                     procedure Write(const Col, Row: Word; const Value: Integer); overload;
                     procedure Write(const Col, Row: Word; const Value: Double); overload;
                     procedure Write(const Col, Row: Word; const Value: string); overload;
                  end;


implementation

const
  CXlsBof    : array[0..5of Word = ($809800$1010);
  CXlsEof    : array[0..1of Word = ($0A00);
  CXlsLabel  : array[0..5of Word = ($20400000);
  CXlsNumber : array[0..4of Word = ($20314000);
  CXlsRk     : array[0..4of Word = ($27E10000);


constructor TXLSExport.Create(filename : string);
begin
  inherited Create;
  fs := TFileStream.Create(filename,fmCreate);
  fs.WriteBuffer(CXlsBof, SizeOf(CXlsBof));
end;

destructor TXLSExport.Destroy;
begin
  fs.WriteBuffer(CXlsEof, SizeOf(CXlsEof));
  inherited Destroy;
end;

procedure TXLSExport.Write(const Col, Row: Word; const Value: Integer);
var
  V: Integer;
begin
  CXlsRk[2] := Row;
  CXlsRk[3] := Col;
  fs.WriteBuffer(CXlsRk, SizeOf(CXlsRk));
  V := (Value shl 2or 2;
  fs.WriteBuffer(V, 4);
end;

procedure TXLSExport.Write(const Col, Row: Word; const Value: Double);
begin
  CXlsNumber[2] := Row;
  CXlsNumber[3] := Col;
  fs.WriteBuffer(CXlsNumber, SizeOf(CXlsNumber));
  fs.WriteBuffer(Value, 8);
end;

procedure TXLSExport.Write(const Col, Row: Word; const Value: string);
var L: Word;
begin
  L := Length(Value);
  CXlsLabel[1] := 8 + L;
  CXlsLabel[2] := Row;
  CXlsLabel[3] := Col;
  CXlsLabel[5] := L;
  fs.WriteBuffer(CXlsLabel, SizeOf(CXlsLabel));
  fs.WriteBuffer(Pointer(Value)^, L);
end;

end.


Beim Highlit reklamiert er zum ersten mal:
der Linken Seite kann kein Wert zugewiesen werden.

Wär cool wenn mir Jemand helfen könnte!
THX


Moderiert von user profile iconKlabautermann: Topic aus Sonstiges verschoben am Mo 05.09.2005 um 13:14
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 05.09.05 13:10 
Hallo,

das bemängelt er, weil das Array als cons Deklariert ist. Konstanten können nun einmal nicht verändert werden. Wenn du das Willst, musst du es als Variable deklarieren.

Gruß
Klabautermann

PS: Du kannst auch einfach Suche in: Delphi-Forum, Delphi-Library PER ADO AUF EXCEL Dateien zugreifen.


Zuletzt bearbeitet von Klabautermann am Mo 05.09.05 13:13, insgesamt 1-mal bearbeitet
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Mo 05.09.05 13:12 
Das was links steht hast du doch als Konstante deklariert!
cherry Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 136

WinXP - Professional
RAD Studio 2009
BeitragVerfasst: Mo 05.09.05 13:19 
:? Ooops..
Funktioniert nun bestens nachdem ich die Arrays als Variablen deklariert habe!
THX!