![]() |
Stringgrid nach Tabelle in Word
Hallo
ich versuche ein Stringgrid in eine Tabelle in Word zu kopieren:
Delphi-Quellcode:
Ich bekomme in Word immer nur die erste und die letzte Zeile eingefügt und auch immer so gestaucht, würde ich den Spalten gerne individuelle Breiten geben und einen schwarzen Rand.
procedure Tform1.AdvGlowButton3Click(Sender: TObject);
var WordApp, NewDoc, WordTable: OLEVariant; iRows, iCols, iGridRows, jGridCols: Integer; begin try // Create a Word Instance // Word Instanz erzeugen WordApp := CreateOleObject('Word.Application'); except // Error... // Fehler.... Exit; end; // Show Word // Word anzeigen WordApp.Visible := True; // Add a new Doc // Neues Dok einfügen NewDoc := WordApp.Documents.Add; // Get number of columns, rows // Spalten, Reihen ermitteln iCols := StringGrid1.ColCount; iRows := StringGrid1.RowCount; // Add a Table // Tabelle einfügen WordTable := NewDoc.Tables.Add(WordApp.Selection.Range, iCols, iRows); // Fill up the word table with the Stringgrid contents // Tabelle ausfüllen mit Stringgrid Daten for iGridRows := 1 to iRows do for jGridCols := 1 to iCols do WordTable.Cell(iGridRows, jGridCols).Range.Text := StringGrid1.Cells[jGridCols - 1, iGridRows - 1]; // Here you might want to Save the Doc, quit Word... // Hier evtl Word Doc speichern, beenden... // ... // Cleanup... WordApp := Unassigned; NewDoc := Unassigned; WordTable := Unassigned; end; Frohe Ostern Aaron :-) |
Re: Stringgrid nach Tabelle in Word
Hallo,
Zitat:
Zitat:
![]() |
Re: Stringgrid nach Tabelle in Word
Hallo toms
Word 2007 und Word 2000. Evtl. liegt es auch am TAdvStringgrid (TMS), muss ich mal testen. Danke für deine Tips. Ich meld mich gelich nochmal. Gruß Aaron |
Re: Stringgrid nach Tabelle in Word
Zitat:
|
Re: Stringgrid nach Tabelle in Word
Ja.
Ich teste gerade mit einem "normalen" Stringgrid, irgendwie klappt das auch nicht. Zitat:
Grüße Aaron |
Re: Stringgrid nach Tabelle in Word
Bei welcher Zeile tritt der Fehler auf?
|
Re: Stringgrid nach Tabelle in Word
Hier:
Delphi-Quellcode:
WordTable := NewDoc.Tables.Add(WordApp.Selection.Range, iCols, iRows);
|
Re: Stringgrid nach Tabelle in Word
...und die Werte von iCols, iRows?
|
Re: Stringgrid nach Tabelle in Word
Hallo toms,
ich verwende folgenden Tip: ![]() Mehr Code habe ich nicht dafür verwendet. Dein Link hilft aber auch sehr weiter: ![]() |
Re: Stringgrid nach Tabelle in Word
Zitat:
Zitat:
Darum die Frage, was für Werte die Variablen beim Aufruf von Add(...) haben. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:43 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz