Question

I need to automate the opening of excel files and saving them as csv files to be consumed by a ruby app. The csv files must be in UTF-8 encoding so that there will be no problems reading from them on a UNIX computer.

I have adone this manually by opening them with open office on a mac and saving as csv. then uploading this to my rails app. But Id like to have this process automated and I was wondering where I can start to look for this .

Ive looked here but dont really see many helpful details to start.

https://wiki.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Getting_Started/Starting_from_the_command_line

Was it helpful?

Solution

The command line is /opt/libreoffice4.1/program/soffice.bin -headless -convert-to csv /path/to/your/file.xlsx

You'll need to update the path for libreoffice if you use a different version (the version is in the path above). You can put this into your Rails app by using

system("/opt/libreoffice4.1/program/soffice.bin --headless --convert-to csv /path/to/your/file.xlsx")

This will create a CSV file in the same directory as the original xlsx file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top