def setUp(self):
     row = odf_create_row(width=2, repeated=3, style=u"ro1")
     # Add repeated cell
     row.append_element(odf_create_cell(1, repeated=2))
     # Add regular cell
     row.append_element(odf_create_cell(style=u"ce1"))
     self.row = row
Example #2
0
def create_table(labels, results):

    document = odf_new_document('spreadsheet')
    body = document.get_body()
    table = odf_create_table("results")

    row = odf_create_row()
    rnbr = 1
    for lang in sorted(results):
        cell = odf_create_cell()
        cell.set_value(lang, text=lang)
        row.set_cell(rnbr, cell)
        rnbr += 1
    table.set_row(0, row)

    lnbr = 1

    for i in range(len(labels)):
        row = odf_create_row()
        cell = odf_create_cell()
        cell.set_value(labels[i], text=labels[i])
        row.set_cell(0, cell)
        rnbr = 1
        for lang in sorted(results):
            cell = odf_create_cell()
            val = results[lang][i]
            cell.set_value(val, text="%.5f" % val, cell_type="float")
            row.set_cell(rnbr, cell)
            rnbr += 1
        table.set_row(lnbr, row)
        lnbr += 1

    body.append(table)
    document.save(target="__res2.ods", pretty=True)
Example #3
0
 def setUp(self):
     row = odf_create_row(width=2, repeated=3, style=u"ro1")
     # Add repeated cell
     row.append(odf_create_cell(1, repeated=2))
     # Add regular cell
     row.append(odf_create_cell(style=u"ce1"))
     self.row = row
 def test_append_cell(self):
     row = self.row.clone()
     row.append_cell(odf_create_cell(u"Appended"))
     self.assertEqual(row.get_cell_values(),
             [1, 1, 1, 2, 3, 3, 3, u"Appended"])
     # Test repetitions are synchronized
     self.assertEqual(row.get_row_width(), 8)
 def test_bool_repr(self):
     cell = odf_create_cell(True, text=u"VRAI")
     expected = ('<table:table-cell office:value-type="boolean" '
                   'office:boolean-value="true">'
                   '<text:p>VRAI</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #6
0
 def test_currency(self):
     cell = odf_create_cell(1.54, cell_type='currency', currency='EUR')
     expected = ('<table:table-cell office:value-type="currency" '
                 'office:value="1.54" office:currency="EUR">'
                 '<text:p>1.54</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #7
0
 def test_percentage_repr(self):
     cell = odf_create_cell(90, text=u"90 %", cell_type='percentage')
     expected = ('<table:table-cell office:value-type="percentage" '
                 'office:value="90">'
                 '<text:p>90 %</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #8
0
 def test_timedelta_repr(self):
     cell = odf_create_cell(timedelta(0, 8), text=u"00:00:08")
     expected = ('<table:table-cell office:value-type="time" '
                 'office:time-value="PT00H00M08S">'
                 '<text:p>00:00:08</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #9
0
 def test_unicode_repr(self):
     cell = odf_create_cell(u"Plato", text=u"P.")
     expected = ('<table:table-cell office:value-type="string" '
                 'office:string-value="Plato">'
                 '<text:p>P.</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #10
0
 def test_str_repr(self):
     cell = odf_create_cell('red', text=u"Red")
     expected = ('<table:table-cell office:value-type="string" '
                 'office:string-value="red">'
                 '<text:p>Red</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #11
0
 def test_datetime(self):
     cell = odf_create_cell(datetime(2009, 6, 30, 17, 33, 18))
     expected = ('<table:table-cell office:value-type="date" '
                 'office:date-value="2009-06-30T17:33:18">'
                 '<text:p>2009-06-30T17:33:18</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #12
0
 def test_date_repr(self):
     cell = odf_create_cell(date(2009, 6, 30), text=u"30/6/2009")
     expected = ('<table:table-cell office:value-type="date" '
                 'office:date-value="2009-06-30">'
                 '<text:p>30/6/2009</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #13
0
 def test_decimal_repr(self):
     cell = odf_create_cell(dec('2.718281828'), text=u"2,72")
     expected = ('<table:table-cell office:value-type="float" '
                 'office:value="2.718281828">'
                 '<text:p>2,72</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #14
0
 def test_insert_cell(self):
     row = self.row.clone()
     row.insert_cell(3, odf_create_cell(u"Inserted"))
     self.assertEqual(row.get_width(), 8)
     self.assertEqual(row.get_values(), [1, 1, 1, u"Inserted", 2, 3, 3, 3])
     # Test repetitions are synchronized
     self.assertEqual(row.get_width(), 8)
 def test_date_repr(self):
     cell = odf_create_cell(date(2009, 6, 30), text=u"30/6/2009")
     expected = ('<table:table-cell office:value-type="date" '
                   'office:date-value="2009-06-30">'
                   '<text:p>30/6/2009</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_float_repr(self):
     cell = odf_create_cell(3.141592654, text=u"3,14")
     expected = ('<table:table-cell office:value-type="float" '
                   'office:value="3.141592654">'
                   '<text:p>3,14</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #17
0
 def test_int_repr(self):
     cell = odf_create_cell(23, text=u"00023")
     expected = ('<table:table-cell office:value-type="float" '
                 'office:value="23">'
                 '<text:p>00023</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_decimal_repr(self):
     cell = odf_create_cell(dec('2.718281828'), text=u"2,72")
     expected = ('<table:table-cell office:value-type="float" '
                   'office:value="2.718281828">'
                   '<text:p>2,72</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #19
0
 def test_bool_repr(self):
     cell = odf_create_cell(True, text=u"VRAI")
     expected = ('<table:table-cell office:value-type="boolean" '
                 'office:boolean-value="true">'
                 '<text:p>VRAI</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_datetime(self):
     cell = odf_create_cell(datetime(2009, 6, 30, 17, 33, 18))
     expected = ('<table:table-cell office:value-type="date" '
             'office:date-value="2009-06-30T17:33:18">'
                   '<text:p>2009-06-30T17:33:18</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_int_repr(self):
     cell = odf_create_cell(23, text=u"00023")
     expected = ('<table:table-cell office:value-type="float" '
                   'office:value="23">'
                   '<text:p>00023</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_currency(self):
     cell = odf_create_cell(1.54, cell_type='currency', currency='EUR')
     expected = ('<table:table-cell office:value-type="currency" '
                   'office:value="1.54" office:currency="EUR">'
                   '<text:p>1.54</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #23
0
 def test_float_repr(self):
     cell = odf_create_cell(3.141592654, text=u"3,14")
     expected = ('<table:table-cell office:value-type="float" '
                 'office:value="3.141592654">'
                 '<text:p>3,14</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_timedelta_repr(self):
     cell = odf_create_cell(timedelta(0, 8), text=u"00:00:08")
     expected = ('<table:table-cell office:value-type="time" '
                   'office:time-value="PT00H00M08S">'
                   '<text:p>00:00:08</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_unicode_repr(self):
     cell = odf_create_cell(u"Plato", text=u"P.")
     expected = ('<table:table-cell office:value-type="string" '
                   'office:string-value="Plato">'
                   '<text:p>P.</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_insert_cell_repeat_repeat(self):
     row = self.row_repeats.clone()
     row.insert_cell(6, odf_create_cell(u"Inserted", repeated=3))
     self.assertEqual(row.get_cell_values(),
             [1, 1, 1, 2, 3, 3, u"Inserted", u"Inserted", u"Inserted", 3])
     # Test repetitions are synchronized
     self.assertEqual(row.get_row_width(), 10)
 def test_str_repr(self):
     cell = odf_create_cell('red', text=u"Red")
     expected = ('<table:table-cell office:value-type="string" '
                   'office:string-value="red">'
                   '<text:p>Red</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #28
0
def createTable(csv_path, table):
    csv_file = open(csv_path, 'r')
    lnbr = 0
    while 1:
        line = csv_file.readline()
        if line == "":
            break
        #lnbr = lnbr + 1
        row = odf_create_row()
        vals = line.split(",")
        rnbr = 0
        for val in vals:
            cell = odf_create_cell()
            if lnbr < 2 or rnbr < 1:
                #table.set_value((rnbr, lnbr), val)
                cell.set_value(val, text=val)
            else:
                #table.set_value((rnbr, lnbr), float(val))
                cell.set_value(float(val),
                               text="%.5f" % float(val),
                               cell_type="float")
            row.set_cell(rnbr, cell)
            rnbr = rnbr + 1
        table.set_row(lnbr, row)
        lnbr = lnbr + 1
 def test_percentage_repr(self):
     cell = odf_create_cell(90, text=u"90 %", cell_type='percentage')
     expected = ('<table:table-cell office:value-type="percentage" '
                   'office:value="90">'
                   '<text:p>90 %</text:p>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #30
0
 def test_rstrip(self):
     row = odf_create_row(width=100)
     row.set_value(0, 1)
     row.set_value(1, 2)
     row.set_value(2, 3)
     row.set_cell(3, odf_create_cell(style=u"ce1"))
     row.rstrip()
     self.assertEqual(row.get_width(), 4)
 def test_rstrip(self):
     row = odf_create_row(width=100)
     row.set_cell_value(0, 1)
     row.set_cell_value(1, 2)
     row.set_cell_value(2, 3)
     row.set_cell(3, odf_create_cell(style=u"ce1"))
     row.rstrip_row()
     self.assertEqual(row.get_row_width(), 4)
 def test_insert_cell(self):
     row = self.row.clone()
     row.insert_cell(3, odf_create_cell(u"Inserted"))
     self.assertEqual(row.get_row_width(), 8)
     self.assertEqual(row.get_cell_values(),
             [1, 1, 1, u"Inserted", 2, 3, 3, 3])
     # Test repetitions are synchronized
     self.assertEqual(row.get_row_width(), 8)
Example #33
0
 def test_insert_cell_repeat_repeat(self):
     row = self.row_repeats.clone()
     row.insert_cell(6, odf_create_cell(u"Inserted", repeated=3))
     self.assertEqual(
         row.get_values(),
         [1, 1, 1, 2, 3, 3, u"Inserted", u"Inserted", u"Inserted", 3])
     # Test repetitions are synchronized
     self.assertEqual(row.get_width(), 10)
Example #34
0
 def test_insert_cell(self):
     table = self.table.clone()
     table.insert_cell('B3', odf_create_cell(u"Inserted"))
     self.assertEqual(
         table.get_values(),
         [[1, 1, 1, 2, 3, 3, 3, None], [1, 1, 1, 2, 3, 3, 3, None],
          [1, u"Inserted", 1, 1, 2, 3, 3, 3], [1, 2, 3, 4, 5, 6, 7, None]])
     # Test columns are synchronized
     self.assertEqual(table.get_width(), 8)
Example #35
0
 def test_append_cell(self):
     table = self.table.clone()
     table.append_cell(1, odf_create_cell(u"Appended"))
     self.assertEqual(
         table.get_values(),
         [[1, 1, 1, 2, 3, 3, 3, None], [1, 1, 1, 2, 3, 3, 3, u"Appended"],
          [1, 1, 1, 2, 3, 3, 3, None], [1, 2, 3, 4, 5, 6, 7, None]])
     # Test columns are synchronized
     self.assertEqual(table.get_width(), 8)
 def test_append_cell(self):
     table = self.table.clone()
     table.append_cell(1, odf_create_cell(u"Appended"))
     self.assertEqual(table.get_table_values(),
             [[1, 1, 1, 2, 3, 3, 3, None],
              [1, 1, 1, 2, 3, 3, 3, u"Appended"],
              [1, 1, 1, 2, 3, 3, 3, None],
              [1, 2, 3, 4, 5, 6, 7, None]])
     # Test columns are synchronized
     self.assertEqual(table.get_table_width(), 8)
 def test_insert_cell(self):
     table = self.table.clone()
     table.insert_cell('B3', odf_create_cell(u"Inserted"))
     self.assertEqual(table.get_table_values(),
             [[1, 1, 1, 2, 3, 3, 3, None],
              [1, 1, 1, 2, 3, 3, 3, None],
              [1, u"Inserted", 1, 1, 2, 3, 3, 3],
              [1, 2, 3, 4, 5, 6, 7, None]])
     # Test columns are synchronized
     self.assertEqual(table.get_table_width(), 8)
Example #38
0
 def test_with_cell(self):
     cell = odf_create_cell(42)
     set_value(cell, '你好 Zoé')
     expected = ('<table:table-cell office:value-type="string" '
                   'office:string-value="%s">'
                   '<text:p>'
                     '%s'
                   '</text:p>'
                 '</table:table-cell>') % (
                             (convert_unicode('你好 Zoé'),) * 2)
     self.assertEqual(cell.serialize(), expected)
Example #39
0
 def test_attach_chart_to_cell(self):
     cell = odf_create_cell()
     cell = attach_chart_to_cell('Object', cell)
     expected=('<table:table-cell>'
                 '<draw:frame svg:width="10cm" svg:height="10cm" '
                   'draw:z-index="0">'
                   '<draw:object xlink:href="./Object" xlink:type="simple" '
                     'xlink:show="embed" xlink:actuate="onLoad"/>'
                 '</draw:frame>'
               '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
 def test_with_cell(self):
     cell = odf_create_cell(42)
     set_value(cell, u'你好 Zoé')
     expected = ('<table:table-cell office:value-type="string" '
                   'office:string-value="%s">'
                   '<text:p>'
                     '%s'
                   '</text:p>'
                 '</table:table-cell>') % (
                             (convert_unicode(u'你好 Zoé'),) * 2)
     self.assertEqual(cell.serialize(), expected)
Example #41
0
 def test_attach_chart_to_cell(self):
     cell = odf_create_cell()
     cell = attach_chart_to_cell('Object', cell)
     expected = ('<table:table-cell>'
                 '<draw:frame svg:width="10cm" svg:height="10cm" '
                 'draw:z-index="0">'
                 '<draw:object xlink:href="./Object" xlink:type="simple" '
                 'xlink:show="embed" xlink:actuate="onLoad"/>'
                 '</draw:frame>'
                 '</table:table-cell>')
     self.assertEqual(cell.serialize(), expected)
Example #42
0
 def GET(self, resource, context):
     if lpod_is_install is False:
         msg = ERROR(u'Please install LPOD')
         return context.come_back(msg)
     document = odf_new_document_from_type('text')
     body = document.get_body()
     root = context.root
     table = odf_create_table(u"Table 1",
                              width=5,
                              height=1,
                              style='table-cell')
     for brain in root.search(format='product').get_documents():
         # Get product
         product = root.get_resource(brain.abspath)
         cover = product.get_resource(product.get_property('cover'))
         # Add line
         row = odf_create_row(width=5)
         cell = odf_create_cell(u"")
         file = context.database.fs.open(cover.handler.key)
         local_uri = document.add_file(file)
         image_frame = odf_create_image_frame(local_uri,
                                              size=('5cm', '5cm'),
                                              position=('0cm', '0cm'),
                                              anchor_type='as-char')
         paragraph = cell.get_element('text:p')
         paragraph.append(image_frame)
         cell.append(paragraph)
         row.set_cell(0, cell)
         row.set_cell_value(1, brain.reference)
         row.set_cell_value(2, brain.title)
         row.set_cell_value(3, u'%s' % product.get_price_without_tax())
         table.append_row(row)
         # Get declinations
         for d in product.search_resources(cls=Declination):
             price = d.parent.get_price_without_tax(id_declination=d.name,
                                                    pretty=True)
             row = odf_create_row(width=5)
             row.set_cell_value(1, 'reference')
             row.set_cell_value(2, d.get_declination_title())
             row.set_cell_value(3, u'%s' % price)
             row.set_cell_value(4, d.get_property('stock-quantity'))
             table.append(row)
     body.append(table)
     f = StringIO()
     document.save(f)
     content = f.getvalue()
     f.close()
     context.set_content_type('application/vnd.oasis.opendocument.text')
     context.set_content_disposition('attachment', 'export.odt')
     return content
Example #43
0
 def GET(self, resource, context):
     if lpod_is_install is False:
         msg = ERROR(u'Please install LPOD')
         return context.come_back(msg)
     document = odf_new_document_from_type('text')
     body = document.get_body()
     root = context.root
     table = odf_create_table(u"Table 1", width=5, height=1, style='table-cell')
     for brain in root.search(format='product').get_documents():
         # Get product
         product = root.get_resource(brain.abspath)
         cover = product.get_resource(product.get_property('cover'))
         # Add line
         row = odf_create_row(width=5)
         cell = odf_create_cell(u"")
         file = context.database.fs.open(cover.handler.key)
         local_uri = document.add_file(file)
         image_frame = odf_create_image_frame(local_uri, size=('5cm', '5cm'),
             position=('0cm', '0cm'), anchor_type='as-char')
         paragraph = cell.get_element('text:p')
         paragraph.append(image_frame)
         cell.append(paragraph)
         row.set_cell(0, cell)
         row.set_cell_value(1, brain.reference)
         row.set_cell_value(2, brain.title)
         row.set_cell_value(3, u'%s' % product.get_price_without_tax())
         table.append_row(row)
         # Get declinations
         for d in product.search_resources(cls=Declination):
             price = d.parent.get_price_without_tax(id_declination=d.name, pretty=True)
             row = odf_create_row(width=5)
             row.set_cell_value(1, 'reference')
             row.set_cell_value(2, d.get_declination_title())
             row.set_cell_value(3, u'%s' % price)
             row.set_cell_value(4, d.get_property('stock-quantity'))
             table.append(row)
     body.append(table)
     f = StringIO()
     document.save(f)
     content = f.getvalue()
     f.close()
     context.set_content_type('application/vnd.oasis.opendocument.text')
     context.set_content_disposition('attachment', 'export.odt')
     return content
Example #44
0
def _convert_table_rows(container, node, context, cell_style=None):
    for row in node:
        if row.tagname != "row":
            warn('node "%s" not supported in thead/tbody' % row.tagname)
            continue

        odf_row = odf_create_row()
        container.append_element(odf_row)

        for entry in row:
            if entry.tagname != "entry":
                warn('node "%s" not supported in row' % entry.tagname)
                continue

            # Create a new odf_cell
            odf_cell = odf_create_cell(cell_type="string", style=cell_style)
            odf_row.append_element(odf_cell)

            # XXX We don't add table:covered-table-cell !
            #     It's bad but OO can nevertheless load the file
            morecols = entry.get("morecols")
            if morecols is not None:
                morecols = int(morecols) + 1
                odf_cell.set_attribute('table:number-columns-spanned',
                                       str(morecols))
            morerows = entry.get("morerows")
            if morerows is not None:
                morerows = int(morerows) + 1
                odf_cell.set_attribute('table:number-rows-spanned',
                                       str(morerows))

            # Save the current top
            old_top = context["top"]

            # Convert
            context["top"] = odf_cell
            for child in entry:
                convert_node(child, context)

            # And restore the top
            context["top"] = old_top
Example #45
0
 def setUp(self):
     self.cell = odf_create_cell(1, repeated=3, style=u"ce1")
Example #46
0
 def test_append_cell(self):
     row = self.row.clone()
     row.append_cell(odf_create_cell(u"Appended"))
     self.assertEqual(row.get_values(), [1, 1, 1, 2, 3, 3, 3, u"Appended"])
     # Test repetitions are synchronized
     self.assertEqual(row.get_width(), 8)
Example #47
0
 def test_set_cell_currency(self):
     cell = odf_create_cell(123, cell_type='currency', currency='EUR')
     cell.set_currency('CHF')
     self.assertEqual(cell.get_currency(), 'CHF')
Example #48
0
        line_read.append(index)

###
#Second step :  write the data in an ods file
###

    document = odf_new_document('spreadsheet')
    body = document.get_body()      

    table = odf_create_table('Data')
    body.append(table)

    for i in range(len(result[0])):
        row = odf_create_row()
        cell = odf_create_cell("Place "+str(places[i]))
        row.append_cell(cell)
        for j in range(len(result)):
            cell = odf_create_cell(result[j][i])
            row.append_cell(cell)
        table.append_row(row)

###
#Third step :  create our chart
###
    table = odf_create_table('Gantt')
    body.append(table)
    
    cell_range="Data.A1:Data."+_digit_to_alpha(len(result))+str(len(result[0]))

    cols_list = divide_range(cell_range)
Example #49
0
    def test_with_cell(self):

        cell = odf_create_cell(42)
        self.assertEqual(get_value(cell), 42)
 def test_set_cell_currency(self):
     cell = odf_create_cell(123, cell_type='currency', currency='EUR')
     cell.set_cell_currency('CHF')
     self.assertEqual(cell.get_cell_currency(), 'CHF')
    def test_with_cell(self):

        cell = odf_create_cell(42)
        self.assertEqual(get_value(cell), 42)
 def test_style(self):
     cell = odf_create_cell(style=u"Monétaire")
     expected = '<table:table-cell table:style-name="Mon&#233;taire"/>'
     self.assertEqual(cell.serialize(), expected)
 def setUp(self):
     self.cell = odf_create_cell(1, repeated=3, style=u"ce1")
Example #54
0
                                 str(height / 72.0) + 'in')
        image = odf_create_image(internal_name)
        frame.append(image)
        paragraph.append(frame)
        body.append(paragraph)

        # And store the data
        container = document.container
        container.set_part(internal_name, open(path).read())
    elif mimetype in ('text/csv', 'text/comma-separated-values'):
        table = odf_create_table(u"table %d" % numero, style=u"Standard")
        csv = reader(open(path))
        for line in csv:
            size = len(line)
            row = odf_create_row()
            for value in line:
                cell = odf_create_cell(value)
                row.append(cell)
            table.append(row)
        for i in xrange(size):
            column = odf_create_column(style=u"Standard")
            table.insert(column, FIRST_CHILD)
        body.append(table)
    else:
        paragraph = odf_create_paragraph(u"Not image / csv", style=u"Standard")
        body.append(paragraph)

if not exists('test_output'):
    mkdir('test_output')
document.save('test_output/use_case1.odt', pretty=True)
Example #55
0
        image = odf_create_image(internal_name)
        frame.append_element(image)
        paragraph.append_element(frame)
        body.append_element(paragraph)

        # And store the data
        container = document.container
        container.set_part(internal_name,
                           samples.open(filename).read())
    elif isinstance(handler, CSVFile):
        table = odf_create_table(u"table %d" % numero, style=u"Standard")
        for csv_row in handler.get_rows():
            size = len(csv_row)
            row = odf_create_row()
            for value in csv_row:
                cell = odf_create_cell(value)
                row.append_element(cell)
            table.append_element(row)
        for i in xrange(size):
            column = odf_create_column(style=u"Standard")
            table.insert_element(column, FIRST_CHILD)
        body.append_element(table)
    else:
        paragraph = odf_create_paragraph(u"Not image / csv",
                style=u"Standard")
        body.append_element(paragraph)

vfs.make_folder('test_output')
document.save('test_output/use_case1.odt', pretty=True)

    command = {0 : 1, 1 : 12, 2 : 3, 4 : 5 }

    # A table in the text document :
    table = odf_create_table(u"Table")
    body.append(table)
    row = odf_create_row()
    row.set_values([u"Product", u"Price", u"Quantity", u"Amount"])
    table.set_row("A1", row)
    # or: table.set_row(0, row)
    row_number = 0
    for item, quantity in command.iteritems():
        prod = catalog[item]
        row = odf_create_row()
        row.set_value("A", prod.name)
        #or : row.set_value(0, prod.name)
        cell = odf_create_cell()
        cell.set_value(prod.price, text = u"%.2f €" % prod.price,
                                    currency = u"EUR", cell_type="float")
        row.set_cell("B", cell)
        #or : row.set_cell(1, cell)
        row.set_value("C", quantity)
        #row.set_value(2, quantity)
        p = prod.price * quantity
        cell = odf_create_cell()
        cell.set_value(p, text = u"%.2f €" % p,
                                    currency = u"EUR", cell_type="float")
        row.set_cell(3, cell)
        row_number += 1
        table.set_row(row_number, row)

    cols = table.get_width()
                                color = 'white'
                                )
        border_bt = make_table_cell_border_string(
                                thick = '0.80cm',
                                color = 'white',
                                )
        style = odf_create_table_cell_style(
                                color = 'grey' ,
                                background_color = cell_value,
                                border_right = border_rl,
                                border_left = border_rl,
                                border_bottom = border_bt,
                                border_top = border_bt,
                                )
        name = document.insert_style(style=style, automatic=True)
        cell = odf_create_cell(value=rgb2hex(cell_value), style=name)
        row.append_cell(cell)
    table.append_row(row)

    row_style = odf_create_style('table-row', height='1.80cm')
    name_style_row = document.insert_style(style=row_style, automatic=True)
    for row in table.get_rows():
        row.set_style(name_style_row)
        table.set_row(row.y, row)

    col_style = odf_create_style('table-column', width='3.6cm')
    name = document.insert_style(style=col_style, automatic=True)
    for column in table.get_columns():
        column.set_style(col_style)
        table.set_column(column.x, column)
        border_rl = make_table_cell_border_string(thick='0.20cm',
                                                  color='white')
        border_bt = make_table_cell_border_string(
            thick='0.80cm',
            color='white',
        )
        style = odf_create_table_cell_style(
            color='grey',
            background_color=cell_value,
            border_right=border_rl,
            border_left=border_rl,
            border_bottom=border_bt,
            border_top=border_bt,
        )
        name = document.insert_style(style=style, automatic=True)
        cell = odf_create_cell(value=rgb2hex(cell_value), style=name)
        row.append_cell(cell)
    table.append_row(row)

    row_style = odf_create_style('table-row', height='1.80cm')
    name_style_row = document.insert_style(style=row_style, automatic=True)
    for row in table.get_rows():
        row.set_style(name_style_row)
        table.set_row(row.y, row)

    col_style = odf_create_style('table-column', width='3.6cm')
    name = document.insert_style(style=col_style, automatic=True)
    for column in table.get_columns():
        column.set_style(col_style)
        table.set_column(column.x, column)