[Mpuls-commits] r4613 - base/trunk/mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Feb 11 17:52:37 CET 2011
Author: torsten
Date: 2011-02-11 17:52:36 +0100 (Fri, 11 Feb 2011)
New Revision: 4613
Modified:
base/trunk/mpulsweb/lib/export.py
Log:
* mpulsweb/lib/export.py: Added new Export classes to export a
formletter XLS.
Modified: base/trunk/mpulsweb/lib/export.py
===================================================================
--- base/trunk/mpulsweb/lib/export.py 2011-02-11 14:39:23 UTC (rev 4612)
+++ base/trunk/mpulsweb/lib/export.py 2011-02-11 16:52:36 UTC (rev 4613)
@@ -277,7 +277,41 @@
finally:
out.real_close()
+#
+# Formletter Export
+#
+class FormletterXLSTable(XLSTable):
+ def encode(self, value):
+ if value is None:
+ return ""
+ if isinstance(value, basestring) and len(value) > 32765:
+ value = value[:32765]
+ if not isinstance(value, basestring):
+ return str(value)
+ return value
+
+class FormletterExport(Export):
+
+ def __init__(self, data):
+ self.data = data
+ self.xls = FormletterXLSTable('formletter', data[0].keys())
+
+ def export(self):
+ for row in self.data:
+ self.xls.append(row)
+ try:
+ out = MyStringIO()
+ self.write_xls(out)
+ return out.getvalue()
+ finally:
+ out.real_close()
+
+ def write_xls(self, output):
+ workbook = pyExcelerator.Workbook()
+ self.xls.add_to_workbook(workbook)
+ workbook.save(FakeStr(output))
+
#
# CSV Export
#
More information about the Mpuls-commits
mailing list