[Calc] Import txt to new sheet

Creating a macro - Writing a Script - Using the API

[Calc] Import txt to new sheet

Postby Monte94 » Tue Jul 23, 2019 5:28 pm

Hi all,

I am trying to import .txt files in to LibreOffice Calc with a macro (later i want to calculate on those files a lot, cause those are measurment datas).
I have read the whole day and found lots of tutorials and topics, i can get the path of those files, choose single or multiple, etc. But my problem is that i cannot read the .txt files in the same doc to single sheets. I tried with the loadComponentFromURL(URL, TargetFrameName, SearchFlags, Arguments) function, but i couldn't set the right parameter for TargetFrameName. ("_blank" creates a new doc, "MyFrameName" ((or anything else)) writes over the actual sheet. :/ )
So i would like to import some .txt files to the same calc doc, everyone to a different sheet. I am sorry if a topic has existed yet, and i thank a lot for a useful link to an example or anything else too.
Thank you very much!
LibreOffice 6.0.7.3 on Ubuntu 18.04
Monte94
 
Posts: 1
Joined: Tue Jul 23, 2019 5:08 pm

Re: [Calc] Import txt to new sheet

Postby Villeroy » Tue Jul 23, 2019 5:59 pm

viewtopic.php?f=21&t=77069 is a template with macro. It has one cell named "Target" and several other options in named cells, for instance path, pattern and import options of text files. It inserts new cells before "pasting" data so all your calculation references and names should update accordingly.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27214
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests