导出到Excel的错误 [英] error in export to excel

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

问题描述

您好我的索引超出范围异常....在下面的行..

Hi I am getting index out of range exception....in below line..

rng.set_Item(16, 1, odr60["phase_name"].ToString().Replace("\r", "").Replace("\\n", "\n").Replace("\\r", ""));



以下是代码......请帮我解决这个问题


below is the code...Please help me to resolve this issue

  strNonWeighedTotalTab = Session["TotalNonWeightedExcel"].ToString();
            ocmd = new OracleCommand();
            ocmd.Connection = DBConn;
            ocmd.CommandText = strNonWeighedTotalTab;
            OracleDataReader odr60 = ocmd.ExecuteReader();
            int cntt2 = 0;
            while (odr60.Read())
            {
                cntt2 = cntt2 + 1;
                rng.set_Item(16, 1, odr60["phase_name"].ToString().Replace("\r", "").Replace("\\n", "\n").Replace("\\r", ""));
                rng.set_Item(16, 2, odr60["req_analysis_high"].ToString().Replace("\r", "").Replace("\\n", "\n").Replace("\\r", ""));
                rng.set_Item(16, 3, odr60["req_analysis_medium"].ToString().Replace("\r", "").Replace("\\n", "\n").Replace("\\r", ""));
}

推荐答案

Excel.Range rng = null;然后我实际上期待一个NullRefereceException。那么,看看你将范围设置为某个值的地方。然后使用更大的范围,允许足够数量的行和列。
"Excel.Range rng = null;" Then I'd actually expect a NullRefereceException. Well, look at the place where you set the range to some value. And then use a "bigger" range allowing for a sufficient amount of rows and columns.


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

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