Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Aug 22, 2017 9:33 pm

Hi,
I am working on a project which needs to auto fit all of the columns in all rows except first 3 rows. Do you know how to do it?


Thanks,
Lucy

lsong
 
Posts: 36
Joined: Wed Feb 01, 2017 4:13 pm

Wed Aug 23, 2017 3:17 am

Hello lsong,

Thanks for your inquiry.
Please kindly note the "autofit column" take a clolum as a whole, it is impossible to only set the "autofit columns" for certain rows. Even you choose a range, the columns in the first three rows will also be auto fitted following the changes by the columns in other rows.
If there's still any doubt, welcome to write back.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Wed Aug 23, 2017 7:35 pm

Could you please send me a code example of how to set autofitcolumn on a worksheet starting with the second column? In my case, I just wanted to skip the first column and autofit with the second column and on.

Thanks,
Lucy

lsong
 
Posts: 36
Joined: Wed Feb 01, 2017 4:13 pm

Thu Aug 24, 2017 1:26 am

Hello Lucy,

Please use the code below.
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(inputfile);
            Worksheet sheet = workbook.Worksheets[0];
           
            //autofitcloumn from the second column
            var destRange = sheet.Range[sheet.FirstRow, 2, sheet.LastRow, sheet.LastColumn];
            destRange.AutoFitColumns();


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Wed Aug 30, 2017 8:30 am

Hi Lucy,

How is the issue now?
Could you please give us some feedback at your convenience?

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.XLS

cron