如何使用编码合并excel中的单元格 [英] how to merge the cells in excel using coding

查看:122
本文介绍了如何使用编码合并excel中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下;



xlsheet.Cells [1,1] =打印日期+ string.Format({0:dd-MMM- yyyy},DateTime.Now);



输出如下;



印刷日期05-Mar -2013。



在excel中,我获得了excel中左侧位置的特定值。



但我想将所需的单元格合并到中心位置。



如何使用编码合并单元格。





如何使用编码。



Rgds,

Narasiman P.

My code as follows;

xlsheet.Cells[1, 1] = " Printed Date " + string.Format("{0:dd-MMM-yyyy}", DateTime.Now);

Output as follows;

Printed Date 05-Mar-2013.

In excel, i get the about in the particular in the Left Position in excel.

But i want to merge the required cells fit into centre position.

how can i merge the cells using coding.


how can i do using coding.

Rgds,
Narasiman P.

推荐答案

使用 Style 对象,例如

Use a Style object, e.g.
Style style = _WorkBook.Styles.Add("MyStyle");
style.HorizontalAlignment = XlHAlign.xlHAlignCenter;
style.VerticalAlignment = XlVAlign.xlVAlignCenter;
xlsheet.Cells[1, 1].Style = style;



另请参阅 http://msdn.microsoft.com/ en-us / library / office / ff194252.aspx [ ^ ]


这篇关于如何使用编码合并excel中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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