c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #04992
[Bug 399278] Re: Implemented data export to OO Calc (code included)
** Changed in: openobject-client
Milestone: 6.0 => None
--
Implemented data export to OO Calc (code included)
https://bugs.launchpad.net/bugs/399278
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
Status in OpenObject GTK Client: Confirmed
Bug description:
Hi!
I've implemented data export to OpenOffice.org Calc and I share the code here, maybe others need this functionality, too. It does the same job as the 'Open in Excel' function for win32. This code was tested on Ubuntu 8.04 and 9.04.
The needed oootools.py is attached.
So replace this line: :)
common.message(_("Function only available for MS Office !\nSorry, OOo users :("))
with this:
try:
import subprocess
import time
retcode = subprocess.call(["soffice", "-accept=socket,host=localhost,port=2002;urp;", "-nodefault"], shell=False)
from oootools import OOoTools
for i in range(10):
ooo = OOoTools('localhost', 2002)
if ooo and ooo.desktop:
break
time.sleep(1)
doc = ooo.desktop.loadComponentFromURL("private:factory/scalc",'_blank',0,())
sheet = doc.CurrentController.ActiveSheet
for col in range(len(fields)):
cell = sheet.getCellByPosition(col, 0)
cell.String = fields[col]
cellrange = sheet.getCellRangeByPosition(0, 1, len(fields) - 1, len(result))
tresult = []
for i in range(len(result)):
tresult.append(tuple(result[i]))
tresult = tuple(tresult)
cellrange.setDataArray(tresult)
except:
common.error(_('Error Opening Excel !'),'')