Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Fixed Columns Widths, No Auto-Expand For UltraWebGridExcelExporter
posted

I am using UltraWebGridExcelExporter and passing in a UltraWebGrid. I setup the columns widths up-front, for example:

myGrid.Columns[0].Width = Unit.Percentage(10);
myGrid.Columns[1].Width = Unit.Percentage(10);
myGrid.Columns[2].Width = Unit.Percentage(20);
myGrid.Columns[3].Width = Unit.Percentage(20);
myGrid.Columns[4].Width = Unit.Percentage(20);
myGrid.Columns[5].Width = Unit.Percentage(20);


Then I simply pass the entire UltraWebGrid into the UltaWebGridExporter:

Random myRandom = new Random();

myExcelExport.WorksheetName = "Data";
myExcelExport.DownloadName = myRandom.Next(10000000, 99999999).ToString();
myExcelExport.Export(myGrid);

The problem I am having is some of the text going into the columns is larger than the percentage defined above as the widths. What happens is the exported excel worksheet widths get auto-expanded to fit the text. I don't want this behavior though as the entire column becomes huge for one record with really long text. I want the width defined fixed as they are defined above, without auto-expansion. Is this possible? Is there a property to accomplish this?

Parents
No Data
Reply
  • 25
    posted

     Specify the column widths in the EndExport event handler.  If you do it earlier, the values you specify get over-ridden during the row and column exports.

Children
No Data