首頁  >  問答  >  主體

python 使用 xlwt 写入单元格时,如何合并单元格

我想展示成这样:

----------------
|     名称      |
----------------
| 1    | 2     |
----------------

用下列代码写入:

sheet.write(0, 0, '名称')
sheet.write(1, 0, 1)
sheet.write(1, 1, 2)

但实际展示成了:

--------------------
|    名称    |      |
--------------------
| 1         | 2    |
--------------------

求解

天蓬老师天蓬老师2742 天前868

全部回覆(1)我來回復

  • PHPz

    PHPz2017-04-17 14:33:35

    stackoverflow上幾乎有相同的問題:
    http://stackoverflow.com/questions/19672760/how-to-write-a-cell-with-multiple-columns-in-xlwt

    程式碼就是這樣了:

    sheet.write_merge(0, 0, 0, 1, 'Long Cell')
    sheet.write(1, 0, 1)
    sheet.write(1, 1, 2)
    

    回覆
    0
  • 取消回覆