导出到C#中的excel [英] Export to excel in C#

查看:81
本文介绍了导出到C#中的excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在将datagrid视图导出到excel.有什么办法可以使列正确对齐.我在C#Windows应用程序中工作

Hi I am exporting a datagrid view to excel. Is there any way to make right align for a column. I a working in C# windows application

推荐答案

例如,如果您想设置第二列的对齐方式,则代码如下:

For example if you want to set the alignment of the second column, here is the code :

var eApp = new Excel.Application { DisplayAlerts = false };
eApp.Workbooks.Open(@"c:\target.xlsx");
eApp.Visible = true;
Worksheet ws = eApp.ActiveSheet;
ws.Columns[2].HorizontalAlignment = XlHAlign.xlHAlignRight;



希望对您有所帮助.



Hope it helps.


您将需要在Office Interop中打开Excel并调整单元格的属性
You will need to the Office Interop to open Excel and adjust the properties of the cells


这篇关于导出到C#中的excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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