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

Creating a macro - Writing a Script - Using the API

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

Postby zenira » Mon Mar 27, 2017 8:03 am

hi
I want insert "Example" string into "ColumnName" column in TableControl but I can't do it
Code: Select all   Expand viewCollapse view
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
zenira
 
Posts: 85
Joined: Sun May 11, 2014 11:24 am

Re: I can't insert data into Table Control

Postby UnklDonald418 » Mon Mar 27, 2017 7:05 pm

If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.3 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 543
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: I can't insert data into Table Control

Postby zenira » Mon Mar 27, 2017 8:12 pm

yes . I did but I did not understand
LibreOffice 4.1.0.4 on Windows 7
zenira
 
Posts: 85
Joined: Sun May 11, 2014 11:24 am

Re: I can't insert data into Table Control

Postby UnklDonald418 » Tue Mar 28, 2017 5:29 pm

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.
https://forum.openoffice.org/en/forum/viewtopic.php?f=39&t=13396&p=64815&hilit=Star+office+Basic+programmers+guide#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/Documentation/BASIC_Guide

One book I found particularly helpful was “Database Programming with OpenOffice.org Base & Basic” by Roberto Benitez.
http://www.baseprogramming.com/%20%20%20and%20%20http://www.baseprogramming.com/resources.html
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.3 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 543
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: I can't insert data into Table Control

Postby zenira » Tue Mar 28, 2017 9:51 pm

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
zenira
 
Posts: 85
Joined: Sun May 11, 2014 11:24 am

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

Postby UnklDonald418 » Wed Mar 29, 2017 6:03 am

OK, try

Code: Select all   Expand viewCollapse view
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 subject line
Apache OpenOffice 4.1.3 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 543
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA


Return to Macros and UNO API

Who is online

Users browsing this forum: Google [Bot] and 8 guests