在将数据导出到Excel时格式化单元格 [英] Format Cells while in Exporting data to Excel
问题描述
大家好,
目前我在做导出到Excel的概念。我知道如何做到这一点,现在它工作正常。但我的问题是什么...
点击导出按钮后,打开一个Excel工作表并显示其中的总数据,但我也想要格式化单元格.. 。
例如:我有一个列(doc,date,serial no)
now我想要
doc - uneditable mode
date - text format
serial no - text format
如何实现这个....
任何人都可以帮我解决这个问题....
注意:到现在我正在将Excel DataTable数据导出到Excel,我没有使用网格控件
以前我从不使用Interop Classes ...
我过去3天试过这个词你能不能帮我解决这个问题来满足我的需求要求..
Hi guys,
Currently i''m doing Export to Excel concept. I know how to do this upto now it''s working fine . But what is my question is ...
After Clicking the Exporting button one excel sheet is opened and display the total data in that but i want formated cells also...
for ex: i have a columns like ( doc, date,serial no )
now i want
doc -- uneditable mode
date -- text format
serial no -- text format
how to achieve this ....
can anyone help me out of this....
Note: Upto Now i''m doing Export DataTable data to Excel , i''m not using Grid controls
Previously i never use Interop Classes...
I tried for this past 3 days onwords can you please help me out of this to satisfy my requirement..
string attachment = "attachment; filename=EMS_BnF_Update.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
string tab = "";
foreach (DataColumn dc in dsExcelUpdate.Tables[0].Columns)
{
Response.Write(tab + dc.ColumnName);
tab = "\t";
}
Response.Write("\n");
int i;
foreach (DataRow dr in dsExcelUpdate.Tables[0].Rows)
{
tab = "";
for (i = 0; i < dsExcelUpdate.Tables[0].Columns.Count; i++)
{
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();
推荐答案
您好b $ b
尝试此解决方案
http://csharp.net-informations.com/excel/csharp-excel-tutorial。 htm [ ^ ]
你应该在那里得到一些很棒的教程。我希望它有所帮助
Hi
try this solution
http://csharp.net-informations.com/excel/csharp-excel-tutorial.htm[^]
you should get some great tutorials there. I hope it helps
如果不使用Interop或一些繁重的自定义Excel作者,则无法格式化单元格。最简单的方法是:
http://support.microsoft.com/kb/302084 [ ^ ]
You cannot format the cells without either using Interop or some heavy custom excel writer. The easiest method is this:
http://support.microsoft.com/kb/302084[^]
这篇关于在将数据导出到Excel时格式化单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!