foodcoop-adam / foodsoft

DEPRECATED, being merged in upstream. Web-based software for foodcoops - as used in NL.
http://foodcoop-adam.github.io/
Other
10 stars 3 forks source link

Using OpenOffice.org server for conversion #108

Closed wvengen closed 10 years ago

wvengen commented 10 years ago

It would be great to import multiple file formats easily. Also, we'd like to fill in spreadsheets sent by suppliers with order results, so that they're easy to work with for them. There are different gems to do so, but I've seen them borking on certain documents, and writing is often not perfect or absent.

Currently, sharedlists uses OpenOffice.org from the command-line for conversion of spreadsheets to CSV. Now, we're starting to fill in templates from suppliers using an OpenOffice.org macro. To avoid the latency of starting up the office suite, as well as to avoid problems with running multiple instances of OpenOffice.org at the same time, it would be best to start OpenOffice.org as a server (I guess, that's the same as running in UNO mode).

What needs to be done

wvengen commented 10 years ago

A simple StarofficeBASIC script (sorry!) to open, modify and save a spreadsheet is:

Sub UpdateCells(src, dst)
  ' open file
  doc = StarDesktop.loadComponentFromURL(ConvertToUrl(src), "_blank", 0, Array())
  ' update cells
  s = doc.getSheets().getByIndex(0)
  s.getCellByPosition(0, 0).setValue(123)
  ' write file
  doc.storeToURL(ConvertToUrl(dst), Array())
  doc.Close(True)
End Sub
wvengen commented 10 years ago

unoconv and the links mentioned there may be useful

bert1977 commented 10 years ago

Tried to install rubyuno as a gem, so we could manipulate office-files directly from ruby scripts, using UNO objects, using OpenOffice headless as a listener-process. But we ran into problems. Rubyuno requires the libreoffice-sdk and wants a libreoffice script for setting environment variables to be run prior to deployment (setsdkenv_unix.sh). Then another environment variable needs to be set manually. Several packages need to be deployed and variables need to be set in different places the system, making rubyuno as a solution not very portable across different systems. After all instructions were followed, building the gem failed on several occassions on various systems, for unclear reasons. We were thinking of forking rubyuno to add some scripts with educated guessing and make it more portable and make sure it compiled. But at this point it's yet more trouble than it's worth and for the time being we'll continue with the original solution: invoking OpenOffice to do the conversions and manipulation, with the inevitable huge use of processor/memory resources per operation.

wvengen commented 10 years ago

Thanks, @bert1977 for investigating. Closing for now.