[英]Instead of using column alphabets while formatting, can I use column headers in xlsxwriter
Can I use column header names instead of column alphabets for editing in pandas xlsxwriter?我可以使用列 header 名称而不是列字母在 pandas xlsxwriter 中进行编辑吗?
This is for python 3.x using pandas and latest xlsx writer这适用于使用 pandas 和最新 xlsx 编写器的 python 3.x
worksheet.set_column('F:H', 30)
I want something like我想要类似的东西
worksheet.set_column('colname1:colname2', 30)
I don't want to use dictionary or assign column names to the default cell notation, it has to be dynamic(the position of the column shouldn't matter)我不想使用字典或将列名分配给默认单元格符号,它必须是动态的(列的 position 无关紧要)
In almost all cases in XlsxWriter you can use zero indexed (Row, Col)
notation instead of A1
range notation.在 XlsxWriter 中的几乎所有情况下,您都可以使用零索引(Row, Col)
表示法而不是A1
范围表示法。
From the XlsxWriter docs on set_column()来自set_column() 上的 XlsxWriter 文档
It is also possible, and generally clearer, to specify a column range using the form of A1 notation used for columns.使用用于列的 A1 表示法形式来指定列范围也是可能的,而且通常更清楚。 See Working with Cell Notation for more details.有关更多详细信息,请参阅使用单元表示法。
Examples:例子:
worksheet.set_column(0, 0, 20) # Column A width set to 20.
worksheet.set_column(1, 3, 30) # Columns B-D width set to 30.
worksheet.set_column('E:E', 20) # Column E width set to 20.
worksheet.set_column('F:H', 30) # Columns F-H width set to 30.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.