导出到Excel数据 [英] Export To Excel Data

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

问题描述

我有一个GridView,它正在与数据表中的数据绑定,我将从表中过滤数据,然后绑定到Gridview,

如何将数据导出到绑定到gridview的Excel。



请尽快帮助我



I Have a GridView, which is getting bind with data from data table and i will filter data from table and then bind to Gridview,
How to Export data to Excel which is binded to gridview.

Please Help Me ASAP

BindRequestDetails();
           //dtRequestDetails = dsRequests.Tables["CertificationRequest"];
           DataTable dtReport = dtRequestDetails;
           string[] strColumns = { "RequestID", "RequestStatus", "EmployeeName", "ProjectName", "CertificationName", "PercentageObtained", "PassingPercentage", "ExpectedExamFee", "ActualExamFee", "ReimbursementAmount", "ValidTillDate", "PrimarySkills" };
           DataTable reportTable = dtReport.DefaultView.ToTable(dtReport.TableName, false, strColumns);
           string strFileNameForExport = "Report.xls";
           reportTable.Columns["RequestID"].ColumnName = "Request ID";
           reportTable.Columns["RequestStatus"].ColumnName = "Request Status";
           reportTable.Columns["EmployeeName"].ColumnName = "Employee Name";
           reportTable.Columns["ProjectName"].ColumnName = "Project Name";
           reportTable.Columns["CertificationName"].ColumnName = "Certification Name";
           reportTable.Columns["PercentageObtained"].ColumnName = "Percentage Obtained";
           reportTable.Columns["PassingPercentage"].ColumnName = "Passing Percentage";
           reportTable.Columns["ExpectedExamFee"].ColumnName = "Expected Exam Fee";
           reportTable.Columns["ActualExamFee"].ColumnName = "Actual Exam Fee";
           reportTable.Columns["ReimbursementAmount"].ColumnName = "Reimbursement Amount";
           reportTable.Columns["ValidTillDate"].ColumnName = "ValidTill Date";
           reportTable.Columns["PrimarySkills"].ColumnName = "Primary Skills";

           try
           {
               OCSCommon.GenerateExcelAndDownload(strFileNameForExport, reportTable);
           }

推荐答案

点击此处查看从数据表导出到excel

< a href =http://kishsharmasoftcode.blogspot.in/> http://kishsharmasoftcode.blogspot.in/ [ ^ ]
Check here for Export to excel from datatable
http://kishsharmasoftcode.blogspot.in/[^]


我最近回答了一对这样的情况。以下是微软的演练: http://support.microsoft.com/kb/306022 [ ^ ]。



听起来像你可能遇到了一个常见的问题 - 你编码正确,但处理速度很慢。为了加快速度,通过数组输出到Excel到一个范围而不是逐个单元格。上面的Microsoft链接包含了一个示例。
I've answered a couple just like this recently. Here's Microsoft's walkthrough: http://support.microsoft.com/kb/306022[^].

It sounds like you may be experiencing a common problem--you code it right, but the processing is very slow. To speed that up, output to Excel via an array into a range instead of cell by cell. The Microsoft link above includes an example of that.


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

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