當前位置: 首頁>>代碼示例>>Python>>正文


Python table.TableRow類代碼示例

本文整理匯總了Python中odf.table.TableRow的典型用法代碼示例。如果您正苦於以下問題:Python TableRow類的具體用法?Python TableRow怎麽用?Python TableRow使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TableRow類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_percentage

    def test_percentage(self):
        """ Test that an automatic style can refer to a PercentageStyle as a datastylename """
        doc = OpenDocumentSpreadsheet()
        nonze = PercentageStyle(name='N11')
        nonze.addElement(Number(decimalplaces='2', minintegerdigits='1'))
        nonze.addElement(Text(text='%'))
        doc.automaticstyles.addElement(nonze)
        pourcent = Style(name='pourcent', family='table-cell', datastylename='N11')
        pourcent.addElement(ParagraphProperties(textalign='center'))
        pourcent.addElement(TextProperties(attributes={'fontsize':"10pt",'fontweight':"bold", 'color':"#000000" }))
        doc.automaticstyles.addElement(pourcent)

        table = Table(name='sheet1')
        tr = TableRow()
        tc = TableCell(formula='=AVERAGE(C4:CB62)/2',stylename='pourcent', valuetype='percentage')
        tr.addElement(tc)
        table.addElement(tr)
        doc.spreadsheet.addElement(table)
        doc.save("TEST.odt")
        self.saved = True
        d = load("TEST.odt")
        result = d.contentxml()
        self.assertNotEqual(-1, result.find(u'''<number:percentage-style'''))
        self.assertNotEqual(-1, result.find(u'''style:data-style-name="N11"'''))
        self.assertNotEqual(-1, result.find(u'''style:name="pourcent"'''))
開發者ID:agiacomolli,項目名稱:odfpy,代碼行數:25,代碼來源:testdatastyles.py

示例2: add_title

 def add_title(self, title, width):
     row = TableRow()
     cell = TableCell(stylename="title")
     cell.setAttrNS(TABLENS, "number-columns-spanned", width)
     cell.addElement(P(text=title))
     row.addElement(cell)
     self.sheet.addElement(row)
開發者ID:CroissanceCommune,項目名稱:autonomie,代碼行數:7,代碼來源:ods.py

示例3: add_row

 def add_row( self, _tuple, stylename):
     tr = TableRow()
     self.table.addElement(tr)
     for _c in _tuple:
         tc = TableCell( stylename= stylename )
         tr.addElement(tc)
         p = P(text = _c )
         tc.addElement(p)
開發者ID:Apkawa,項目名稱:polytechnik-django,代碼行數:8,代碼來源:save_to_ods.py

示例4: generate_ods

    def generate_ods(self, path="/home/apkawa/work/test_desu", group=False):
        self.make_style( tablename = self.category.name )

        self.add_spanned_row( (u'OOO "Политехник"',), self.head )
        head = (
                ( u'phone:','+7 (812) 312-42-38'),
                ( u'','+7 (812) 970-42-93'),
                ( u'email:','[email protected]'),
                ( u'www:','http://polytechnik.ru'),
                ('',),
                )
        self.add_rows( head, self.head )
        self.add_row( ( u'Прайс от %s'%date,), self.root_style )
        self.add_spanned_row( (self.category.name, ), self.tablemanuf )
        
        self.add_row( ( u'Наименование',u'Описание',u'Цена',), self.tablehead )


        manuf = None
        type_product = 13
        for p in self.price:

            if manuf != p.manufacturer_id and p.manufacturer_id != 233:
                manuf = p.manufacturer.id
                self.add_spanned_row( (p.manufacturer.name,) , self.tablemanuf )

            if type_product != p.type_product_id and p.type_product_id != 13:
                type_product = p.type_product_id
                self.add_spanned_row( ( p.type_product.name,) , self.tablemanuf )

            p_desc = p.desc
            p_cell = ' %.0f %s'%(p.cell, p.valyuta.desc) if p.cell else ' -'

            if p_desc:
                self.add_row( ( p.name, p_desc, p_cell  ) , self.tablecontents )
            elif not p.desc and not p.cell:
                p_name = re.sub('(<h4>|</h4>)','',p.name)
                self.add_spanned_row( (p_name,), self.tablehead )
            else:
                tr = TableRow( stylename = self.tablecontents )
                self.table.addElement(tr)
                p_price = ( p.name, p_cell )

                #self.add_cell( pl, tr, self.tablecontents, )#numbercolumnsspanned=2, numberrowsspanned = 1 )
                tc = TableCell( stylename= self.tablecontents, numbercolumnsspanned=2, numberrowsspanned = 1 )
                tr.addElement(tc)
                p = P(text=p_price[0])
                tc.addElement(p)

                tr.addElement( CoveredTableCell() )


                self.add_cell( p_price[1], tr, self.tablecontents )

        self.doc.spreadsheet.addElement( self.table )
        self.doc.save( path , True)
