none
Reading a .xls file in C#

    Question

  • Hi,

    I need to parse some data from an Exel file (.xls) i think i can use the 'Excel Objects Library' but when i deploy the project will all machines tha application is run on require Office to be installed?

    If so this is a no goer, what other options i have? (the .xls file in question has multiple sheets and i need data from each sheet at different locations)

    Thanks

    Dora9


    Student [Visual C#.Net / VB.Net]
    • Moved by Larcolais Gong Wednesday, January 26, 2011 9:25 AM (From:Visual C# General)
    Tuesday, January 25, 2011 8:04 PM

Answers

  • Hi,

    Some day back i also face the same scenario. In my case, my client have installed Excel in there system. So i use Excel Interop. If you want some sample plz use the below link

    http://www.codeproject.com/KB/office/ExcelReader.aspx

    That time i same one forum they said like with Excel interop we can read excel data using XML Object. Some third party tools also provide the excel reading option. They support with out office application we can read excel data using there components.

    Use the below link for third party componet

    http://www.gemboxsoftware.com/

    You Can use this. Or you can check how they did.

    I hope this will show the way to find the result.

     


    With Regards, DP
    • Marked as answer by Dora9 Wednesday, January 26, 2011 11:51 AM
    Wednesday, January 26, 2011 8:09 AM
  • Hi,

    In my last post i mention we can read excel using XML object. 

    You can use the below link package. They use XML object only.

    http://excelpackage.codeplex.com/

    I hope this link will resolve your problem


    With Regards, DP
    • Marked as answer by Dora9 Wednesday, January 26, 2011 11:51 AM
    Wednesday, January 26, 2011 10:48 AM
  • If you want to use ExcelPackage, make sure you get the latest version, which is now Excel Package Plus:

    http://epplus.codeplex.com/

    It will only be able to read and write xlsx file format though, not the older xls file format.

    You could also look into commercially available solutions such as Aspose.Cells, which can read and write a multitude of cell based file formats, including Excel 2003 and 2007 file formats.

     

    • Marked as answer by Dora9 Wednesday, January 26, 2011 11:51 AM
    Wednesday, January 26, 2011 11:03 AM

All replies

  • Hi,

    You have the excel Interop for Excel manipulations contents.

    Use the below link

    http://msdn.microsoft.com/en-us/library/ms173186(v=vs.80).aspx

    I hope this will useful for you.

     


    With Regards, DP
    Tuesday, January 25, 2011 8:09 PM
  • hi
    can you tell in detail about , what you are trying to do ??

    to read data form excel you can even use odbc adapter and fill your datasets..

    Tuesday, January 25, 2011 9:55 PM
  • Hi

    "You have the excel Interop for Excel manipulations contents."

    As i understand it the user of the appllication must have Office installed which is no good for my application (as they will not have office).

    "can you tell in detail about , what you are trying to do ??"

    I need to read data from a specific cell in several sheets.

    Thanks

    Dora9


    Student [Visual C#.Net / VB.Net]
    Tuesday, January 25, 2011 11:06 PM
  • ...

    I need to read data from a specific cell in several sheets.

    Thanks

    Dora9


    Student [Visual C#.Net / VB.Net]
    For this type of requirement, it would be easiest to use the Excel PIA.  Otherwise, you can use OLEDB and iterate over the data, until you find the specific piece, you need.  It's rather difficult to use: SELECT Z45 FROM [Sheet1$].
    Tuesday, January 25, 2011 11:19 PM
  • Hi,

    by Excel PIA do you mean the Excel Objects Library? If so how do i write the code such that it will work with Office 2007, 2010 etc as i have no idea which the user has installed.


    THanks,

    Dora9


    Student [Visual C#.Net / VB.Net]
    Tuesday, January 25, 2011 11:21 PM
  • Hi,

    Some day back i also face the same scenario. In my case, my client have installed Excel in there system. So i use Excel Interop. If you want some sample plz use the below link

    http://www.codeproject.com/KB/office/ExcelReader.aspx

    That time i same one forum they said like with Excel interop we can read excel data using XML Object. Some third party tools also provide the excel reading option. They support with out office application we can read excel data using there components.

    Use the below link for third party componet

    http://www.gemboxsoftware.com/

    You Can use this. Or you can check how they did.

    I hope this will show the way to find the result.

     


    With Regards, DP
    • Marked as answer by Dora9 Wednesday, January 26, 2011 11:51 AM
    Wednesday, January 26, 2011 8:09 AM
  • Hi Dora9,

    Thank you for posting. I'll help you moving your post to Excel for Developer forum. You will get more helfpul suggestions there.

    Best Regards,

    Larcolais


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 26, 2011 9:25 AM
  • Hi,

    In my last post i mention we can read excel using XML object. 

    You can use the below link package. They use XML object only.

    http://excelpackage.codeplex.com/

    I hope this link will resolve your problem


    With Regards, DP
    • Marked as answer by Dora9 Wednesday, January 26, 2011 11:51 AM
    Wednesday, January 26, 2011 10:48 AM
  • If you want to use ExcelPackage, make sure you get the latest version, which is now Excel Package Plus:

    http://epplus.codeplex.com/

    It will only be able to read and write xlsx file format though, not the older xls file format.

    You could also look into commercially available solutions such as Aspose.Cells, which can read and write a multitude of cell based file formats, including Excel 2003 and 2007 file formats.

     

    • Marked as answer by Dora9 Wednesday, January 26, 2011 11:51 AM
    Wednesday, January 26, 2011 11:03 AM