Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Importing And EXporting An Excel


Importing And EXporting An Excel

Reply
  #1 (permalink)  
Old 05-02-06, 01:33 AM
Dilna Dilna is offline
New Member
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Importing And EXporting An Excel

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....
Reply With Quote
  #2 (permalink)  
Old 05-02-06, 01:37 AM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Moved to ASP.NET ....
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
  #3 (permalink)  
Old 05-02-06, 04:49 PM
koncept
Guest
 
Posts: n/a
is there any chance of converting the excel file to be a csv file? there are some built in functions designed to work with databases and csv files.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
importing Excel to Access ASP zeromonster ASP 3 04-01-05 01:33 AM


All times are GMT -5. The time now is 01:09 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.