Avec OpenOffice 2.1 j'arrivais sans problème à remplir les tableaux. Depuis la 
version 3 ceux-ci ne sont plus affichés et il n'y a pas de message d'erreur!
Je n'en comprend pas le motif!!

Function SendToOpenOffice:Integer;
Var
  MyDoc:Variant;
  Tls:Boolean;
  Titre:String;
  Symb,ValMax,ValMin,SymbChar:String;
  i,Row:Integer;
Begin
  Result:=0;
  ConnectOpenOffice;
  MyDoc:=Unassigned;
  MyDoc:=StarDesktop.CurrentComponent;
  if isNullEmpty(MyDoc)=False then
  Begin
    StartRow:=StartRow+3;
    Row:=0;
    Tls:=ToolsIni;
    For i:=0 To Symbol.Count-1 do
    begin
      Symb:=Symbol.Strings[i];
      SymbChar:=ExtractSymbol(Symb);//Only symbol
      Symb:=CleanDt(Symb); //Only data
      ValMin:=''; ValMax:='';
      if (Symb<>'weight') and (Symb<>'lnote') then
      begin
        Result:=WriteCell(MyDoc,StartCol+IntToStr
(StartRow+Row),SymbChar);//First column
        If Result=1 Then SendLog('Unable to write '+SymbChar);
        ValMax:=ExtractMax(Symb);
        if ValMax<>'' then
        Begin
          Result:=WriteCell(MyDoc,B+IntToStr(StartRow+Row),ValMax);
          If Result=1 Then SendLog('Unable to write '+ValMax);
        End;//End second column
        ValMin:=ExtractMin(Symb);
        if ValMin<>'' then
        Begin
          if ValMin[1]='-'  then Delete(ValMin,1,1);
          Result:=WriteCell(MyDoc,C+IntToStr(StartRow+Row),ValMin);
          If Result=1 Then SendLog('Unable to write '+ValMin);
        End; //End tirth column
        If Tls Then
        Begin
          if Tools.ReadString('Tools',Symb,'')<>'' then
          Begin
            Result:=WriteCell(MyDoc,ToolsCol+IntToStr
(StartRow+Row),Tools.ReadString('Tools',Symb,''));
            If Result=1 Then SendLog('Unable to write '+Tools.ReadString
('Tools',Symb,''));
          End;
        End;//End Tls
        Inc(Row);
      end;//End Symb
    end;//End For
    Titre:=GetTitle;
    Result:=WriteCell(MyDoc,TitleCol+IntToStr(TitleRow),Titre);
    If Result=1 Then SendLog('Unable to write '+GetTitle);
    WriteFooter(MyDoc,'Print from scr...@2000 of GSE Sas');
    MyDoc:=Unassigned;
    FreeAndNil(Tools);
    FreeAndNil(Symbol);
  End Else
  Begin
    SendLog('Unable to open Report.ods');
    Result:=1;
  End;
End;

Ou ConnectOffice est:

Procedure ConnectOpenOffice;
begin
  if IsOpenOfficeConnected=True then exit;
  Application.ProcessMessages;
  OpenOffice:=CreateOleObject('com.sun.star.ServiceManager');
  if isNullEmpty(OpenOffice) then Raise EOOoError.Create(OOo_connectKO);
  StarDesktop:=CreateUnoService('com.sun.star.frame.Desktop');
  SpreadSheet:=CreateUnoService('com.sun.star.sheet.SpreadsheetDocument');
end;

et WriteCell:

Function WriteCell(MyDoc:Variant;CellPos,Text:String):Integer;
var
  Sheet,Cell: Variant;
  c:Char;
  i,r:Integer;
begin
  Result:=0;
  c:=CellPos[1];
  Delete(CellPos,1,1);
  r:=StrToInt(CellPos);
  if c='A' then i:=0;
  if c='B' then i:=1;
  if c='C' then i:=2;
  if c='D' then i:=3;
  if c='E' then i:=4;
  if c='F' then i:=5;
  Sheet:=MyDoc.Sheets.getByName('Screws_2000');
  if isNullEmpty(Sheet)=False then
  Begin
    Cell:=Sheet.getCellByPosition(i,r);//Avant getCellRangeByName(CellPos);
    Cell.String:=Text;
  End Else
  Begin
    Result:=1;
  End;
end;


---------------------------------------------------------------------
To unsubscribe, e-mail: prog-unsubscr...@fr.openoffice.org
For additional commands, e-mail: prog-h...@fr.openoffice.org

Répondre à