Hi,
I'm doing a project in ASP.NET 2.0 with C#.I want to upload excel files and have to transfer those data into an SQLServer database file using C# coding.I'm able to upload the excel file using fileupload control in ASP.NET 2.0.
But problem is while transfering it to the database file.I tried it with some code that creates an excel application instance as below:
Using System;
using Range=Microsoft.Office.Interop.Excel.Range;
using Office=Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application xlsApp=new Excel.Application;
Excel.Workbooks xlsWbs;
Excel.Workbook xlsWb ;
Excel.Sheets xlsSheet;
Excel.Worksheet workSheet;
Excel.Range xlsCell;
.
.
.
.
xlsWbs=xlsApp.Workbooks;
xlsWbs = (global::Excel.Workbooks)xlsApp.Workbooks.Open(Ser ver.MapPath("~\fn1"), 0, true, 1, System.Reflection.Missing.Value, System.Reflection.Missing.Value, true, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false, System.Reflection.Missing.Value, false, false, false);
The error i'm getting is :
NullReferenceException was unhandled by user code;Object reference not set to an instance of an object.
I tried to instantiate the workbooks object(xlsWbs) using 'New' .But it is showing sme like can't instantiate the abstract class or interface Excel.Workbooks.
This is the issue..plz help me to solve this.Could anyone send the code for importing and exporting Excel files in an SQLServer database file using C#.
Plz reply....