Einzelnen Beitrag anzeigen

Steven2

Registriert seit: 17. Nov 2006
94 Beitrдge
 
Delphi 11 Alexandria
 
#1

OpenOffice.org Writer - Stringgrid

  Alt 12. Mдr 2012, 11:57
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;
  Mit Zitat antworten Zitat