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

Import CSV-File into a Calc-Document using OpenOffice 2.0.3

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


Joined: 04 Oct 2006
Posts: 1

PostPosted: Wed Oct 04, 2006 12:07 am    Post subject: Import CSV-File into a Calc-Document using OpenOffice 2.0.3 Reply with quote

Hello,
How can I import a CSV-File via Macro and copy it into a Calc-Document.
The CSV-File is seperated by ;
I already had an working function under OpenOffice 1. But under OpenOffice it doesn't work.
Please help
Bernd
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Oct 04, 2006 8:05 am    Post subject: Reply with quote

What is not working in your code ?
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
dine
General User
General User


Joined: 28 Aug 2006
Posts: 8
Location: Germany

PostPosted: Thu Oct 05, 2006 11:05 pm    Post subject: Re: Import CSV-File into a Calc-Document using OpenOffice 2. Reply with quote

berndhe wrote:
Hello,
How can I import a CSV-File via Macro and copy it into a Calc-Document.
The CSV-File is seperated by ;
I already had an working function under OpenOffice 1. But under OpenOffice it doesn't work.
Please help
Bernd


As far as i see you've got the same problem that i had when i was switching from OO1 to OO2.
i use the function below for importing csv-files (don't know where i got this from anymore)

Code:

Function OpenCSVFile (sUrl As String) As Object
' Opens CSV-file
' sUrl MUST be in Url-format (for example: "file:///c:/ddd.sxc")
'   ( --> use / not \ )

   Dim fileProperties(1) As New com.sun.star.beans.PropertyValue

   fileProperties(0).Name = "FilterName"
   fileProperties(0).Value = "scalc: Text - txt - csv (StarCalc)"
   fileProperties(1).Name = "FilterFlags"
   fileProperties(1).Value = "59/9,34,IBMPC_850,1,1/1/1/1/1/1/1/1"
                           '59/9 --> columns are devided by ";" and tab
                           '34   --> text delimiter --> double qoutes (")
                           ' IBMPC_850 --> charset (is a constant with the value 4)
                           '            0 is system charset   
   OpenCSVFile = StarDesktop.loadComponentFromURL(sUrl,"_blank", 0,fileProperties())
End Function


i used this function in OO1 as well but for OO2 i had to change something in the fileproperties...
you can now import the csv by using
Code:

   oDocCSV = OpenCSVFile([path as URL!])
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