Import Excel Sheet Data into List RRS feed

  • Question

  • Hi,

    I have 10 columns in Excel file(Sample.xls)  and their names are first,second,third...............ten and there are 20 rows in each
    column and i've a SharePoint 2007 List named as Test and there are ten columns in this list as well and list is filled with data .
    My Requirement is as follows

    I want to write a C# code which can Import the Excel Sheet's all  Data   into the SharePoint 2007 List(Test) but code should be written in the way that first it checks  whether the List is empty or filled with data, if the List is empty then the Code should Import the whole Excel sheet data in that list but if list is filled with data then the code first delete that List(Test) data but the column names should not be deleted only the data which is in the list must be deleted and then import the excel sheet data in that  list.

    Note: First column's data from excel sheet should be inserted into the first column of List,similarly second column data from excel sheet sholud be inserted into the second column of the SharePoint List and so on.

        * Excel Sheet is in 97-2003 version
        * List is of SharePoint 2007  

    can anyone send me the  c# code for this task

    • Edited by Mike Walsh FIN Tuesday, March 22, 2011 6:48 AM 2007 removed from title as default here
    • Moved by Mike Walsh FIN Tuesday, March 22, 2011 6:48 AM programming questions go to the programming forum (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Tuesday, March 22, 2011 5:07 AM