5

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
1
  • Does it have to open .ods? There is this, link but I've never used it. May 11, 2012 at 2:17

2 Answers 2

2

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
1
  • I has hoping to be able to show it as tabular data _directly (without an intermediate .csv), but there's probably no tool for that. Thanks for the answer!
    – user62521
    May 12, 2012 at 15:40
0

Sure. It's called, save as CSV and use cat.

You must log in to answer this question.