Ask Your Question
0

I want to import a text file into Calc and have it appear in the same page format that I see when I open it in Writer.

asked 2021-04-17 10:40:06 +0200

t5404tmz gravatar image

updated 2021-04-17 12:23:52 +0200

ajlittoz gravatar image

So I want 80 characters per row in a single column.

I want to take advantage of the Data Grouping function in Calc, which will allow me to click a twisty to hide or reveal rows of data, which in my case will be paragraphs.

I found the following code online. Can I modify this for my purposes? And what kind of code is it? How would I execute it? Sorry for being so helpless. And I had to add newlines in my post to prevent the code from bunching up. I'm new to this forum, so I don't know all the nuances.

An example of a CSV going into one column, multiple rows (but note complete lack of error handling):

Sub Example()
Dim i
Dim sTemp As String
i = FreeFile
Open "C:\MyFile.txt" For Input As #i
n = 0
Do While Not EOF(i)
Input #i, sTemp
ActiveCell.Offset(n, 0) = sTemp
n = n + 1
Loop
Close #i
End Sub

[Edit Opaque] put code to preformatted text

[Edit ajlittoz] removed extra blank lines in code

edit retag flag offensive close merge delete

Comments

You can hide sections in Writer, see Help

Earnest Al gravatar imageEarnest Al ( 2021-04-18 08:36:04 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2021-04-18 08:54:23 +0200

t5404tmz gravatar image

I couldn't figure out how to import the text file into a single column, but I did find a sed command that inserts a newline every 80 characters, and that imports sufficiently. Thanks for providing this forum!

Here is the sed command: sed -e "s/.{80}/&\n/g"

edit flag offensive delete link more
0

answered 2021-04-18 15:46:55 +0200

LeroyG gravatar image

You can export the text file as PDF, open the PDF, select all, copy and paste in Calc.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-04-17 10:40:06 +0200

Seen: 61 times

Last updated: Apr 18