Masse salariale, avec un peu de formattage pour le heading
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 27 Mar 2012 15:28:35 +0000 (10:28 -0500)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 27 Mar 2012 15:28:35 +0000 (10:28 -0500)
project/rh/masse_salariale.py
project/rh/ods.py

index 2d5f35b..51c1faf 100644 (file)
@@ -529,6 +529,6 @@ class MasseSalariale():
             if len(h) > 2:
                 table.add_column(**h[2])
 
-        table.add_row([h[1] for h in self.headers], rowheight='2cm', verticalalign='middle')
-
+        table.add_row([h[1] for h in self.headers], rowheight='2cm')
 
+        #a.doc.write('hello_world.ods')
index eb84a37..d5f24db 100644 (file)
@@ -44,28 +44,22 @@ class Table(Wrapper):
 
     def add_row(self, values=[], **kwargs):
          # attributs appartenant à table-column-poperties
-        props = {}
-        for attr in ['rowheight']:
-            if attr in kwargs:
-                props[attr] = kwargs.pop(attr)
+#        props = {}
+#        for attr in ['rowheight']:
+#            if attr in kwargs:
+#                props[attr] = kwargs.pop(attr)
 
-        style = self._doc.add_automatic_style()
+        style = self._doc.add_automatic_style(family='table-row')
         if 'rowheight' in kwargs:
             style.addElement(odf.style.TableRowProperties(
                 rowheight=kwargs['rowheight']))
             kwargs['stylename'] = style.getAttribute('name')
             del kwargs['rowheight']
 
-        if 'verticalalign' in kwargs:
-            style.addElement(odf.style.TableCellProperties(
-                verticalalign=kwargs['verticalalign']))
-            kwargs['stylename'] = style.getAttribute('name')
-            del kwargs['verticalalign']
-
-
         row = TableRow(**kwargs)
+        row._doc = self._doc
         for value in values:
-            row.add_cell(value)
+            row.add_cell(value, verticalalign='middle')
         self.addElement(row)
         return row
 
@@ -96,6 +90,14 @@ class TableRow(Wrapper):
             elif isinstance(value, (int, float, Decimal)):
                 kwargs['valuetype'] = 'float'
                 kwargs['value'] = float(value)
+
+        if 'verticalalign' in kwargs:
+            style = self._doc.add_automatic_style(family='table-cell')
+            style.addElement(odf.style.TableCellProperties(
+                verticalalign=kwargs['verticalalign']))
+            kwargs['stylename'] = style.getAttribute('name')
+            del kwargs['verticalalign']
+
         cell = odf.table.TableCell(**kwargs)
         self.addElement(cell)
         return cell