Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用c.net从excel中提取重复记录_Asp.net_Excel - Fatal编程技术网

Asp.net 使用c.net从excel中提取重复记录

Asp.net 使用c.net从excel中提取重复记录,asp.net,excel,Asp.net,Excel,我是asp.net新手。我有一张excel表格,其中有许多重复记录。我需要单独显示重复记录,说明这些是重复记录。我该怎么做呢。 是否有特定的查询仅获取重复项。请帮助 好的,您没有提供很多关于您遇到问题的细节,因此我将为您提供一个关于您需要做什么的良好概述。然后你可以看看它,通过例子,看看你是否仍然困惑或遗漏了什么 基本上,您将使用ADO.NET Jet OLEDB与Excel的连接来查询数据。基本上,您将执行SELECT语句。现在我不相信您可以执行SELECT DISTINCT,这是最简单的,请

我是asp.net新手。我有一张excel表格,其中有许多重复记录。我需要单独显示重复记录,说明这些是重复记录。我该怎么做呢。
是否有特定的查询仅获取重复项。请帮助

好的,您没有提供很多关于您遇到问题的细节,因此我将为您提供一个关于您需要做什么的良好概述。然后你可以看看它,通过例子,看看你是否仍然困惑或遗漏了什么

基本上,您将使用ADO.NET Jet OLEDB与Excel的连接来查询数据。基本上,您将执行SELECT语句。现在我不相信您可以执行SELECT DISTINCT,这是最简单的,请尝试验证,但您至少可以执行SELECT语句将所有数据放入DataTable

数据表中包含数据后,将应用一个视图,该视图将允许您过滤掉重复的数据。基本准则类似于:

ds.Tables["YourTable"].DefaultView.ToTable(true,”uniqueID”);
你可以根据自己的需要来调整。以下是一些帮助您入门的链接:


首先,我建议您使用ExcelReaderFactory来读取excel记录

VB.Net Code

Dim excelReader As IExcelDataReader = Nothing
Dim result As DataSet = Nothing
Dim stream As FileStream = Nothing
stream = File.Open(Server.MapPath("FilePath.xls"), FileMode.Open, FileAccess.Read)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream)
result = excelReader.AsDataSet()
stream.Close()
stream.Dispose()
excelReader.Close()
result.Dispose()
C代码

IExcelDataReader excelReader = null;
DataSet result = null;
FileStream stream = null;
stream = File.Open(Server.MapPath("FilePath.xls"), FileMode.Open, FileAccess.Read);
excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
result = excelReader.AsDataSet();
stream.Close();
stream.Dispose();
excelReader.Close();
result.Dispose();
获取datatable中的数据后,可以使用select函数


最后处理数据表。

显示您的代码,以及如何从Excel中提取数据。