naftalimich
naftalimich

Reputation: 411

xlsxwriter - Set Width of Individual Cell

The only method in the worksheet docs that deals with width is set_column which requires a range of columns.

I have a pivot table where one header cell width is equal to that of multiple cells in the succeeding rows.

Something like this:

                  ------Monday------    ------Tue---------  --------Wed-------
name  hourofdday   calls emails notes    calls emails notes  calls emails notes 
fred   9:00-9:59    29    21    19       78     78     11     42   78      12
     10:00-10:59    88    89    89       83     88     34     82   83      11

I know it's possible because pandas is able to output essentially what I'm looking for save for that I'm looking to make adjustments to the sizes.

Upvotes: 2

Views: 1352

Answers (1)

naftalimich
naftalimich

Reputation: 411

The answer is that ... you cannot adjust the width of an individual cell without respect to the column and this isn't an xlsxwriter limitation but a limitation of Excel itself.

The way pandas does it is by merging multiple header cells for similar effect.

So the way to handle the goal of this question, namely, to size the header row cell proportional to the sum of its related subheader row cells is to size the the columns according the sub header cells and to merge the cells in the header related to the sub header cells into a single cell.

Upvotes: 3

Related Questions