Linux excel convert to

Unix command to convert xls file into xlsx file? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I there any unix command which will convert xls file into xlsx file? Also i have tried using mv command, it is changing the extension as well. But then i am not able to open the xlsx file.

Same question on the appropriate SE site with more answers: unix.stackexchange.com/questions/354043/…

1 Answer 1

As far as I know, this is not something you can easily do with standard unix tools.

libreoffice --convert-to xlsx my.xls --headless 

Or maybe find an online converter and submit your file to it.

@HussainShabbir You don’t have LibreOffice installed. You can try installing it, or look for other ways, of which I am not aware.

I try to do this, but nothing happens, not even an error message. Any ideas what’s the matter? This is using version LibreOffice 4.0.4.2

@Nick Are you sure the file is not created? (although on my system with 4.3.5.2.0 I see a message when the conversion is finished)

@LevLevitsky I followed advice at diegolamonica.info/… and found that fixed it; I had only installed the libreoffice-headless and required packages, but not the calc package. But it didn’t give any error message or return code, which wasn’t too helpful! 🙂

Источник

How to convert xlsx files to xls or csv format on Linux

The xlsx file name extension is a new file format based on XML, first used by Microsoft Office Excel 2007 spreadsheet application. The letter x appended to the existing xls extension used by earlier versions of Excel, signifies that the format is based on XML. If you would like to open or edit an xlsx file created by Excel 2007 or later, on an earlier version of Excel or any other spreadsheet application, you need to convert xlsx files first.

There are four different ways you can convert xlsx files on Linux.

Method One: Gnumeric

The first method is to use Gnumeric. Gnumeric is a free spreadsheet program which can import or export data in different file formats such as csv , xls and xlsx . Gnumeric comes with a command-line utility called ssconvert which can convert between different spreadsheet file formats. In order to convert xls files to xlsx or csv format by using Gnumeric, first install Gnumeric. Once Gnumeric is installed, you can use ssconvert .

$ sudo apt-get install gnumeric

Note that ssconvert accepts arguments in the following format.

$ ssconvert --export-type=ID [input file] [output file]

In the above, —export-type is optional, and without —export-type , ssconvert can infer export type from the extension of output file. If you want to explicitly specify export type, ID can be one of the following.

  • Gnumeric_Excel:excel_dsf : Microsoft Excel 97/2000/XP, 5.0/95 format
  • Gnumeric_Excel:xlsx : Microsoft Excel 2007
  • Gnumeric_pdf:pdf_assistant : Portable Document Format (PDF)
  • Gnumeric_stf:stf_csv: Comma Separated Values (CSV)
Читайте также:  Устройство не готово linux

So if you would like to convert xlsx files to csv format using ssconvert :

$ ssconvert input.xlsx output.csv $ ssconvert --export-type=Gnumeric_stf:stf_csv input.xls output.txt

Method Two: xlsx2csv

The drawback of the Gnumeric-based method is that you need to install Gnumeric which may be too bloated software to install just for file conversion. A more lightweight way is to use xlsx2csv which is a python tool for xlsx to csv conversion.

$ git clone https://github.com/dilshod/xlsx2csv.git $ cd xlsx2csv $ ./xlsx2csv.py input.xlsx output.csv

Method Three: OpenOffice

Besides these methods, you can also use OpenOffice (if you already have it installed) to perform xlsx format conversions. OpenOffice comes with a command-line utility called unoconv which can convert xlsx files.

If you do not have it installed, you can install it with:

$ sudo apt-get install unoconv $ unoconv -f csv input.xlsx

Note that once you install unoconv using apt-get , it will install OpenOffice package as well.

Method Four: Google Docs

The final method of converting xlsx files is to use Google Spreadsheets. Google Spreadsheets can import Excel 2007 files. Thus, all you have to do is to import your xlsx file on to Google Docs Spreadsheet, click on Download as menu, and choose an appropriate file format: Excel ( xls ), PDF, CSV, Text. Note that document files which can be uploaded to Google Docs for conversion cannot be larger than 2MB .

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Источник

Convert Excel to CSV Command Line Linux: Methods and Commands

Learn efficient and easy-to-use methods and commands to convert Excel files to CSV format on Linux command line. Includes Gnumeric, Libreoffice, csvkit, xlsx2csv, Cygwin, and PowerShell.

  • Converting xlsx to csv using Gnumeric Spreadsheet Program
  • Other methods for Excel to CSV conversion on Linux command line
  • Convert XLS to CSV on command line
  • Converting specific sheets of xlsx file to csv on LibreOffice command line
  • Excel to CSV conversion using PowerShell and SaveAs() method
  • Other simple code samples for converting Excel to CSV on Linux command line
  • Conclusion
  • How do I convert Excel to CSV in Linux?
  • How to convert Excel to CSV in command line?
  • How to convert Excel to CSV programmatically?
  • How to convert XLSX file to CSV in PowerShell?

Excel files are widely used for data storage and analysis, but sometimes it is necessary to convert them to CSV format for compatibility with other applications or for data processing purposes. converting excel files to csv format on Linux command line can be done using several methods and commands that are efficient and easy to use. In this blog post, we will discuss various methods and commands to convert excel files to csv format on Linux command line.

Читайте также:  Arch linux install docker compose

Gnumeric is a powerful spreadsheet program that can be installed via apt-get command on Linux. The ssconvert command in Gnumeric can be used to convert xlsx files to csv format. This command is useful in situations where you need to convert multiple Excel files to CSV format simultaneously.

To convert an xlsx file to CSV format using Gnumeric Spreadsheet Program, follow these steps:

