[Solved] I can't insert data into Table Control

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
zenira
Posts: 88
Joined: Sun May 11, 2014 11:24 am

[Solved] I can't insert data into Table Control

Post by zenira »

hi
I want insert "Example" string into "ColumnName" column in TableControl but I can't do it

Code: Select all

oTable=oForm.getByName("TableControl1")
oTable.insertByName("ColumnName","Example")
how can I do.
I can not find enough document about TableGrid how can be added data into it
Thanks for your help
Last edited by zenira on Tue Mar 28, 2017 9:53 pm, edited 2 times in total.
LibreOffice 4.1.0.4 on Windows 7
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: I can't insert data into Table Control

Post by UnklDonald418 »

Have you looked at this example?
viewtopic.php?f=100&t=36716
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
zenira
Posts: 88
Joined: Sun May 11, 2014 11:24 am

Re: I can't insert data into Table Control

Post by zenira »

yes . I did but I did not understand
LibreOffice 4.1.0.4 on Windows 7
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: I can't insert data into Table Control

Post by UnklDonald418 »

Yes, the OO API is complex and has a steep learning curve. Add to that the fact that the official documentation is opaque. On this forum the common recommendation is that to make full use of SQL and proper database design and rely on macro programming as a last resort.

It isn't entirely clear what you are trying to accomplish.
Are you sure you need a macro for this?
InsertByName() is used to programmatically add a new control to a form. Is that what you want?
Or are you trying to change the Column heading “ColumnName” on the table to “Example”?
Or are you trying to insert the string “Example” into a table cell in the column “ColumnName”?

Look here for a list of macro programming resources.
viewtopic.php?f=39&t=13396&p=64815&hili ... ide#p64815
Many of those are free downloads.
If you don't already have the macro programming documents from Andrew Pintonyak see:
http://www.pitonyak.org/oo.php
You also might find The Star Office Basic Programmers Guide helpful
https://wiki.openoffice.org/wiki/Docume ... ASIC_Guide

One book I found particularly helpful was “Database Programming with OpenOffice.org Base & Basic” by Roberto Benitez.
http://www.baseprogramming.com/%20%20%2 ... urces.html
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
zenira
Posts: 88
Joined: Sun May 11, 2014 11:24 am

Re: I can't insert data into Table Control

Post by zenira »

Thank you UnklDonald418, I appreciate your effort
Yes I want to add some value into grid, ColumnName is one of column names in grid.
I will study examples in your post.
Really thanks
LibreOffice 4.1.0.4 on Windows 7
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: [Solved] I can't insert data into Table Control

Post by UnklDonald418 »

OK, try

Code: Select all

oTable=oForm.getByName("TableControl1")
oColumn = oTable.getByName("ColumnName")
oColumn.Boundfield.updateString("Example")  
oColumn.commit   
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply