cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Export: Make column width same as largest cell value of that column

Former Member
0 Kudos

Hello!

I´m using CR2008 SP2 to export reports with a dynamic number of fields to a number of formats, including excel. I have enabled CanGrow on all fields and this is working in the sence that when a value exceeds width of cell, it increases the size of the cell vertically and continues there. I would very much prefer the functionality of "dubbelclicking" a column border in excel to make it as wide as the largest value therein. That is, increasing cellsize horizontally instead of vertically. Is this possible to achieve?

/regards

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Andrew

Thank you for your reply, but I think you missunderstood my question.

When the export is done and the excel-file is complete, I want the column width to be as wide as that of the widest value of that column. like this:

column1

val1

val2

val3 is a little wider than than that

In this scenario I would want the entire column to be as wide as "val3 is a little wider than than that", when the export is complete.

Former Member
0 Kudos

when you export a report to Excel, in the Excel Format Options dialog box there is a radio button i.e. Column Width Based on an Object in.

Did you try to set this optin to different values i.e. page Header,Details etc.?

Former Member
0 Kudos

Hello Ashwin, thanks for your reply.

I create the report programmatically, so I do this:

excelOptions.BaseAreaType = ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindDetail;

which I think would correspond to your suggestion, but to no avail.

Former Member
0 Kudos

Solved id by dynamically changing columnwidth depending on values in a column.

longest stringvalue -> to pixels -> to Twips -> Value of Column.Width (and matching header-column).

If anyone else is going to do this dont forget to update Column.Left as well, otherwise the columns will overlap

Former Member
0 Kudos

Hi Magnus,

In Excel, highlight the entire columns -- so click A, B etc not just highlighting the range. In the bar at the top where it says A, B etc move the widest column a little bit to the left or right. All columns will then go to that size. Double clicking can work but it just auto fits the content.

Regards,

Andrew