開發者ID:Apkawa,項目名稱:polytechnik-django,代碼行數:56,代碼來源:save_to_ods.py

示例5: pictable

 def pictable(num):
     table = Table()
     table.addElement(TableColumn(numbercolumnsrepeated=2,stylename=tablestyle))
     for word in data[num].params.keys():
         if word in transword and data[num].params[word] != None:
             tr = TableRow()
             tr.addElement(ttb(tabletext, transword[word]))
             tr.addElement(ttb(tabletext, data[num].params[word]))
             table.addElement(tr)
     return table
開發者ID:pinballwizard,項目名稱:Cab,代碼行數:10,代碼來源:odtwrite.py

示例6: write_captions

    def write_captions(self, sheet, table):
        """ Writes sheet's caption row to table.
        """

        row = TableRow()
        for caption in sheet.captions:
            cell = TableCell()
            cell.addElement(P(text=caption))
            row.addElement(cell)
        table.addElement(row)
開發者ID:vakaras,項目名稱:pysheets,代碼行數:10,代碼來源:ods.py

示例7: add_spanned_row

 def add_spanned_row( self, _tuple, stylename, _count_col_spanned = 3):
     tr = TableRow()
     self.table.addElement(tr)
     for _c in _tuple:
         tc = TableCell( stylename= stylename )
         tc = TableCell( stylename= stylename, numbercolumnsspanned= _count_col_spanned, numberrowsspanned = 1 )
         tr.addElement(tc)
         p = P(text = _c )
         tc.addElement(p)
         tr.addElement( CoveredTableCell() )
開發者ID:Apkawa,項目名稱:polytechnik-django,代碼行數:10,代碼來源:save_to_ods.py

示例8: NameDatePair

 def NameDatePair(self, a, b) :
     table = Table(name="t")
     table.addElement(TableColumn(numbercolumnsrepeated="1",
                                  stylename="widecolumn"))
     table.addElement(TableColumn(numbercolumnsrepeated="1",
                                  stylename="narrowcolumn"))
     tr = TableRow()
     tc = TableCell(valuetype="string")
     tc.addElement(P(text=a,stylename="Name"))
     tr.addElement(tc)             
     tc = TableCell(valuetype="string")
     tc.addElement(P(text=b,stylename="RightItalic"))
     tr.addElement(tc)             
     table.addElement(tr)
     return table
開發者ID:hobson,項目名稱:Util,代碼行數:15,代碼來源:JITProfile.py

示例9: make_row

	def make_row(self, row):
		""" For each item in array add a cell to a row """
		tr = TableRow()
		for cell_text in row:
			try:
				#i = int(cell_text)
				tc = TableCell(formula=cell_text)
			except:
				tc = TableCell()
				txt = P(text=cell_text)
				tc.addElement(txt)

			tr.addElement(tc)

		return tr
開發者ID:oliverfields,項目名稱:reqy,代碼行數:15,代碼來源:GenEstimation.py

示例10: skills

 def skills(self) :
     t = self.doc.text
     t.addElement(P(text='RELEVANT SKILLS', stylename="Heading"))
     table = Table(name="skills-table")
     col = 0
     skills_cols = int(self.config.fetch('skills_cols'))
     table.addElement(TableColumn(numbercolumnsrepeated=skills_cols))
     for skill in Resume.skills(self) :
         if col % skills_cols == 0 :
             tr = TableRow()
             table.addElement(tr)
         tc = TableCell(valuetype="string")
         tc.addElement(P(text=skill,stylename="List"))
         tr.addElement(tc)             
         col += 1
     t.addElement(table)
