Example #1
0
        def writeSheet(self, sheet, ranges):
            import odf.text, odf.table

            # Create the table
            table = odf.table.Table(name=sheet.sheetName())
            # Add the columns
            for i in range( self.getMaxColumn(ranges) ):
                table.addElement(odf.table.TableColumn())

            # Add the rows to the table
            for r in ranges:
                for row in range(r[1],r[3]+1):
                    tr = odf.table.TableRow()
                    table.addElement(tr)
                    for col in range(r[0],r[2]+1):
                        td = odf.table.TableCell()
                        tr.addElement(td)
                        #value = "%s" % sheet.value(row,col)
                        value = "%s" % sheet.text(col,row)
                        #print "row=%i col=%i value=%s" % (row,col,value)
                        p = odf.text.P(stylename=self.tablestyle, text=value)
                        td.addElement(p)

            # Add the table to the document
            self.doc.spreadsheet.addElement(table)
Example #2
0
    def save(self, f):
        cards_per_page = self._label.across * self._label.down
        pages = int(math.ceil(float(len(self._cards)) / cards_per_page))
        spacer = (self._label.width != self._label.horizontal_pitch)

        for page in range(pages):
            table = odf.table.Table(stylename=self._page_break)
            self._doc.text.addElement(table)

            for cs in self._layout_table_colspec:
                table.addElement(odf.table.TableColumn(stylename=cs))

            for row in range(self._label.down):
                data = []
                for col in range(self._label.across):
                    try:
                        data.append(self._cards[(page * cards_per_page) + (col * self._label.down) + row])
                    except IndexError:
                        data.append('')
                    if spacer:
                        data.append('')
                if spacer:
                    data.pop()

                tr = odf.table.TableRow(stylename=self._layout_table_label_height)
                table.addElement(tr)

                for d in data:
                    tc = odf.table.TableCell(stylename=self._style_card_table_cell)
                    tr.addElement(tc)
                    self.HTML(self._html_parser.parse(d), tc)

        self._doc.write(f)
Example #3
0
    def render(self):
        table = odf.table.Table(name=self._name)
        table.addElement(odf.table.TableColumn(stylename=self._calc.style_co1))

        for row in range(self._rows):
            tr = odf.table.TableRow()
            table.addElement(tr)

            for col in range(self._cols):
                try:
                    tc = self._cells[(row, col)]
                except KeyError:
                    tc = odf.table.TableCell()
                tr.addElement(tc)
        return table
Example #4
0
    def test_ooo_ns(self):
        """ Check that ooo exists in namespace declarations """
        calcdoc = OpenDocumentSpreadsheet()
        table = odf.table.Table(name="Costs")
        forms = odf.office.Forms()
        form = odf.form.Form(
            controlimplementation="ooo:com.sun.star.form.component.Form")
        lb = odf.form.Listbox(
            controlimplementation="ooo:com.sun.star.form.component.ListBox",
            dropdown="true",
            id="control1")
        form.addElement(lb)
        forms.addElement(form)
        table.addElement(forms)

        # One empty line
        tr = odf.table.TableRow()
        table.addElement(tr)

        tr = odf.table.TableRow()
        # One empty cell
        cell = odf.table.TableCell()
        tr.addElement(cell)

        cell = odf.table.TableCell()

        draw = odf.draw.Control(control="control1",
                                height="0.1126in",
                                width="0.798in",
                                x="0.0303in",
                                y="0.0205in",
                                endcelladdress="Costs.B2",
                                endx="0.8283in",
                                endy="0.1331in")

        cell.addElement(draw)
        tr.addElement(cell)
        table.addElement(tr)

        calcdoc.spreadsheet.addElement(table)
        result = calcdoc.contentxml(
        )  # contentxml() is supposed to yeld a bytes
        self.assertNotEqual(
            -1,
            result.find(b'''xmlns:ooo="http://openoffice.org/2004/office"'''))
Example #5
0
    def test_ooo_ns(self):
        """ Check that ooo exists in namespace declarations """
        calcdoc = OpenDocumentSpreadsheet()
        table = odf.table.Table(name="Costs")
        forms = odf.office.Forms()
        form = odf.form.Form(
           controlimplementation="ooo:com.sun.star.form.component.Form")
        lb = odf.form.Listbox(
           controlimplementation="ooo:com.sun.star.form.component.ListBox", dropdown="true", id="control1")
        form.addElement(lb)
        forms.addElement(form)
        table.addElement(forms)

        # One empty line
        tr = odf.table.TableRow()
        table.addElement(tr)

        tr = odf.table.TableRow()
        # One empty cell
        cell = odf.table.TableCell()
        tr.addElement(cell)

        cell = odf.table.TableCell()

        draw = odf.draw.Control(
        control="control1", height="0.1126in", width="0.798in",
        x="0.0303in", y="0.0205in", endcelladdress="Costs.B2",
        endx="0.8283in", endy="0.1331in")

        cell.addElement(draw)
        tr.addElement(cell)
        table.addElement(tr)

        calcdoc.spreadsheet.addElement(table)
        result = unicode(calcdoc.contentxml(),'utf-8')
        self.assertNotEqual(-1, result.find(u'''xmlns:ooo="http://openoffice.org/2004/office"'''))
Example #6
0
 def _add_row(self, table):
     tr = odf.table.TableRow()
     table.addElement(tr)
     return tr
Example #7
0
    def _export_ods(self, fname: str):
        doc = odf.opendocument.OpenDocumentSpreadsheet()
        doc.styles.addElement(self.odfstyles["tablecontents"])
        doc.automaticstyles.addElement(self.odfstyles["widewidth"])
        doc.automaticstyles.addElement(self.odfstyles["widewidth2"])
        doc.automaticstyles.addElement(self.odfstyles["borderbottom"])
        doc.automaticstyles.addElement(self.odfstyles["borderright"])
        doc.automaticstyles.addElement(self.odfstyles["bold"])

        table = odf.table.Table(name="Practices")
        table.addElement(
            odf.table.TableColumn(stylename=self.odfstyles["widewidth"],
                                  defaultcellstylename="ce1"))
        table.addElement(
            odf.table.TableColumn(stylename=self.odfstyles["widewidth2"],
                                  defaultcellstylename="ce2"))
        table.addElement(
            odf.table.TableColumn(stylename=self.odfstyles["widewidth2"],
                                  defaultcellstylename="ce3"))
        table.addElement(
            odf.table.TableColumn(stylename=self.odfstyles["widewidth2"],
                                  defaultcellstylename="ce4"))

        for index, practice in enumerate(self.practices):
            tr_header = self._add_row(table)
            self._add_string_cell(tr_header,
                                  "",
                                  border=self.odfstyles["borderbottom"])
            self._add_string_cell(tr_header, f"Practice #{index +1}", True,
                                  self.odfstyles["borderbottom"])
            self._add_string_cell(
                tr_header,
                practice.instrument.name.title(),
                True,
                self.odfstyles["borderbottom"],
            )
            self._add_string_cell(
                tr_header,
                f"{practice.date:%a, %d %B %Y}",
                True,
                self.odfstyles["borderbottom"],
            )

            tr_goals = self._add_row(table)
            self._add_string_cell(tr_goals, "Goals:", True,
                                  self.odfstyles["borderright"])
            [
                self._add_string_cell(tr_goals, goal.name)
                for goal in practice.goals.all()
            ]

            tr_exercise = self._add_row(table)
            self._add_string_cell(tr_exercise, "Exercises:", True,
                                  self.odfstyles["borderright"])
            exercises = practice.exercises.all()
            for index, exercise in enumerate(exercises):
                self._add_string_cell(tr_exercise, exercise.name)
                self._add_string_cell(
                    tr_exercise,
                    f"{exercise.bpm_start}-{exercise.bpm_end} bpm")
                self._add_string_cell(tr_exercise, f"{exercise.minutes}m")

                if index + 1 != len(exercises):
                    tr_exercise = self._add_row(table)
                    self._add_string_cell(tr_exercise,
                                          odf.text.P(),
                                          border=self.odfstyles["borderright"])

            tr_improvements = self._add_row(table)
            self._add_string_cell(tr_improvements, "Improvements:", True,
                                  self.odfstyles["borderright"])
            [
                self._add_string_cell(tr_improvements, improvement.name)
                for improvement in practice.improvements.all()
            ]

            tr_positives = self._add_row(table)
            self._add_string_cell(tr_positives, "Positives:", True,
                                  self.odfstyles["borderright"])
            [
                self._add_string_cell(tr_positives, positive.name)
                for positive in practice.positives.all()
            ]

            tr_notes = self._add_row(table)
            self._add_string_cell(tr_notes, f"Notes:", True,
                                  self.odfstyles["borderright"])
            self._add_string_cell(tr_notes, practice.notes)
            self._add_row(table)

        doc.spreadsheet.addElement(table)
        doc.save(fname)
Example #8
0
    def _html_table(self, chunk, root, p, style):
        for tbody in chunk.childNodes:
            if tbody.name == 'tbody':
                chunk = tbody
                break

        table = odf.table.Table(stylename=self._inner_table_style)
        root.addElement(table)

        widths = []
        taken = 0
        for tr in chunk.childNodes:
            if tr.name == 'tr':
                for td in tr.childNodes:
                    if td.name == 'td':
                        w = None

                        if td.attributes.has_key('width'):
                            _w = td.attributes['width'].replace(' ', '')
                            if _w.endswith('%'):
                                w = float(_w[:-1])
                                taken += w

                        elif td.attributes.has_key('style'):
                            s = td.attributes['style']
                            for se in s.split(';'):
                                se = se.replace(' ', '')
                                try:
                                    k, v = se.split(':')
                                    if k == 'width' and v.endswith('%'):
                                        w = float(v[:-1])
                                        taken += w
                                        break

                                except ValueError:
                                    pass

                        widths.append(w)
                # we only look at the first row
                break

        if taken > 100:
            raise Exception('Table columns claim %d%%' % taken)

        remaining = 100.0 - taken
        unsized = len(filter(lambda x: not x, widths))
        if unsized:
            remaining = remaining / unsized
            widths = [w or remaining for w in widths]

        for w in widths:
            table.addElement(odf.table.TableColumn(stylename=self.style('table-column', {'columnwidth': '%f%%' % w})))

        for tr in chunk.childNodes:
            if tr.name != 'tr':
                continue

            row = odf.table.TableRow()
            table.addElement(row)

            for td in tr.childNodes:
                if td.name == 'td':
                    tc = odf.table.TableCell(stylename=self._inner_table_cell_style)
                    row.addElement(tc)
                    self.HTML(td, tc, None, style)
Example #9
0
 def makeOdfSchedules(self):
     document = OpenDocumentText()
     
     nameColumnWidth = 1.25
     rowHeight = 0.15
     letterColumnWidth = 0.25
     wlColumnWidth = 0.25
     
     styles = document.automaticstyles
     #Page layout style
     pageLayoutStyleName = "PageLayoutStyleName"
     s = style.PageLayout(name=pageLayoutStyleName)
     t = style.PageLayoutProperties(writingmode="lr-tb", margintop ="0.5in", marginbottom="0.5in", marginleft="0.5in",
                                    marginright="0.5in", printorientation="portrait", pageheight="11in", pagewidth="8.5in")
     s.addElement(t)
     styles.addElement(s)
     
     masterpage = style.MasterPage(name="Standard", pagelayoutname=pageLayoutStyleName)
     document.masterstyles.addElement(masterpage)
     
     #Section Style
     sectionStyleName = "SectionStyleName"
     s = Style(name=sectionStyleName, family="section", displayname="Section Style")
     t = SectionProperties(editable="false", dontbalancetextcolumns="false")
     c = Columns(columngap="0in", columncount="2")
     c1 = Column(endindent="0in", startindent="0in", relwidth="5400*")
     c2 = Column(endindent="0in", startindent="0in", relwidth="5400*")
     c.addElement(c1)
     c.addElement(c2)
     t.addElement(c)
     s.addElement(t)
     styles.addElement(s)
     
     #Table Style
     scoreCardTableStyleName = "ScoreCardTableStyle"
     tableWidth = 2*nameColumnWidth  + 2*letterColumnWidth + 2*wlColumnWidth
     s = Style(name=scoreCardTableStyleName, family="table", displayname="Score Card Table ")
     t = TableProperties(align="center", width=str(tableWidth) + "in")
     s.addElement(t)
     s.addElement(t)
     styles.addElement(s)
     
     #Row style
     rowStyleName = "RowStyleName"
     s = Style(name = rowStyleName, family="table-row", displayname="Normal Table Row")
     t = TableRowProperties(minrowheight=str(rowHeight) + "in")        
     s.addElement(t)
     styles.addElement(s)
     
     #Even Row cell style
     evenRowCellStyleName = "EvenRowCellStyleName"
     s = Style(name=evenRowCellStyleName, family="table-cell", displayname="Text Cell")
     t = TableCellProperties(backgroundcolor='#C0C0C0', verticalalign="middle", padding="0.05in", borderright="0.05pt solid #000000", bordertop="0.05pt solid #000000", borderleft='0.05pt solid #000000', borderbottom='0.05pt solid #000000')        
     s.addElement(t)
     styles.addElement(s)
     
     #Odd row cell style
     oddRowCellStyleName = "OddRowCellStyleName"
     s = Style(name=oddRowCellStyleName, family="table-cell", displayname="Text Cell")
     t = TableCellProperties(verticalalign="middle", padding="0.05in", borderright="0.05pt solid #000000", bordertop="0.05pt solid #000000", borderleft='0.05pt solid #000000', borderbottom='0.05pt solid #000000')        
     s.addElement(t)
     styles.addElement(s)
     
     #letter Column Style
     letterColumnStyleName = "LetterColumnStyle"
     s = Style(name=letterColumnStyleName, family="table-column", displayname="Left Table Column")
     t = TableColumnProperties(columnwidth=str(letterColumnWidth) + "in")
     s.addElement(t)
     styles.addElement(s)
     
     #letter Column Style
     wlColumnStyleName = "WLColumnStyle"
     s = Style(name=wlColumnStyleName, family="table-column", displayname="Left Table Column")
     t = TableColumnProperties(columnwidth=str(wlColumnWidth) + "in")
     s.addElement(t)
     styles.addElement(s)
     
     #letter Column Style
     nameColumnStyleName = "NameColumnStyle"
     s = Style(name=nameColumnStyleName, family="table-column", displayname="Left Table Column")
     t = TableColumnProperties(columnwidth=str(nameColumnWidth) + "in")
     s.addElement(t)
     styles.addElement(s)
     
     #Robot Name Paragraph Style
     robotNameParagraphStyleName = "RobotNameParagraphStyle"
     s = Style(name = robotNameParagraphStyleName, family="paragraph", displayname="Robot Name Paragraph Style")
     t = ParagraphProperties(textalign="center")
     s.addElement(t)
     t = TextProperties(fontsize="12pt", fontsizecomplex="12pt", fontsizeasian="12pt")
     s.addElement(t)
     styles.addElement(s)
     
     judgeTimerStyleName = "JudgeTimerStyleName"
     s = Style(name = judgeTimerStyleName, family="paragraph", displayname="Judge Timer Paragraph Style")
     t = ParagraphProperties(textalign="right")
     s.addElement(t)
     t = TextProperties(fontsize="12pt")
     s.addElement(t)
     styles.addElement(s)
     
     #Heading Text
     headingParagraphStyleName = "HeadingParagraphStyle"
     s = Style(name = headingParagraphStyleName, family="paragraph", displayname="Robot Name Paragraph Style")
     t = ParagraphProperties(breakbefore="page", textalign="center")
     s.addElement(t)
     t = TextProperties(fontsize="20pt", fontsizecomplex="20pt", fontsizeasian="20pt")
     s.addElement(t)
     styles.addElement(s)
     
     wlParagraphStyleName = "WLParagraphStyle"
     s = Style(name = wlParagraphStyleName, family="paragraph", displayname="WL Paragraph Style")
     t = ParagraphProperties(breakbefore="page", textalign="center")
     s.addElement(t)
     t = TextProperties(fontsize="9pt", fontsizecomplex="9pt", fontsizeasian="9pt")
     s.addElement(t)
     styles.addElement(s)
     
     for i in range(0, len(self.roundRobinTournaments), 1):
         h=H(outlinelevel=1, text=self.roundRobinTournaments[i].name + " Score Sheet - Revision " + str (self.version), stylename=headingParagraphStyleName)
         document.text.addElement(h)
         document.text.addElement(P(text=""))
         p = P(text="Judge:___________________   Timer:__________________", stylename=judgeTimerStyleName)
         document.text.addElement(p)
         
         table = Table(name="Table" + str(i), stylename=scoreCardTableStyleName)
         table.addElement(TableColumn(stylename=letterColumnStyleName))
         table.addElement(TableColumn(stylename=nameColumnStyleName))
         table.addElement(TableColumn(stylename=wlColumnStyleName))
         table.addElement(TableColumn(stylename=wlColumnStyleName))
         table.addElement(TableColumn(stylename=nameColumnStyleName))
         table.addElement(TableColumn(stylename=letterColumnStyleName))
     
             
         #Populate the first row with  the rest of the robot names (1 per column).
         for j in range(0, len(self.roundRobinTournaments[i].matches)):
             if(j%2==0):
                 columnStyle = evenRowCellStyleName
             else:
                 columnStyle = oddRowCellStyleName
                 
             tr1 = TableRow(stylename=rowStyleName)
             tr2 = TableRow(stylename=rowStyleName)
             
             table.addElement(tr1)
             table.addElement(tr2)
             
             #Letter Column
             tc = TableCell(valuetype="string", stylename=columnStyle, numberrowsspanned="2")
             tc.addElement(P(text=self.roundRobinTournaments[i].matches[j].contestant1.letter, stylename=robotNameParagraphStyleName))
             tr1.addElement(tc)
             
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr2.addElement(tc)
             
             #Name Column
             tc = TableCell(valuetype="string", stylename=columnStyle, numberrowsspanned="2") 
             tc.addElement(P(text=self.roundRobinTournaments[i].matches[j].contestant1.robotName, stylename=robotNameParagraphStyleName))
             tr1.addElement(tc)
             
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr2.addElement(tc)
             
             #W/L column
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr1.addElement(tc)
             
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr2.addElement(tc)
             
             #W/L column
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr1.addElement(tc)
             
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr2.addElement(tc)
             
             #Name column
             tc = TableCell(valuetype="string", stylename=columnStyle, numberrowsspanned="2") 
             tc.addElement(P(text=self.roundRobinTournaments[i].matches[j].contestant2.robotName, stylename=robotNameParagraphStyleName))
             tr1.addElement(tc)
              
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr2.addElement(tc)
             
             #Letter column
             tc = TableCell(valuetype="string", stylename=columnStyle, numberrowsspanned="2")
             tc.addElement(P(text=self.roundRobinTournaments[i].matches[j].contestant2.letter, stylename=robotNameParagraphStyleName))
             tr1.addElement(tc)
             
             tc = TableCell(valuetype="string", stylename=columnStyle)
             tc.addElement(P(text="", stylename=wlParagraphStyleName))
             tr2.addElement(tc)
             
         #If the table is two long break it into two columns.
         if(2*len(self.roundRobinTournaments[i].matches)*rowHeight>6.0):    
             section = text.Section(name="Section" + str(i), stylename=sectionStyleName)
             section.addElement(table)
             document.text.addElement(section)
         else:
             document.text.addElement(table)
         
         #Add a score summary table on the bottom of the page.     
         summaryColumnWidth = 7.5/len(self.roundRobinTournaments[i].entries)
         if(summaryColumnWidth >1.5):
             summaryColumnWidth=1.5
         summaryTableWidth = summaryColumnWidth*len(self.roundRobinTournaments[i].entries)
         
         summaryTableStyleName = "SummaryTableStyleName" + str(i)
         s = Style(name=summaryTableStyleName, family="table", displayname="Summary Table" + str(i))
         t = TableProperties(align="center", width=str(summaryTableWidth) + "in")
         s.addElement(t)
         s.addElement(t)
         styles.addElement(s)
         
         summaryColumnStyleName = "SummaryColumnStyle" + str(i)
         s = Style(name=summaryColumnStyleName, family="table-column", displayname="Summary Table Column " + str(i))
         t = TableColumnProperties(columnwidth=str(summaryColumnWidth) + "in")
         s.addElement(t)
         styles.addElement(s)
         
         table = Table(name="SummaryTable" + str(i), stylename=summaryTableStyleName)
         table.addElement(TableColumn(stylename=summaryColumnStyleName, numbercolumnsrepeated=len(self.roundRobinTournaments[i].entries)))
         tr1 = TableRow(stylename=rowStyleName)
         tr2 = TableRow(stylename=rowStyleName)
         table.addElement(tr1)
         for j in range(0,len(self.roundRobinTournaments[i].entries),1):
             tc = TableCell(valuetype="string", stylename=oddRowCellStyleName)
             tc.addElement(P(text=self.roundRobinTournaments[i].entries[j].robotName, stylename=robotNameParagraphStyleName))
             tr1.addElement(tc)
             tc = TableCell(valuetype="string", stylename=oddRowCellStyleName)
             tr2.addElement(tc)
         table.addElement(tr1)
         table.addElement(tr2)
         document.text.addElement(P(text=""))
         document.text.addElement(table)
         document.text.addElement(P(text=""))
         document.text.addElement(P(text=""))
         document.text.addElement(P(text="1st:________________     2nd:________________     3rd:________________     4th:________________"))
         
      #TODO add a section to record the 1st through 4th place finishers
      
      #TODO add checkboxes for the "Entered on Scoreboard" and "Entered on spreadsheet."   
         
     document.save("./ScoreSheets/" + self.competition, True)
Example #10
0
 def makeOdf5160Labels(self):
     #This will generate an ODF files for 5160 labels for a given event.
     labelWidth = 2.625
     labelHeight = 1
     numLabelRows = 10
     numLabelColumns = 3
     labelSheetWidth = 8.5
     labelSheetHeight = 11
     
     leftRightMargin = (labelSheetWidth - numLabelColumns * labelWidth)/2
     topBottomMargin = (labelSheetHeight - numLabelRows * labelHeight)/2
     
     tableWidth = numLabelColumns * labelWidth
     tableHeight = numLabelRows * labelHeight
     
     document = OpenDocumentText()
     styles = document.automaticstyles    
     
     #Setup the page layout.
     pageLayoutStyleName = "PageLayoutStyleName"
     s = style.PageLayout(name=pageLayoutStyleName)
     t = style.PageLayoutProperties(writingmode="lr-tb", margintop=str(topBottomMargin) + "in", marginbottom=str(topBottomMargin) + "in",
                                     marginleft=str(leftRightMargin) + "in", marginright=str(leftRightMargin) + "in", printorientation="portrait",
                                     pageheight=str(labelSheetHeight) + "in", pagewidth=str(labelSheetWidth) + "in")
     s.addElement(t)
     styles.addElement(s)
     
     masterpage = style.MasterPage(name="Standard", pagelayoutname=pageLayoutStyleName)
     document.masterstyles.addElement(masterpage)
     
     #Setup the table layout
     #Table Style
     labelTableStyleName = "LabelTableStyle"
     s = Style(name=labelTableStyleName, family="table", displayname="Label Table")
     t = TableProperties(align="center", width=str(tableWidth) + "in")
     s.addElement(t)
     styles.addElement(s)
     
     #label Row style
     labelRowStyleName = "LabelRowStyleName"
     s = Style(name = labelRowStyleName, family="table-row", displayname="Label Row")
     t = TableRowProperties(minrowheight=str(labelHeight) + "in")        
     s.addElement(t)
     styles.addElement(s)
     
     #label Column Style
     labelColumnStyleName = "labelColumnStyle"
     s = Style(name=labelColumnStyleName, family="table-column", displayname="Label Table Column")
     t = TableColumnProperties(columnwidth=str(labelWidth) + "in")
     s.addElement(t)
     styles.addElement(s)
     
     #cell style
     labelCellStyleName = "LabelCellStyleName"
     s = Style(name=labelCellStyleName, family="table-cell", displayname="Text Cell")
     t = TableCellProperties(verticalalign="middle", padding="0.05in")        
     s.addElement(t)
     styles.addElement(s)
     
     #Paragraph Style
     labelParagraphStyleName = "LabelParagraphStyle"
     s = Style(name = labelParagraphStyleName, family="paragraph", displayname="Label Paragraph Style")
     t = ParagraphProperties(textalign="center")
     s.addElement(t)
     t = TextProperties(fontsize="10pt", fontsizecomplex="10pt", fontsizeasian="10pt")
     s.addElement(t)
     styles.addElement(s)
     
     if(self.competition in ('LFA', 'TPM', 'NXT', 'RC1', 'JC1')):
         index = 0
         for j in range(0, len(self.entries),1):
             if(index % 30 == 0): #Start a new page.
                 table = Table(name="Table", stylename=labelTableStyleName)
                 table.addElement(TableColumn(stylename=labelColumnStyleName, numbercolumnsrepeated=str(numLabelColumns)))
                 document.text.addElement(table)
             if(index % 3 == 0): #Start a new row
                 tr = TableRow(stylename=labelRowStyleName)
                 table.addElement(tr)
             tc = TableCell(valuetype="string", stylename=labelCellStyleName)
             tr.addElement(tc)
             tc.addElement(P(text="MRG 2016 - " + self.competition + " - "  + "V" + str(self.version), stylename=labelParagraphStyleName))
             tc.addElement(P(text=self.entries[j].robotName + " #" + self.entries[j].id, stylename=labelParagraphStyleName))
             tc.addElement(P(text="[ ]Weight  [ ]Size", stylename=labelParagraphStyleName))
             index += 1
     else:
         index = 0
         for i in range(0, len(self.roundRobinTournaments), 1):
             for j in range(0, len(self.roundRobinTournaments[i].entries),1):
                 if(index % 30 == 0): #Start a new page.
                     table = Table(name="Table" + str(i), stylename=labelTableStyleName)
                     table.addElement(TableColumn(stylename=labelColumnStyleName, numbercolumnsrepeated=str(numLabelColumns)))
                     document.text.addElement(table)
                 if(index % 3 == 0): #Start a new row
                     tr = TableRow(stylename=labelRowStyleName)
                     table.addElement(tr)
                 tc = TableCell(valuetype="string", stylename=labelCellStyleName)
                 tr.addElement(tc)
                 tc.addElement(P(text="MRG 2016 - " + self.roundRobinTournaments[i].name + " - "  + "V" + str(self.version), stylename=labelParagraphStyleName))
                 tc.addElement(P(text= self.roundRobinTournaments[i].entries[j].letter + " - " + self.roundRobinTournaments[i].entries[j].robotName + " #" + self.roundRobinTournaments[i].entries[j].id, stylename=labelParagraphStyleName))
                 tc.addElement(P(text="[ ]Weight  [ ]Size", stylename=labelParagraphStyleName))
                 index += 1
     
     document.save("./ScoreSheets/" + self.competition + "-labels", True)