Monday, April 29, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 3503  / 3 Years ago, mon, october 25, 2021, 2:20:37

I want to be able to easily show a simple text-only representation of a spreadsheet (Calc or Excel) via the command line (so I can pipe that output to usual Linux text manipulation tools). Is there a tool or quick way of accomplishing that?



Here's an example of how such output could look like:



A       B       C       D       E  
Sales Month
1000 Jan
5000 Feb
8000 Mar
2300 Total

More From » command-line

 Answers
6

You could use unoconv to transform the Calc sheet into csv. But unoconv seems to be quite instable, i didn't manage to get it working on a simple ods (calc) file.



A better choice is jodconverter. It's available in universe, so you can install it using apt. Jodconverter requires an instance of openoffice running and listening on port 8100.



To "manually" convert this sheet



sheet



from ods to csv:



$ soffice -headless -accept="socket,port=8100;urp;"
$ jodconverter Untitled1.ods Untitled1.csv


The resulting csv will look like this:



$ cat Untitled1.csv 
"A","B","C","D"
34,68,23,3
34234,68468,34,1
3423,6846,34,34535


If you don't need the table structure but just the contents for indexing purposes, take a look at odt2txt. It seems to be able to handle ods files, too, but it won't preserve the table structure. It doesn't require q soffice process running. With the sheet shown above, you will receive the following output:



$ odt2txt Untitled1.ods 

A

B

C

D

34

23

3

34234

3

34

1

3423

234

34

34535

[#38538] Monday, October 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sipwing

Total Points: 245
Total Questions: 100
Total Answers: 118

Location: Aland Islands
Member since Thu, Oct 22, 2020
4 Years ago
sipwing questions
Sun, May 29, 22, 22:00, 2 Years ago
Fri, Jun 24, 22, 08:46, 2 Years ago
Fri, Dec 23, 22, 00:04, 1 Year ago
;