[Calc] Import txt to new sheet

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Monte94
Posts: 1
Joined: Tue Jul 23, 2019 5:08 pm

[Calc] Import txt to new sheet

Post by Monte94 »

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
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Calc] Import txt to new sheet

Post by Villeroy »

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 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply