\n') print str(t) print '-'*79 t2 = Table([ ('1', '2'), ['3', '4'] ], width='100%', header_row=('col1', 'col2'), col_width=('', '75%')) f.write(str(t2) + '

\n') print t2 print '-'*79 t2.rows.append(['5', '6']) t2.rows = TableCell('new', bgcolor='red') t2.rows.append(TableRow(['7', '8'], attribs={'align': 'center'})) f.write(str(t2) + '

\n') print t2 print '-'*79 # sample table with column attributes and styles: table_data = [ ['Smith', 'John', 30, 4.5], ['Carpenter', 'Jack', 47, 7], ['Johnson', 'Paul', 62, 10.55], ] htmlcode = HTML.table(table_data, header_row = ['Last name', 'First name', 'Age', 'Score'], col_width=['', '20%', '10%', '10%'], col_align=['left', 'center', 'right', 'char'], col_styles=['font-size: large', '', 'font-size: small', 'background-color:yellow']) f.write(htmlcode + '

\n') print htmlcode print '-'*79 def gen_table_squares(n): """ Generator to create table rows for integers from 1 to n """ ## # First, header row: ## yield TableRow(('x', 'square(x)'), header=True, bgcolor='blue') ## # Then all rows: for x in range(1, n+1): yield (x, x*x) t = Table(rows=gen_table_squares(10), header_row=('x', 'square(x)')) f.write(str(t) + '

\n') print '-'*79 l = List(['aaa', 'bbb', 'ccc']) f.write(str(l) + '

\n') l.ordered = True f.write(str(l) + '

\n') l.start=10 f.write(str(l) + '

\n') f.close()