如何使用ASP.NET C#读取特定的Excel文档行和列? [英] How to read particular excel document rows and columns using ASP.NET C#?

查看:264
本文介绍了如何使用ASP.NET C#读取特定的Excel文档行和列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经上传了一个带有多个工作表的excel文件。并将excel文档转换为数据表并验证数据表。在这种情况下验证过程。在这个excel中有许多标题,如项目编号,制造商编号......我已经验证在强制字段中是否有任何空单元格将错误消息存储在一个表中,最后我将显示错误表并更正单元格中的标题。现在问题是我将excel转换为数据表一些excel文件那个时候更多的行和列(65536,1048576实际的excel行)(抛出了类型'System.OutOfMemoryException'的异常。)抛出异常。修复excel文档的特定行列。



我尝试了什么:



I have upload one excel file with the multiple sheets.And convert the excel document to data table and validate the data table.many validation process in this case.in this excel have many heading like item number,manufacturer number ... i have validate if any empty cell in mandatory field to store the error message in one table and the finally i will show the error table and correct the cells against the heading.Now the problem is i convert the excel to data table some excel files have more rows and columns(65536,1048576 actual excel row) on that time (Exception of type 'System.OutOfMemoryException' was thrown.) exception is thrown.how to fix the particular row column of the excel document.

What I have tried:

FileStream stream = File.Open(SourceUpload.Fullpath, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
ds = excelReader.AsDataSet();



以上代码我无法修复特定的行和列。怎么做。


Above code i can't fix the particular rows and columns. How to do it.

推荐答案

尝试使用自述文件中的第5种方法:

Try using the 5th method from the readme :
//5. Data Reader methods
while (excelReader.Read())
{
    //excelReader.GetInt32(0);
}


这篇关于如何使用ASP.NET C#读取特定的Excel文档行和列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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