OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Fill table in textdocument

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
washington
General User
General User


Joined: 14 Jul 2003
Posts: 13
Location: Duisburg, Germany

PostPosted: Tue Aug 12, 2003 11:00 pm    Post subject: Fill table in textdocument Reply with quote

Hello,
how can I fill a table in a textdocument with data from database ?
Thanks.

Greetings
Carsten
Back to top
View user's profile Send private message
openmind
OOo Enthusiast
OOo Enthusiast


Joined: 28 Jun 2003
Posts: 106
Location: Switzerland

PostPosted: Wed Aug 13, 2003 1:15 am    Post subject: Reply with quote

http://www.oooforum.org/forum/viewtopic.php?t=1758&highlight=fill+table+text+document
Back to top
View user's profile Send private message
washington
General User
General User


Joined: 14 Jul 2003
Posts: 13
Location: Duisburg, Germany

PostPosted: Wed Aug 13, 2003 3:59 am    Post subject: Fill table in textdocument Reply with quote

Dear friend,
I don't want to create an own table.
I got a finished template (textdocument with a table), and now should I fill these template with data.

At this position
Code:
oTextTable.getCellByPosition(1,0).String = oDBResult.getString( 1 )

I got the com.sun.star.lang.IndexOutOfBoundsException.
Back to top
View user's profile Send private message
Mario M
Guest





PostPosted: Wed Aug 13, 2003 4:06 am    Post subject: show us more code Reply with quote

show us more code
we love code
COOOODEEEEE
Back to top
washington
General User
General User


Joined: 14 Jul 2003
Posts: 13
Location: Duisburg, Germany

PostPosted: Wed Aug 13, 2003 4:52 am    Post subject: Fill table in textdocument Reply with quote

You love code, you got code (essence of program):

Code:
Global oDesktop As Object
Global oDocument As Object
Global oText As Object
Global oDialog as Object

Dim Statement As Object
Dim ResultSet As Object
Dim Doc As Object

Sub FillDocument 
  Dim sheet as Object
  Dim cell as Object
 
  REM *** Open database connection ***        
  DataSource = DatabaseContext.getByName("regendb")
  If Not DataSource.IsPasswordRequired Then
    Connection = DataSource.GetConnection("","")
  Else
    InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
    Connection = DataSource.ConnectWithCompletion(InteractionHandler)
  End If

  REM *** Access to database ***      
  Statement = Connection.createStatement()
  ResultSet = Statement.executeQuery("select FIRST 30 fb_id, name1, strasse, plz, ort,_
  lage from sicadi.a_druckanschrift where fb_id = " & oListBox.getSelectedItem())
 
  REM *** Open template with text, bookmarks and table ***   
  oDesktop = createUnoService("com.sun.star.frame.Desktop")
  sUrl = "file:///C:/Erinnerung_Wuppertal.stw" '"private:factory/swriter"
  oDocument = _
  oDesktop.loadComponentFromURL(sUrl,"_blank",0,mNoArgs)

  REM *** Fill document with life ***
  If Not IsNull(ResultSet) Then
     While (ResultSet.next)
     For i = 1 To 1 'Step -1
        REM *** Activ document ***
        Doc = StarDesktop.CurrentComponent
       
        REM *** Attempt to fill table
        oText = Doc.Text       
        ' get a text cursor
        oTextCursor = oText.createTextCursor()
        oTextCursor.gotoStart( FALSE )
        sMySQLString = ResultSet.getString(i)
        oTextTable = Doc.createInstance( "com.sun.star.text.TextTable" )
        oTextTable.initialize( 2,2 )
        oText.insertString( oTextCursor, oDBResult.getString( 2 ) , FALSE )
        oText.insertTextContent( oTextCursor, oTextTable, FALSE)
        oTextTable.getCellByPosition(1,0).String = oDBResult.getString( 1 )
        oTextTable.getCellByPosition(1,1).String = oDBResult.getString( 2 )
       
        REM *** Fill Bookmark
        Bookmark = Doc.Bookmarks.getByName("FB_ID1")
        Cursor = Doc.Text.createTextCursorByRange(Bookmark.Anchor)
        Cursor.String = sMySQLString
     Next i
    Wend
  End If
End Sub
Back to top
View user's profile Send private message
Mario M
General User
General User


Joined: 13 Aug 2003
Posts: 10
Location: Dresden, Germany

PostPosted: Wed Aug 13, 2003 5:24 am    Post subject: Re: Fill table in textdocument Reply with quote

well actually Im not firm in this Basic language thing but where does the var 'oDBResult' come from? I cant find any allocation in your code... and the other rhing is: dont u have to qoute the fieldnames in the sql-query? like:
Code:
select FIRST 30 "fb_id", "name1", "strasse", "plz, ort,_lage" from "sicadi.a_druckanschrift" where "fb_id" =

in delphi and java you have to - well surely u have to escape the quotationmarks (\)
as I said I dont know much about Basic - just some hints...
Back to top
View user's profile Send private message
openmind
OOo Enthusiast
OOo Enthusiast


Joined: 28 Jun 2003
Posts: 106
Location: Switzerland

PostPosted: Wed Aug 13, 2003 7:10 am    Post subject: Reply with quote

- Create a template containing bookmarks.
- Replace the bookmarks.

Example:

http://de.openoffice.info/viewtopic.php?t=53


As you're from duisburg.: no problem for you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group