Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Exel datei in stringrid (https://www.delphipraxis.net/25974-exel-datei-stringrid.html)

NikoMitDaMacht 15. Jul 2004 19:51


Exel datei in stringrid
 
Hallo erstmal!!!


Ich weiß dass es dieses Thema hier schon tausendmal gab :roll:

ich frag aber trozdem, weil ich nicht das gefunden hab was ich wollte:

Wie kann ich eine exel Datei in ein(e) Stringrid laden ?
Möglicht ohne dass exel auf dem rechner installiert ist


Danke im voraus.

Bernhard Geyer 16. Jul 2004 07:38

Re: Exel datei in stringrid
 
Ohne Excel? Da fällt mir als einzige Lösung nur Flexel ein. Und die Grids von TMS bieten eine Ein-Zeilen-Lösung an.

NikoMitDaMacht 1. Aug 2004 00:13

Re: Exel datei in stringrid
 
Hab die kompo:
Wie kann ich sie installieren? Da kommt diese fehlermeldung:[Fatal Error] FlexCel50.dpk(113): Unit UFlxMessages was compiled with a different version of VarUtils.VarDateFromStr

Wie kann ich das beheben?

Luckie 1. Aug 2004 00:19

Re: Exel datei in stringrid
 
Du brauchst wohl das Packet passen zu deiner Delphi Version. Der dateiname FlexCel50.dpk läßt darauf schließen, dass es sich um ein Packet für Delphi 5 handelt. Laut deinen Angaben hast du aber Delphi 6 (Enterprise).

NikoMitDaMacht 1. Aug 2004 12:05

Re: Exel datei in stringrid
 
Ja das ist mir klar denn bei der kompo ist auch FlexCel60.dpk dabei (Die fehlermeldung hab ich kopiert als ich es mal mit diesen Packet ausprobiert hab)
Dund das ding auch nicht!

NikoMitDaMacht 2. Aug 2004 14:46

Re: Exel datei in stringrid
 
Und wie könnte ich das machen wenn excel auf dem rechner installiert ist?

NikoMitDaMacht 5. Aug 2004 14:58

Re: Exel datei in stringrid
 
Also ich habe jetzt folgende function bei advdelphisys.com ( über Google) gefunden:

Delphi-Quellcode:
Function ExcelCopyToStringGrid(
  Excel                : Variant;
  ExcelFirstRow        : Integer;
  ExcelFirstCol        : Integer;
  ExcelLastRow         : Integer;
  ExcelLastCol         : Integer;
  StringGrid           : TStringGrid;
  StringGridFirstRow   : Integer;
  StringGridFirstCol   : Integer;
  SizeStringGridToFit  : Boolean; {Make the StringGrid the same size as the input range}
  ClearStringGridFirst : Boolean {cells outside input range in StringGrid are cleared}
  ): Boolean;
Var
  C,R : Integer;
Begin
  Result := False;
  If ExcelLastCol < ExcelFirstCol Then Exit;
  If ExcelLastRow < ExcelFirstRow Then Exit;
  If (ExcelFirstRow < 1) Or (ExcelFirstRow > 255)  Then Exit;
  If (ExcelFirstCol < 1) Or (ExcelFirstCol > 30000) Then Exit;
  If (ExcelLastRow < 1) Or (ExcelLastRow > 255)   Then Exit;
  If (ExcelLastCol < 1) Or (ExcelLastCol > 30000) Then Exit;
  If StringGrid = nil  Then Exit;
  If SizeStringGridToFit Then
  Begin
    StringGrid.ColCount := ExcelLastCol - ExcelFirstCol + StringGridFirstCol + 1;
    StringGrid.RowCount := ExcelLastRow - ExcelFirstRow + StringGridFirstRow + 1;
  End;
  If ClearStringGridFirst Then
  Begin
    C := StringGrid.ColCount;
    R := StringGrid.RowCount;
    StringGrid.ColCount := 1;
    StringGrid.RowCount := 1;
    StringGrid.Cells[0,0] := '';
    StringGrid.ColCount := C;
    StringGrid.RowCount := R;
  End;

  Result := True;
  For R := ExcelFirstRow To ExcelLastRow Do
  Begin
    For C := ExcelFirstCol To ExcelLastCol Do
    Begin
      Try
        StringGrid.Cells[
          C - ExcelFirstCol + StringGridFirstCol,
          R - ExcelFirstRow + StringGridFirstRow] :=
            Excel.Cells[R, C];
      Except
        Result := False;
      End;
    End;
  End;
End;
leider weiss ich nicht was die variable "Variant" (Excel : Variant;) ist und ich hab keinen Plan was ich für sie einsetzen sol.

Bei "uses" dieser unit war auch noch eine datei deklaiert die ich nicht habe die aber widerum ur von einer function gebeaucht wird.

weiß da irgend jemand hilfe?


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:31 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz