我正在寻找如何将数据网格(不是数据网格视图)导出到 Excel。我正在研究 VS 2003 Winform。我在网上看,但没有结果,我发现解决方案只是关于 Datagridview VS 2010 (asp)。
这是我到目前为止所拥有的:
lblMessage.Text = "";
// Export all the details
try
{
// Get the datatable to export
DataTable dtEmployee = dsEmployee.Tables["Employee"].Copy();
// Export all the details to Excel
RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win");
objExport.ExportDetails(dtEmployee, Export.ExportFormat.Excel, "C:\\EmployeesInfo.xls");
lblMessage.Text = "Successfully exported to C:\\EmployeesInfo.xls";
}
catch(Exception Ex)
{
lblMessage.Text = Ex.Message;
}