的Microsoft.Office.Interop.Excel:如何应用边界一个细胞 [英] Microsoft.Office.Interop.Excel: How to Apply a border to ONE CELL

查看:239
本文介绍了的Microsoft.Office.Interop.Excel:如何应用边界一个细胞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待边框适用于使用的Microsoft.Office.Interop.Excel库一个单元格。



我运行一个while循环是搜索某列中的一个空单元格,一旦细胞被发现欲边框适用。



我知道,在这个使用范围很多论坛,但我不能使用范围功能,因为我不知道是什么细胞它被应用到究竟。



我的想法是:



(Excel.Range)xlWS.Cells [行1] .Borders。的LineStyle =(任何值);



有何建议? (除了链接到其他论坛,我已经经历吨的形式看)?


解决方案

  Excel.Range范围= xlWS.UsedRange; 
Excel.Range电池= range.Cells [行,列];
Excel.Borders边界= cell.Borders;

border.LineStyle = Excel.XlLineStyle.xlContinuous;
border.Weight = 2D;



希望这可以帮助别人!把一个细线边框细胞[行,列]!


I am looking to apply a border to one cell using the Microsoft.Office.Interop.Excel library.

I am running a while-loop that is search for a empty cell within a certain column, once the cell is found I want to apply a border to it.

I know there many forums on this using Ranges, but I can't use the range functionality since I do not know what cell it is being applied to exactly.

My idea was:

(Excel.Range)xlWS.Cells[row,1].Borders.LineStyle = (Whatever Value);

Any advice? (besides links to other forums, I already looked through tons of forms)?

解决方案

            Excel.Range range = xlWS.UsedRange;
            Excel.Range cell = range.Cells[row,column];
            Excel.Borders border = cell.Borders;

            border.LineStyle = Excel.XlLineStyle.xlContinuous;
            border.Weight = 2d;

Hope this helps someone! Puts a thin line border around cell[row,column]!

这篇关于的Microsoft.Office.Interop.Excel:如何应用边界一个细胞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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