首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

导出EXCEL 报错误

2012-11-07 
导出EXCEL 报异常C# codefor (int i 0 i gridView.RowCount i++){for (int j 0 j gridView.Col

导出EXCEL 报异常

C# code
for (int i = 0; i < gridView.RowCount; i++){                                                                      for (int j = 0; j < gridView.ColumnCount; j++)      {          excel.Cells[i + 2, j + 1] = gridView[j, i].Value.ToString();          Range ra2;                                             ra2 = sheet.get_Range(excel.Cells[1,1]);          ra2.Font.Bold = true;          ra2 = null;       }}


我想根据条件设置单元格格式
实验了一下给每个单元格都设置粗体
结果报异常 HRESULT:0x800A03EC
如果把这段删除就没事了
C# code
          ra2 = sheet.get_Range(excel.Cells[1,1]);          ra2.Font.Bold = true;

单独使用这两行不报错
C# code
          Range ra2;                                             ra2 = null;

谁帮我看看 那里的问题呀
不明白

[解决办法]
Excel文件.Cells[1,1].Font.Bold = true;

热点排行