開發者ID:hobson,項目名稱:Util,代碼行數:16,代碼來源:JITProfile.py

示例11: addTable

 def addTable(self, content, cell_style, column_styles=[]):
     """  """
     cell_style = getattr(self, cell_style, None)
     table = Table()
     for style in column_styles:
         if "stylename" in style.keys():
             style["stylename"] = getattr(self, style["stylename"], None)
             table.addElement(TableColumn(**style))
     for row in content:
         tr = TableRow()
         table.addElement(tr)
         for cell in row:
             tc = TableCell()
             tr.addElement(tc)
             p = P(stylename=cell_style,text=cell)
             tc.addElement(p)
     self.document.text.addElement(table)
開發者ID:Guts,項目名稱:Metadator,代碼行數:17,代碼來源:test_md2odt_old.py

示例12: add_attribute_row

	def add_attribute_row(self, table, key, value):
		""" Add a two cell row to the table """
		boldstyle = Style(name="Bold",family="text")
		boldstyle.addElement(TextProperties(attributes={'fontweight':"bold"}))

		title_span = Span(stylename=boldstyle, text=key)
		pt = P(text='')
		pt.addElement(title_span)

		tr = TableRow()
		tc = TableCell(valuetype='string')
		tc.addElement(pt)
		tr.addElement(tc)
		tc = TableCell(valuetype='string')
		tc.addElement(P(text=value))
		tr.addElement(tc)
		table.addElement(tr)
開發者ID:oliverfields,項目名稱:reqy,代碼行數:17,代碼來源:GenRequirementList.py

示例13: write_row

    def write_row(self, sheet_row, table):
        """ Appends ``sheet_row`` data into table.
        """

        row = TableRow()
        for field in sheet_row:
            if isinstance(field, datetime.datetime):
                field = unicode(field.strftime('%Y-%m-%d %H:%M:%S'))
            elif isinstance(field, datetime.date):
                field = unicode(field.strftime('%Y-%m-%d'))
            elif not isinstance(field, unicode):
                field = unicode(field)
            cell = TableCell()
            cell.addElement(P(text=field))
            row.addElement(cell)

        table.addElement(row)
開發者ID:vakaras,項目名稱:pysheets,代碼行數:17,代碼來源:ods.py

示例14: add_rows

    def add_rows(self, _tuple, stylename):
        '''
        _tuple example

        (
        ('','',), # 1 row
        ('','','',), # 2 row
        )
        '''
        for _r in _tuple:
            tr = TableRow()
            self.table.addElement(tr)
            for _c in _r:
                tc = TableCell( stylename= stylename )
                tr.addElement(tc)
                p = P(text = _c )
                tc.addElement(p)
開發者ID:Apkawa,項目名稱:polytechnik-django,代碼行數:17,代碼來源:save_to_ods.py

示例15: calc

def calc(title, xlabel, ylabel, xdata, ydata):
    from odf.opendocument import OpenDocumentSpreadsheet
    from odf.text import P
    from odf.table import Table, TableColumn, TableRow, TableCell
    
    outfile = NamedTemporaryFile(
        mode='wb', 
        suffix='.ods',
        prefix='eyesCalc_',
        delete=False)
    doc=OpenDocumentSpreadsheet()
    table = Table(name="ExpEYES {0}".format(time.strftime("%Y-%m-%d %Hh%Mm%Ss")))
    doc.spreadsheet.addElement(table)
    ## add rows into the table
    for i in range(len(xdata)):
        tr = TableRow()
        table.addElement(tr)
        if len(ydata.shape)==1:
            # single y data
            tr.addElement(TableCell(valuetype="float", value=str(xdata[i])))
            tr.addElement(TableCell(valuetype="float", value=str(ydata[i])))
        else:
            # multiple y data
            tr.addElement(TableCell(valuetype="float", value=str(xdata[i])))
            for j in range(ydata.shape[0]):
                tr.addElement(TableCell(valuetype="float", value=str(ydata[j][i])))
    doc.save(outfile)
    outfile.close()
    call("(localc {}&)".format(outfile.name), shell=True)
    return [outfile]
開發者ID:expeyes,項目名稱:expeyes-programs,代碼行數:30,代碼來源:eyesplotter.py


注:本文中的odf.table.TableRow類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。