awalker89 / openxlsx

R package for .xlsx file reading and writing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disregard merged columns when calculating automatic column width

mhermans opened this issue · comments

I am writing crosstables to Excel, and to add a caption for the table, I use one row with merged cells above the table.

However, this clashes with the nicely working auto option for the column widths, as the column where the caption starts is expanded to accomodate the entire caption-string, which is not needed.

Is it possible to disregard the contents of merged cells when calculating the width of the single colums that these merged cells span?

If not (or if it is a to specific feature), is there a workaround?

commented

Thanks I really like this idea. 've added the parameter "ignoreMergedCells" to setColWidths. If TRUE, any cell that is included in any merge is excluded from the column width calculations.

I'll close this issue once I've finished testing.

Thanks for the very fast follow-up! I will try it out.

FYI, I'm working on a set of helper-functions to dump a large amount of crosstabs and similar tables to an Excel-file. Still pretty rough, but functional & openxlsx has been very nice to build on.