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

how to copy a calc table in a Base table by macro

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
briglia23
OOo Enthusiast
OOo Enthusiast


Joined: 24 Jun 2008
Posts: 121

PostPosted: Fri Jul 11, 2008 12:38 am    Post subject: how to copy a calc table in a Base table by macro Reply with quote

Who can help me?
I know how to do this manually but i can't do by macro.
Thanks a lot
Back to top
View user's profile Send private message
Cosmic P
OOo Enthusiast
OOo Enthusiast


Joined: 23 Mar 2005
Posts: 186

PostPosted: Fri Jul 11, 2008 9:50 am    Post subject: Reply with quote

Could you be a bit more specific? What cells need to be copied? What kind of information do you need to enter into the database?
Back to top
View user's profile Send private message
briglia23
OOo Enthusiast
OOo Enthusiast


Joined: 24 Jun 2008
Posts: 121

PostPosted: Sun Jul 13, 2008 11:05 pm    Post subject: Reply with quote

I need to copy from (0.0) to (4,199).
Manually i can do simply copying my area and paste it on the table menĂ¹ of Base.
I want to do the same thing by macro.

Thanks
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Mon Jul 14, 2008 12:33 am    Post subject: Reply with quote

Two ways possible to automate this:


* export Calc data as CSV, then use SQL direct command INSERT FROM FILE doing the insert;

* wirte a macro with INSERT-SQL statement and loop on your sheet.
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
briglia23
OOo Enthusiast
OOo Enthusiast


Joined: 24 Jun 2008
Posts: 121

PostPosted: Mon Jul 14, 2008 12:41 am    Post subject: Reply with quote

Thank you.
I try with the second way.
i wrote this:

Colonna = 0
for i = 1 to 5 step 1
rCell=xSheetDB.getCellByPosition(Colonna,i)
xValueDB = rCell.getFormula
Print xValueDB
strSQL = "INSERT INTO ""Tabella2"" (""DATA"", ""CODICE"", ""ATTIVITA"", ""TEMPO"", ""LUOGO"", ""NOTE"") VALUES ('pippo')"
Stmt.executeUpdate(strSQL)
Colonna = Colonna + 1
Next i

But i have this error:
numbers of columns doesn't corresponds in the statement.

The table "Tabella2" have 6 columns:
DATA,CODICE,ATTIVITA,TEMPO,LUOGO,NOTE

Where and what is the error?

Thank you
Back to top
View user's profile Send private message
Mark B
Super User
Super User


Joined: 16 Feb 2007
Posts: 852
Location: Lincolnshire, UK

PostPosted: Mon Jul 14, 2008 1:09 am    Post subject: Reply with quote

Hi

One of my chapters may help you - go to http://www.packtpub.com/openoffice-ooobasic-calc-automation/book and then look for "Download Chapter 6: Working with Databases"

Mark
_________________
Mark B's Articles
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
briglia23
OOo Enthusiast
OOo Enthusiast


Joined: 24 Jun 2008
Posts: 121

PostPosted: Mon Jul 14, 2008 5:57 am    Post subject: Reply with quote

I got it.
I don't copy the Calc Table, but i write my arguments row by row

Thanks everybody for the help
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