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. Image for the cookie policy date
close icon

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

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++)
                worksheet.ImportArray(item.Werte, 1, columnCounter, true);


            #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;

1 Reply

DB Dilli Babu Nandha Gopal Syncfusion Team May 4, 2016 05:05 AM UTC

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.  

Dilli babu. 

Live Chat Icon For mobile
Up arrow icon