Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   OpenOffice.org Writer - Stringgrid (https://www.delphipraxis.net/167070-openoffice-org-writer-stringgrid.html)

Steven2 12. Mär 2012 11:57

OpenOffice.org Writer - Stringgrid
 
Hallo,

möchte den Inhalt eines Stringgrids in OpenOffice.org Writer einfügen.
Ich habe folgendes Beipiel gefunden welches eine Tabelle in einem Writer Dokument erzeugt.
Kann mir jemand weiter helfen?
Grüße
Steven

Delphi-Quellcode:
procedure TfmMain.btMainTestClick(Sender: TObject);
var
  V:variant;
  x,y:integer;
begin
  OW.PageStyles[0].HeaderIsOn:=true;
  OW.PageStyles[0].ModelCursor[owhHeader].Text:='Test header '#13'line2';
  OW.PageStyles[0].ModelCursor[owhHeader].Font.Posture:=ofpItalic;
  OW.PageStyles[0].ModelCursor[owhHeader].Para.HoriAlignment:=ophCenter;
  OW.PageStyles[0].ModelCursor[owhHeader].CollapseToEnd;
  OW.PageStyles[0].ModelCursor[owhHeader].Text:='Page ';
  OW.PageStyles[0].ModelCursor[owhHeader].CollapseToEnd;
  OW.PageStyles[0].ModelCursor[owhHeader].InsertPageNumber;
  OW.PageStyles[0].ModelCursor[owhHeader].Text:=' of ';
  OW.PageStyles[0].ModelCursor[owhHeader].CollapseToEnd;
  OW.PageStyles[0].ModelCursor[owhHeader].InsertPageCount;

  OW.PageStyles[0].HeaderBottomBorder:=BLine(clRed,0,30,0);
  OW.PageStyles[0].HeaderTopBorder:=BLine(clBlue,0,30,0);
  OW.Tables.Insert(5,9,'',OW.ViewCursor);
  OW.Tables[0].CellByName['A1'].AsText:='Test';
  OW.Tables[0].CellByName['A2'].AsNumber:=12.5678;
  OW.Tables[0].CellByName['A4'].AsDate:=Now;
  OW.Tables[0].CellByName['A4'].Format:=OW.NumberFormats.Add('DD.MM.YYYY');
  OW.Tables[0].CellByName['A4'].BackColor:=clSilver;

  V:=VarArrayCreate([1,3,1,2],VarVariant);
  for x:=1 to 3 do
    for y:=1 to 2 do
      V[x,y]:=IntToStr(x*y+1);
  OW.Tables[0].CellRange[0,1,2,2].Para.HoriAlignment:=ophCenter;

  OW.Tables[0].CellRange[0,1,2,2].Para.Margin.Top:=500;
  OW.Tables[0].CellRange[0,1,2,2].Para.Margin.Left:=500;
  OW.Tables[0].CellRange[0,1,2,2].Para.Margin.Right:=500;
  OW.Tables[0].CellRange[0,1,2,2].Para.Margin.Bottom:=500;

  OW.ViewCursor.GotoEnd(false);
  OW.ViewCursor.Font.FontName:='Times New Roman';
  OW.ViewCursor.Font.Height:=12;
  OW.ViewCursor.Para.FirstLineIndent:=1000;
  OW.ViewCursor.Para.HoriAlignment:=ophLeft;
  OW.ViewCursor.Text:='Çàäà÷à - â ïðîãðàììå íà D7 ôîðìèðóåòñÿ ïðàéñ-ëèñò.'+#13+
                  'Ðàíåå ÿ âûâîäèë åãî â DBF, îòêðûâàë Excel-åì, è òàì ìàêðîñîì ôîðìàòèðîâàë êàê íàäî.'+#13;
  OW.ViewCursor.CollapseToEnd;
  OW.ViewCursor.Para.LineSpacing:=LSpacing(olsProp,150);
  OW.ViewCursor.Para.DropCapFormat:=DCFormat(2,1,1);
  OW.ViewCursor.Text:='Ïîòîì ÷òî áû íå ñâÿçûâàòüñÿ ñ ìàêðîñàìè (íó íå ïåðåâàðèâàþ ÿ ýòèì îáúåêòû ýêñåëÿ) '+
                  'ñòàë äåëàòü òàê - âûâîæó â html ñ ôîðìàòèðîâàíèåì è îòêðûâàþ åãî Excel-åì. Äàæå ôîðìóëû ðàáîòàþò.';
  OW.ViewCursor.GotoEnd(false);
  OW.Tables.Insert(3,35,'',OW.ViewCursor);
  OW.Tables[1].HoriOrient:=ofhoLeft;
  OW.Tables[1].Width:=12000;
  OW.Tables[1].RepeatHeadline:=true;
  OW.Tables[1].HeaderRowCount:=2;
  OW.Tables[1].Rows[0].BackColor:=clGreen;
  OW.Tables[1].Rows[0].AutoHeight:=false;
  OW.Tables[1].Rows[0].Height:=2000;
  OW.Tables[1].Cell[0,0].AsText:='String1';
  OW.Tables[1].Cell[1,0].AsText:='String2'+#13+'String3';
  OW.Tables[1].Cell[0,1].AsText:='1';
  OW.Tables[1].Cell[1,1].AsText:='2';
  OW.Tables[1].Cell[2,1].AsText:='3';
  OW.Tables[1].CellRange[0,1,2,1].Para.HoriAlignment:=ophCenter;
  OW.Tables[1].Cell[0,0].VertAlignment:=ofvoCenter;
  OW.Tables[1].Cell[0,0].Font.Posture:=ofpItalic;
  OW.Tables[1].Cell[0,0].Font.Weight:=ofwBold;
  OW.Tables[1].Cell[0,0].Font.Underline:=ofuDoubleWave;
//  ShowMessage('Page count = '+IntToStr(OW.PageCount));
  OW.ViewCursor.GotoEnd(false);
  OW.ViewCursor.Para.BreakType:=obtPageBefore;
  OW.ViewCursor.Text:='Test 3 page';
  OW.ViewCursor.CollapseToEnd;
  OW.ModelCursor.SyncFrom(OW.ViewCursor);
end;

Coffeecoder 12. Mär 2012 13:04

AW: OpenOffice.org Writer - Stringgrid
 
Zitat:

Zitat von Steven2 (Beitrag 1156130)

Delphi-Quellcode:
....
  OW.Tables[1].Cell[0,0].AsText:= Stringgrid.cells[0,0] // <--------
  OW.Tables[1].Cell[1,0].AsText:=Stringgrid.cells[1,0]// <--------
....

Hi,
Hast du das mal versucht?

Steven2 12. Mär 2012 13:53

AW: OpenOffice.org Writer - Stringgrid
 
Hallo Coffeecoder,

danke für deine Antwort.
Klappt irgendwie nicht.
Mit Word und einen Stringgrid sieht es so aus:

Delphi-Quellcode:
     for iGridRows := 1 to iRows do
      begin
        for jGridCols := 1 to iCols do
        begin
          WordTable.Cell(iGridRows, jGridCols).Range.Text := StringGrid2.Cells[jGridCols - 1, igridRows - 1];
        end;
      end;
[DELPHI]

So habe ich es gerade:

Delphi-Quellcode:
 for iGridRows := 1 to iRows do
      begin
        for jGridCols := 1 to iCols do
        begin
            OW.Tables[1].Cell[0,0].AsText:= advStringgrid1.cells[0,0]; // <--------
            OW.Tables[1].Cell[1,0].AsText:=advStringgrid1.cells[1,0];// <--------
           end;
        end;

Coffeecoder 12. Mär 2012 14:03

AW: OpenOffice.org Writer - Stringgrid
 
Zitat:

Zitat von Steven2 (Beitrag 1156165)

So habe ich es gerade:

Delphi-Quellcode:
 for iGridRows := 1 to iRows do
      begin
        for jGridCols := 1 to iCols do
        begin
            OW.Tables[1].Cell[0,0].AsText:= advStringgrid1.cells[0,0]; // <--------
            OW.Tables[1].Cell[1,0].AsText:=advStringgrid1.cells[1,0];// <--------
           end;
        end;

Dann nur noch anpassen, ich weiss nicht genau in welche Zeilen du alles einfügen willst. Dies ist nur ein Beispiel:
Delphi-Quellcode:
for iGridRows := 1 to iRows do
      begin
        for jGridCols := 1 to iCols do
        begin
            OW.Tables[1].Cell[iGridRows,jGridCols].AsText:= advStringgrid1.cells[iGridRows,jGridCols];
           end;
end;
Zitat:

Zitat von Steven2 (Beitrag 1156165)
Hallo Coffeecoder,

danke für deine Antwort.
Klappt irgendwie nicht.

Kriegst du eine Fehlermeldung? Wenn ja, welche?
Sonst beschreibe mal bitte genauer was nicht geht ;)

