Tentative de mettre un header en gras
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 27 Mar 2012 20:23:14 +0000 (15:23 -0500)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 27 Mar 2012 20:23:14 +0000 (15:23 -0500)
project/rh/masse_salariale.py
project/rh/ods.py

index 76fff6b..4d7decd 100644 (file)
@@ -527,6 +527,7 @@ class MasseSalariale():
             if len(h) > 2:
                 table.add_column(**h[2])
 
-        table.add_row([h[1] for h in self.headers], rowheight='2cm')
+        table.add_row([h[1] for h in self.headers], rowheight='2cm',
+                fontweight='bold')
 
         #a.doc.write('hello_world.ods')
index d5f24db..cbe2fce 100644 (file)
@@ -5,6 +5,10 @@ from decimal import Decimal
 import odf.opendocument
 import odf.style
 import odf.table
+from odf.style import Style, MasterPage, PageLayout, PageLayoutProperties, \
+        TextProperties, GraphicProperties, ParagraphProperties, DrawingPageProperties
+from odf.text import P
+
 
 
 class Wrapper(object):
@@ -56,10 +60,15 @@ class Table(Wrapper):
             kwargs['stylename'] = style.getAttribute('name')
             del kwargs['rowheight']
 
+        style = {}
+        if 'fontweight' in kwargs:
+            style['fontweight'] = kwargs['fontweight']
+            del kwargs['fontweight']
+
         row = TableRow(**kwargs)
         row._doc = self._doc
         for value in values:
-            row.add_cell(value, verticalalign='middle')
+            row.add_cell(value, verticalalign='middle', **style)
         self.addElement(row)
         return row
 
@@ -98,6 +107,21 @@ class TableRow(Wrapper):
             kwargs['stylename'] = style.getAttribute('name')
             del kwargs['verticalalign']
 
+        props = {}
+        if 'fontweight' in kwargs:
+            props['fontweight'] = kwargs.pop('fontweight')
+        if 'stringvalue' in kwargs:
+            props['stringvalue'] = kwargs.pop('stringvalue')
+
         cell = odf.table.TableCell(**kwargs)
+        if 'fontweight' in props:
+            tablecontents = Style(name="Bold", family="paragraph")
+            tablecontents.addElement(TextProperties(fontweight="bold"))
+            self._doc.styles.addElement(tablecontents)
+
+        if 'stringvalue' in props:
+            p = P(stylename='Bold',text=props['stringvalue'])
+            cell.addElement(p)
+
         self.addElement(cell)
         return cell