if __name__ == "__main__": spreadsheet = Document("spreadsheet") # Populate the table in the spreadsheet body = spreadsheet.body table = Table("Table") body.append(table) lines = 50 cols = 20 for line in range(lines): row = Row() for column in range(cols): row.set_value(column, "%s%s" % (chr(65 + column), line + 1)) table.append(row) print("Size of Table :", table.size) table2 = Table("Symetry") # building the symetric table using classical method : for x in range(cols): values = table.get_column_values(x) table2.set_row_values(x, values) body.append(table2) print("Size of symetric table 2 :", table2.size) # a more simple solution with the table.transpose() method : table3 = table.clone
body = spreadsheet.body table = Table("Big Table") body.append(table) lines = 1000 cols = 100 for line in range(lines): row = Row() values = [] n = line for i in range(cols): values.append(n) n = suite(n) row.set_values(values) table.append(row) print("Size of Big Table :", table.size) # now extract 100 rows of 26 columns : table1 = Table("Extract 1") for r in range(800, 900): row = table.get_row(r) values = [row.get_value(x) for x in range(50, 76)] row2 = Row() row2.set_values(values) table1.append(row2) body.append(table1) print("Size of extracted table 1 :", table1.size)