We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Change column witdth to the heading(first row) width, the heading should be fully visible

Thread ID:

Created:

Updated:

Platform:

Replies:

123961 May 3,2016 10:39 AM May 4,2016 01:05 AM ASP.NET MVC 1
loading
Tags: XlsIO
Testname
Asked On May 3, 2016 10:39 AM

I have this code:

            List<wert> tempWerte = ...;



            #region Tabelle füllen

            int columnCounter = 1;

            foreach (wert item in tempWerte)
            {
                //for (int i = 0; i < item.Werte.Length; i++)
                //{item.Werte[i]}
                worksheet.ImportArray(item.Werte, 1, columnCounter, true);
                columnCounter++;
            }

            #endregion

            #region Formatierung

            int startRow = 1;
            int startColumn = 1;

            IRange usedRange = worksheet.UsedRange;
            for (int i = startColumn; i <= usedRange.LastColumn; i++)
            {
                usedRange[startRow, i].CellStyle.Font.Bold = true;
                usedRange[startRow, i].BorderAround(LineStyle.Thin);
            }

            usedRange.CellStyle.Font.FontName = "verdana";
            usedRange.CellStyle.Font.Size = 10;

Dilli Babu Nandha Gopal [Syncfusion]
Replied On May 4, 2016 01:05 AM

Hi Testname  

Thank you for contacting Syncfusion support.  

Yes, you can auto-fit the column width by using IRange.AutofitColumns method. The code example illustrating this behavior is available in the following UG documentation link.  


We have also shared a sample illustrating this behavior for your reference which can be downloaded from the following link.  
  

Please let us know if you have any concerns.  

Regards,  
Dilli babu. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;