sudo apt-get install gnumeric 
  1. Once Gnumeric is installed, navigate to the directory where the xlsx file is located.
  2. Type the following command to convert the xlsx file to CSV format:
ssconvert input.xlsx output.csv 

This command will convert the input.xlsx file to output.csv file in the same directory.

Other methods for Excel to CSV conversion on Linux command line

Apart from Gnumeric Spreadsheet Program, there are other methods and tools available for Excel to CSV conversion on Linux command line.

Cygwin

Cygwin is a tool that allows you to run Windows programs on Linux. It includes a command line tool ‘xls2csv’ for Excel to CSV conversion. To use this tool, you need to have Cygwin installed on your Linux system.

To convert an xlsx file to CSV format using Cygwin, follow these steps:

  1. Install Cygwin on your Linux system.
  2. Open the Cygwin terminal and navigate to the directory where the xlsx file is located.
  3. Type the following command to convert the xlsx file to CSV format:
xls2csv -x input.xlsx -c output.csv 

This command will convert the input.xlsx file to output.csv file in the same directory.

Libreoffice

Libreoffice is a popular open-source office suite that has a built-in feature to convert xlsx files to csv format using the command line. To use this feature, you need to have Libreoffice installed on your Linux system.

To convert an xlsx file to CSV format using Libreoffice, follow these steps:

sudo apt-get install libreoffice 
  1. Once Libreoffice is installed, navigate to the directory where the xlsx file is located.
  2. Type the following command to convert the xlsx file to CSV format:
libreoffice --convert-to csv:"Text - txt - csv (StarCalc)" --infilter="Microsoft Excel 2007/2010/2013 XML" input.xlsx 

This command will convert the input.xlsx file to output.csv file in the same directory.

Csvkit

Csvkit is a suite of command line tools for working with CSV files on Linux. It includes a tool ‘in2csv’ for Excel to CSV conversion. To use this tool, you need to have Csvkit installed on your Linux system.

To convert an xlsx file to CSV format using Csvkit, follow these steps:

sudo apt-get install csvkit 
  1. Once Csvkit is installed, navigate to the directory where the xlsx file is located.
  2. Type the following command to convert the xlsx file to CSV format:
in2csv input.xlsx > output.csv 

This command will convert the input.xlsx file to output.csv file in the same directory.

Xlsx2csv

Xlsx2csv is a Python script that can be used to convert xlsx files to csv format on Linux command line. To use this script, you need to have Python installed on your Linux system.

Читайте также:  How to apply patch linux

To convert an xlsx file to CSV format using Xlsx2csv, follow these steps:

sudo pip install xlsx2csv 
  1. Once Xlsx2csv is installed, navigate to the directory where the xlsx file is located.
  2. Type the following command to convert the xlsx file to CSV format:
xlsx2csv input.xlsx output.csv 

This command will convert the input.xlsx file to output.csv file in the same directory.

Convert XLS to CSV on command line

Convert XLS to CSV on command line [ Gift : Animated Search Engine : https://www.hows.tech Duration: 1:16

Converting specific sheets of xlsx file to csv on LibreOffice command line

Sometimes, you may need to convert only specific sheets of an xlsx file to CSV format. Libreoffice command ‘–convert-to csv:»Text — txt — csv (StarCalc)»’ can be used to achieve this. To use this command, you need to have Libreoffice installed on your Linux system.

To convert specific sheets of an xlsx file to CSV format using Libreoffice command line, follow these steps:

  1. Navigate to the directory where the xlsx file is located.
  2. Type the following command to convert specific sheets of the xlsx file to CSV format:
libreoffice --convert-to csv:"Text - txt - csv (StarCalc)" --infilter="Microsoft Excel 2007/2010/2013 XML" input.xlsx --outdir=output_dir 

In this command, replace ‘input.xlsx’ with the name of the xlsx file that you want to convert, and ’output_dir’ with the directory where you want to save the converted files. This command will convert only the sheets that you have specified to CSV format.

Excel to CSV conversion using PowerShell and SaveAs() method

PowerShell is a command line shell and scripting language developed by Microsoft for Windows and Linux. The SaveAs() method in PowerShell can be used to convert Excel files to CSV format.

To convert an xlsx file to CSV format using PowerShell and SaveAs() method, follow these steps:

sudo apt-get install powershell 
  1. Once PowerShell is installed, navigate to the directory where the xlsx file is located.
  2. Type the following command to convert the xlsx file to CSV format:
$Excel = New-Object -ComObject Excel.Application; $Workbook = $Excel.Workbooks.Open("input.xlsx"); $Workbook.SaveAs("output.csv", 6); $Excel.Quit(); 

This command will convert the input.xlsx file to output.csv file in the same directory.

Other simple code samples for converting Excel to CSV on Linux command line

In Shell , in particular, convert excel to csv command line linux code example

$ ssconvert Book1.xlsx newfile.csv Using exporter Gnumeric_stf:stf_csv$ cat newfile.csv Foo,Bar,Baz 1,2,3 123.6,7.89, 2012/05/14,, The,last,Line 

In Shell , for instance, convert excel to csv command line linux code example

libreoffice --headless --convert-to csv $filename --outdir $outdir 

Conclusion

Converting Excel files to CSV format on Linux command line is an essential task for data processing and compatibility purposes. Several methods and commands are available for Excel to CSV conversion, including Gnumeric Spreadsheet Program, Cygwin, Libreoffice, csvkit, xlsx2csv, and PowerShell. Each method has its advantages and disadvantages, and best practices should be followed to ensure the accuracy and reliability of the converted files. With the methods and tools discussed in this blog post, you can easily convert Excel files to CSV format on Linux command line.

Источник

Оцените статью
Adblock
detector