.NET C#练成列自动调整 [英] .net c# excel column AutoFit

查看:134
本文介绍了.NET C#练成列自动调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作在C#中的Excel对象。我要自动调整列,但像这样的:我想要的列宽度比自动调整方式设定什么5大。

I'm working with an excel object in c#. I want to auto-fit the columns, but like this: I want the columns' width to be 5 bigger than what the AutoFit method set.

我怎样才能得到宽度自动调整()用于后?

How can I get the width after AutoFit() is used?

我怎样才能让列5比这个宽度变大?

How can I make the columns 5 bigger than this width?

推荐答案

如果您希望使用的选择对象,并有智能感知与早​​期绑定,您需要在选择对象转换为范围第一:

If you wish to use the Selection object and have IntelliSense with early binding, you need to cast the Selection object to a Range first:

Excel.Range selectedRange = (Excel.Range)myExcelApp.Selection;    
selectedRange.Columns.AutoFit();

foreach (Excel.Range column in selectedRange.Columns)
{
    column.ColumnWidth = (double)column.ColumnWidth + 5;
}

迈克 -

-- Mike

这篇关于.NET C#练成列自动调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