在 Python 中使用 Xlsxwriter 合并 Excel 单元格 [英] Merging Excel cells using Xlsxwriter in Python

查看:147
本文介绍了在 Python 中使用 Xlsxwriter 合并 Excel 单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Python Xlsxwriter 在 Excel 文件中合并多个系列的单元格区域,我在本网站的 Xlsxwriter 文档中找到了 Python 命令http://xlsxwriter.readthedocs.org/en/latest/example_merge1.html如下:

I want to merge several series of cell ranges in an Excel file using Python Xlsxwriter, I found the Python command in the Xlsxwriter documentation in this website http://xlsxwriter.readthedocs.org/en/latest/example_merge1.html as below:

worksheet.merge_range('B4:D4')

唯一的问题是我的范围采用行和列数字格式,例如 (0,0) 等于 A1.但是 Xlsxwriter 似乎只接受像 A1 这样的格式.我想知道是否有其他人遇到了同样的问题,是否有任何解决方案.

The only problem is that I have my ranges in row and columns numbers format for example (0,0) which is equal to A1. But Xlsxwriter seems to only accept format like A1. I was wondering if anybody else had the same problem and if there is any solution for that.

推荐答案

XlsxWriter 中几乎所有的方法都支持 A1(row, col) 表示法,查看文档.因此,以下内容等效于 merge_range():

Almost all methods in XlsxWriter support both A1 and (row, col) notation, see the docs. So the following are equivalent for merge_range():

worksheet.merge_range('B4:D4',    'Merged Range', merge_format)
worksheet.merge_range(3, 1, 3, 3, 'Merged Range', merge_format)

这篇关于在 Python 中使用 Xlsxwriter 合并 Excel 单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