如何边框使用C#来设置围绕多个单元格在Excel中 [英] How can a border be set around multiple cells in excel using C#

查看:111
本文介绍了如何边框使用C#来设置围绕多个单元格在Excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,创建Excel文件的项目。

I am working on a project that creates excel files.

我有麻烦放置在多个单元格边框组织Excel文件。

I am having trouble placing a border on multiple cells to organize the excel file.

比方说,我想从单元格B5到B10的边框。不应该有B5,B6,B7,...

Let's say I want a border from cell B5 to B10. There shouldn't be borders between B5, B6, B7,...

目前,我有这样的代码之间的边界:

Currently, I have this code:

workSheet_range = worksheet.get_Range("B5", "B10");
workSheet_range.Borders.Color = System.Drawing.Color.Black.ToArgb();



这使得边界,但是它把每一个细胞,而不是一个大边框的所有单元格周围的边框。

It makes the borders, however it places a border around every cell instead of one big border for all cells.

我怎样才能做到这一点?

How can I accomplish this?

推荐答案

您需要单独设置这些

.Borders[Excel.XlBordersIndex.xlEdgeBottom] 
.Borders[Excel.XlBordersIndex.xlEdgeRight]
.Borders[Excel.XlBordersIndex.xlEdgeLeft]  
.Borders[Excel.XlBordersIndex.xlEdgeTop]

这篇关于如何边框使用C#来设置围绕多个单元格在Excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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