日期:2014-05-17  浏览次数:21473 次

为什么我删除excle3行后总是有一行没删掉?
我用C#在向excle模板中写入数据时,想把13行到15行删除掉,代码如下:
                    int startRowIndex = 13;
                    int endRowIndex = 16;
                    for (int i = startRowIndex; i < endRowIndex; i++)
                    {

                        m_objSheet.Cells[i, 1].EntireRow.Delete  (Excel.XlDirection.xlDown);                       
                    }
C# excle 删除行

------解决方案--------------------
索引重置了?
    int startRowIndex = 13;
                     int endRowIndex = 15;
                     for (int i = endRowIndex; i > startRowIndex; i--)
                     {

                         m_objSheet.Cells[i, 1].EntireRow.Delete  (Excel.XlDirection.xlDown);                       
                     }
------解决方案--------------------
友情链接: 爱易网 云虚拟主机技术 云服务器技术 程序设计技术 开发网站 APP开发教程
Copyright © 2013-2026 爱易网页 当前在线:932人  网站在15时57分8秒内访问总人数:189730人 当前 59.24%  粤ICP备18100884号-2