- Mecbur bulmak için kaynak kodunu okuyun. Bunu yapmak için Worksheet
sınıfında iki yöntem vardır, write_merge
ve merge
. merge
varolan hücreleri alır ve onları birleştirir, write_merge
bir etiket (write
gibi) yazıyor ve daha sonra merge
aynı şeyler yapar.
Her iki hücreyi de r1, r2, c1, c2
olarak birleştirin ve isteğe bağlı bir style
parametresini kabul edin.
sheet.write_merge(0, 0, 0, 1, 'Long Cell')
sheet.write(1, 0, 1)
sheet.write(1, 1, 2)
çağrı nasıl çalıştığı konusunda daha açık olmak gerekirse: Alternatif
top_row = 0
bottom_row = 0
left_column = 0
right_column = 1
sheet.write_merge(top_row, bottom_row, left_column, right_column, 'Long Cell')
, merge
kullanarak:
sheet.write(top_row, left_column, 'Long Cell')
sheet.merge(top_row, bottom_row, left_column, right_column)
sizin örnekten
, bu en basit çağrı olurdu
merge
kaynağında işaret eden bazı yorumlar vardır ntial sorunlar:
# Problems: (1) style to be used should be existing style of
# the top-left cell, not an arg.
# (2) should ensure that any previous data value in
# non-top-left cells is nobbled.
# Note: if a cell is set by a data record then later
# is referenced by a [MUL]BLANK record, Excel will blank
# out the cell on the screen, but OOo & Gnu will not
# blank it out. Need to do something better than writing
# multiple records. In the meantime, avoid this method and use
# write_merge() instead.
Ama böyle basit bir durum için iyi olurdu.
@ShivanRaptor Sorumu güncelledim. Teşekkürler. –