| View previous topic :: View next topic |
| Author |
Message |
briglia23 OOo Enthusiast

Joined: 24 Jun 2008 Posts: 121
|
Posted: Fri Jul 11, 2008 12:38 am Post subject: how to copy a calc table in a Base table by macro |
|
|
Who can help me?
I know how to do this manually but i can't do by macro.
Thanks a lot |
|
| Back to top |
|
 |
Cosmic P OOo Enthusiast

Joined: 23 Mar 2005 Posts: 186
|
Posted: Fri Jul 11, 2008 9:50 am Post subject: |
|
|
| 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 |
|
 |
briglia23 OOo Enthusiast

Joined: 24 Jun 2008 Posts: 121
|
Posted: Sun Jul 13, 2008 11:05 pm Post subject: |
|
|
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 |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2465 Location: Chonburi Thailand Asia
|
Posted: Mon Jul 14, 2008 12:33 am Post subject: |
|
|
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 |
|
 |
briglia23 OOo Enthusiast

Joined: 24 Jun 2008 Posts: 121
|
Posted: Mon Jul 14, 2008 12:41 am Post subject: |
|
|
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 |
|
 |
Mark B Super User


Joined: 16 Feb 2007 Posts: 852 Location: Lincolnshire, UK
|
|
| Back to top |
|
 |
briglia23 OOo Enthusiast

Joined: 24 Jun 2008 Posts: 121
|
Posted: Mon Jul 14, 2008 5:57 am Post subject: |
|
|
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 |
|
 |
|