Steven2 12. Mär 2012 18:50

AW: OpenOffice.org Writer - Stringgrid
 
Diese Fehlermeldung:
Code:
---------------------------
Openofficetest
---------------------------
com.sun.star.lang.IndexOutOfBoundsException:.
---------------------------
OK  
---------------------------
oder
diese:

Code:
---------------------------
Openofficetest
---------------------------
Ungültige Variantenoperation.
---------------------------
OK  
---------------------------

Coffeecoder 12. Mär 2012 19:29

AW: OpenOffice.org Writer - Stringgrid
 
Zitat:

Zitat von Steven2 (Beitrag 1156214)
Diese Fehlermeldung:
Code:
---------------------------
Openofficetest
---------------------------
com.sun.star.lang.IndexOutOfBoundsException:.
---------------------------
OK  
---------------------------

Das liegt daran, so sollte es besser sein:

Delphi-Quellcode:
for iGridRows := 1 to iRows do
      begin
        for jGridCols := 1 to iCols do
        begin
            OW.Tables[1].Cell[iGridRows,jGridCols].AsText:= advStringgrid1.cells[iGridRows-1,jGridCols-1];
           end;
end;
Zitat:

Zitat von Steven2 (Beitrag 1156214)

oder
diese:
Code:
---------------------------
Openofficetest
---------------------------
Ungültige Variantenoperation.
---------------------------
OK  
---------------------------

