.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Searching Duplicate values in Excel - MVC

Posted By:      Posted Date: September 25, 2010    Points: 0   Category :ASP.Net

Hi everyone,

I am working in an MVC .net project. I use the below method to search for duplicate values in an excel sheet before uploading.

The dataset contains all the rows in the excel sheet. the colName is one of the columns in the excel sheet where the duplication is checked. the values in the particular are checked , iterated and if unique a copy stored in hashtable and the duplicate is stored in array list and the entire row containing the duplicate cell value is deleted.

"Here i only compare all the values in a single column of an excel sheet(colName).  I would like to send two columns and compare a cell value in both the columns".

Can anybody help me.

public DataSet RemoveDuplicateRows(DataSet dSet, string colName)
            Hashtable hTable = new Hashtable();
            ArrayList duplicateList = new ArrayList();

            foreach (DataRow drow in dSet.Tables[0].Rows)
                if (!string.IsNullOrEmpty(drow[colName].ToStr

View Complete Post

More Related Resource Links

Excel 2007 Filter on multiple values

Hi Everyone,How do I use Excel 2007 Pivot Table's label filters/value filters to filter with multiple conditions? for example, I want to get all customers with customer name start with "G" and doesn't include "E" and with measure>100 and measure between 50-60.Regards,George

How do you add duplicate fields to a SSRS custom report and receive differtent output values.

I have built a custom report in SSRS 2008 using fields for supplier and customer.   I have added a Parent Row Group using the Supplier field for the group expression and used the Customer Details as my child details group. This returns a list of all customers for each supplier.   (Supplier | = Customer details ( Name, Dob etc.)   How would I add an additional Supplier field to the customer details returning only values for other Suppliers used by a customer, not the value of the Supplier listed in the Parent Group?

Importing Data from Excel into SQL Server using SSIS: some datetime values appear as NULLS How to Re

I created a Package in the Business Intelligence studio to Import data from Excel file  into SQL Server 2005 using a Excel Source and a OLE DB Destination that uses a data convertion transformation before it reaches the destination a mjority of the data is copied over. However i am having 2 Issues. 1. In the Date field some of the values appear as Null in SQL Server 2. I need to change the format of the date in Excel from dd/mm/yyyy to mm/dd/yyyy before inserting into SQL Server if Possible. I am not sure of the solution for Ques 1 but i attempted using a script task for #2 It did not work. Please Advice what the best way to proceed Thanks.

how to duplicate values to a new repeating section from a previous one?

It's nice to have repeating section. Is there any easy way to duplicate values from a previous section to a new one, even with manual process (eg, click a button)? THanks,

Duplicate Product() function from excel


I need to duplicate the excel function PRODUCT(1+D76:K76)-1

I need to replace the line Sum(Rtn) as Year with PRODUCT(1+D76:K76)-1   where rtn would be  the columns my current sql is :

Sum(Rtn) as Year,
Sum(case when Month([Date])=1 then Rtn else null end) as [1], 
Sum(case when Month([Date])=2 then Rtn else null end) as [2], 
Sum(case when Month([Date])=3 then Rtn else null end) as [3], 
Sum(case when Month([Date])=4 then Rtn else null end) as [4], 
Sum(case when Month([Date])=5 then Rtn else null end) as [5], 
Sum(case when Month([Date])=6 then Rtn else null end) as [6], 
Sum(case when Month([Date])=7 then Rtn else null end) as [7], 
Sum(case when Month([Date])=8 then Rtn else null end) as [8], 
Sum(case when Month([Date])=9 then Rtn else null end) as [9], 
Sum(case when Month([Date])=10 then Rtn else null end) as [10], 
Sum(case when Month([Date])=11 then Rtn el

Excel Export - Toggled details duplicate


I have a report that is duplicating rows when toggeled within the excel export.  I do not have this problem in the report viewer, it only happens when exported to excel.  Also, it does this in SQL 2008 and not SQL 2005. 

Any ideas on what could cause the duplication in excel and not the report viewer?



no duplicate values in column


I have a view that displays entry for contacts and their role.  A single contact_pk value may have 2 or 3 entries for it. 

I need to have the query for this only return a contact pk value once.

  RIGHT OUTER JOIN tbl_join_contact_roles ON (tbl_contacts.contact_pk = tbl_join_contact_roles.contact_pk)
  LEFT OUTER JOIN tbl_contact_roles ON (tbl_join_contact_roles.contact_role_pk = tbl_contact_roles.contact_role_pk)


So is there something I can add to this query so that no duplicate values for tbl_join_contact_roles.contact_pk get returned?

SSIS excel data source numeric values returned as null

Hello everyone, long time no see!, I have a problem and was hoping someone can help me:
I'm using SSIS 2005 Enterprise edition,  I'm creating a package that reads an excel (xls) file using the "excel source" component, and it dumps the data into an OLEDB destination (a sql server).
When I drag the excel source component and create the excel connection to my file the component automatically reads the columns and their datatypes.

The problem is that I have a column which has numeric data and the package uploads as NULL every number that starts with a zero. (note: in excel this column is formatted as "text", despite it has only numbers, because it's the only way excel maintains the left sided zeros).
So I checked the data types by right clicking the excel source component -> show advanced editor and my surprise is that this column's data type is detected as double-precision float, and it doesn't let me change it.

I tried the answer posted here: http://devselekta.blogspot.com/2007/09/ssis-excel-data-source-values-returned.html but it only works when the first row of data has a number beginning with zero on this column.
Someone knows how to get the data imported correctly? Thanks in advance.

Picture Library - Allow Name column to accept duplicate values


I'm wanting to create a Picture Library that will accept images with the same name (e.g. 001.jpg and 001.jpg).  Currently I get an error as they 'name' column must be unique. 

Is there a way to allow the 'name' column to accept duplicate names.

Thanks Jamie

Values from Excel sheet in Infopath?



I am trying to find a way to get values from an Excel sheet in my drop down field for exchange rates.
Without any success.
Can this somehow be done?


Prevent duplicate values to be entered into list


Hi, my scenario is that I got a list of Candidate details, This list i edited in Infopath 2010 and created a user interface, I am filling the candidate details list through this interface,

my problem is that I dont want to enter duplicate values to be entered into the list, i want to show a message in the form that when ever duplicate values are entered I watn to show a message

normally it is easy to prevent this by using workflow, but i dont understand how can i do this with the form,

is there any way that once i run the workflow i can pass the value to the form and check there and show a message


Excel to sql import null values issue

How to handle null data or empty rows in the excel, as i got no record in mydestination table.

Navin.D http://navind.spaces.live.com/

Using the Client Object Model to read values from Excel file produces 504 error



I use the Client Object Model to retrieve and read values from an Excel file. This is triggered in an Event Receiver on the Document Library where the Excel file lives. I use a simple CAML Query to retrieve the file. This has worked just fine on a dev/test server. 
Now, I just recently deployed this solution to a production/live server and now this code doesn't work anymore. I get an error saying 'The remote server returned an error: (504) Gateway Timeout'. This happnes when I try clientContext.ExecuteQuery();

The difference between the two servers is that on the test server (where it works) the solution is sitting as the root site, so to speak. No host headers or nothing.
On the live server, there are several web applications (SharePoint) on the same port, but with different host headers.

I have tried to trace a little bit and I found that on the test server, the url that is used to create the ClientContext object is 'http://<servername>/<webname>'. The url is comes from the following code: web.Url. I tried changing the url to the DNS name the test server has and that resulted in the same error as on the live server.

Does anyone have any idea what I need to do?

Thanks a billion!

Check the if SSAS Roles property is used in excel connection string before returning the values



We are using Excel 2007 to connect to SSAS cubes. We have many roles for a user and all having different permission including different VISUAL TOTAL setting. We want to restrict the user so that he cannot see anything if he is not using the ROLES property in the excel connection string.

At the run time I want to know if the user who is using excel has used ROLES property or not.

Any help will be appreciated

Mr myName

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

Excel Automation in .Net

Excel Automation is a buzz word in both webapps and winapps. In the programming life (like Mr.Anderson neo) I guess almost every one could have come across this word. For others let me go further in detail. Excel Automation is automating some or all of the process involved in creating or updating excel worsheets.

display data into GridView from excel sheet

I have to display data from excel sheet into my gridview and also I need to figure out a way to store data into excel files from my web page. I am using C# 3.5, VS 2008.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend