[英]xlsxwriter format specific cell
I've seen many pages on here to format the width of an entire column, but is there a way to format an individual cell width? 我在这里看到了许多页面来格式化整个列的宽度,但是有没有办法格式化单个单元格的宽度? My issue is that I'm creating a sheet that has a "header" more or less, several rows where each column is a different length because they're been mergered to include unique information.
我的问题是,我正在创建一个或多或少具有“标题”的工作表,其中的几行各列的长度不同,因为它们被合并为包含唯一信息。 Below this section will be a standard dataframe, which the entire column's width will need to be formatted to the data.
在此部分下面将是一个标准数据框,需要将整个列的宽度格式化为数据。 But for the first five rows I need to specify unique width values.
但是对于前五行,我需要指定唯一的宽度值。 Is this possible?
这可能吗?
xlswriter has a format feature saying how to change the properties of the spreadsheet cell: https://xlsxwriter.readthedocs.io/format.html xlswriter具有格式功能,说明如何更改电子表格单元格的属性: https ://xlsxwriter.readthedocs.io/format.html
import xlsxwriter
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('Expenses01.xlsx')
worksheet = workbook.add_worksheet()
cell_format = workbook.add_format()
cell_format.set_bold()
cell_format.set_font_color('red')
There are properties to do everything including change the width of the cell. 有一些属性可以执行所有操作,包括更改单元格的宽度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.