急 C#DataTable导出成Execl 总是提示object未包含"get_Range"的定义
各位高手请帮帮忙,在下面红色区域总是提示:object未包含"get_Range"的定义,导致导出数据失败
try
{
System.Data.DataTable objDtResult = new System.Data.DataTable();
objDtResult.Columns.Add("姓名");
objDtResult.Columns.Add("性别");
objDtResult.Columns.Add("年龄");
objDtResult.Columns.Add("身份证号");
objDtResult.Columns.Add("职业工种");
objDtResult.Columns.Add("工作单位");
objDtResult.Columns.Add("套餐名称");
objDtResult.Columns.Add("企业分组");
//指定数据源
string m_strSerName = string.Empty;//套餐名
string m_strGroup = string.Empty;//分组名
string m_strSex = "男,女";
string m_strEnterprise = this.m_objViewer.m_dgvEnterpriseDetail.Rows[0].Cells["entname_vchr"].Value.ToString();
for (int intI = 0; intI < this.m_objViewer.m_dgvEnterpriseDetail.Rows.Count; intI++)
{
if (intI == 0)
{
m_strSerName = this.m_objViewer.m_dgvEnterpriseDetail.Rows[intI].Cells["sername_vchr"].Value.ToString();
m_strGroup = this.m_objViewer.m_dgvEnterpriseDetail.Rows[intI].Cells["entgroupname_vchr"].Value.ToString();
}
else
{
m_strSerName += "," + this.m_objViewer.m_dgvEnterpriseDetail.Rows[intI].Cells["sername_vchr"].Value.ToString();
m_strGroup += "," + this.m_objViewer.m_dgvEnterpriseDetail.Rows[intI].Cells["entgroupname_vchr"].Value.ToString();
}
}
string saveFileName = "";
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.DefaultExt = "xls";
saveDialog.Filter = "Excel文件|*.xls";
saveDialog.FileName = "";
saveDialog.ShowDialog();
saveFileName = saveDialog.FileName;
if (saveFileName.IndexOf(":") < 0) return; //被点了取消
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
{
MessageBox.Show("无法创建Excel对象,可能您的电脑未安装Excel");
return;
}
Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks;
Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];//取得sheet1
//新方法
iCare.Pub.Utility.clsExcelExporter m_objExcelExporter = new Pub.Utility.clsExcelExporter();
m_objExcelExporter.m_mthExport(saveFileName);
//写入标题
for (int i = 0; i < objDtResult.Columns.Count; i++)
{