Do we need to install Microsoft office in server for Excel import in Asp.net?

前端 未结 3 1552
遥遥无期
遥遥无期 2020-12-16 06:08

do we need to install Microsoft office in server to run a application to import data from excel file to mssql database ?

any suggestions or ideas ?

the code

3条回答
  •  既然无缘
    2020-12-16 06:55

    If you are reading only xls files then use Microsoft.Jet.OLEDB.4.0 that is inbuilt with your .net framework.

    If you are reading xlsx files then use Microsoft.ACE.OLEDB.12.0. The drivers for this can be download freely from Microsoft site. You don't need to install Microsoft officer for interoping.

    Use following connection string

        string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;  
    Data Source=" + path + ";Extended Properties=Excel 12.0;HDR=YES";
    

    Download drivers from here

    Refer this for running example

提交回复
热议问题