In welcher Zeile taucht dieser Fehler auf?

Steven2 12. Mär 2012 21:00

AW: OpenOffice.org Writer - Stringgrid
 
irgendwie finde ich die Zeile nicht, ich suche noch.
Das klappt damit auch nicht.

Delphi-Quellcode:
 for iGridRows := 1 to iRows do
     begin
        for jGridCols := 1 to iCols do
        begin
            OW.Tables[1].Cell[iGridRows,jGridCols].AsText:= advStringgrid1.cells[iGridRows-1,jGridCols-1];
           end;
end;
Soll ich mal ein Beispiel fertig machen und hier anhängen?

Coffeecoder 13. Mär 2012 07:19

AW: OpenOffice.org Writer - Stringgrid
 
Zitat:

Zitat von Steven2 (Beitrag 1156235)
irgendwie finde ich die Zeile nicht, ich suche noch.
Das klappt damit auch nicht.

Delphi-Quellcode:
 for iGridRows := 1 to iRows do
     begin
        for jGridCols := 1 to iCols do
        begin
            OW.Tables[1].Cell[iGridRows,jGridCols].AsText:= advStringgrid1.cells[iGridRows-1,jGridCols-1];
           end;
end;
Soll ich mal ein Beispiel fertig machen und hier anhängen?

Jo bitte :)

Steven2 13. Mär 2012 08:52

AW: OpenOffice.org Writer - Stringgrid
 
Kann ich die Stringgridkomponente von TMS nehmen?
Oder soll ich in dem Beispiel ein einfaches Stringgrid nehmen?

Steven2 13. Mär 2012 09:01

AW: OpenOffice.org Writer - Stringgrid
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hab jetzt mal ein Beispiel mit dem TMS Stringgrid

Der Fehler ist hier:
Zitat:

Zeile 5209
FTable.TableObj:=FDocument.GetTextTables.GetByInde x(Index);
in der uOpenOffice.pas


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:28 Uhr.
Seite 1 von 2  1 2      

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