Importing Data From an Excel file

Anybody know how I could import data from an Excel sheet into a dataset via ASP.NET using VB.NET? Here is the code I have that works with a win32 app. It gives me a COM error. The Excel.dll, Interopp.dll, and Office.dll are all on the webserver.

Dim

strfile As String = "E:\Sites\InsuranceTmeplateSite\tempProcess\" & Now.Ticks.ToString() & ".XLS"

File1.PostedFile.SaveAs(strfile)

Dim EXL As New Excel.Application

Dim wsheet As Excel.Worksheet

wsheet = EXL.Workbooks.Open(strfile).Worksheets.Item(0)

Dim tb As New DataTable

Dim ds As New DataSet

Dim cl1 As New DataColumn("Name")

Dim cl2 As New DataColumn("Email")

tb.Columns.Add(cl1)

tb.Columns.Add(cl2)

ds.Tables.Add(tb)

Dim rw As DataRow

Dim counter As Integer = 0

Do

If wsheet.Cells(counter, 0) = "" Or wsheet.Cells(counter, 1) = "" Then

Exit Do

End If

rw = ds.Tables(0).NewRow()

ds.Tables(0).Rows(counter)(0) = wsheet.Cells(counter, 0)

ds.Tables(0).Rows(counter)(1) = wsheet.Cells(counter, 1)

counter += 1

Loop

Kill(strfile)

Try

EXL.Workbooks.Close()

EXL.Quit()

EXL =

Nothing

Catch ex As Exception

End Try

DataGrid2.DataSource = ds

DataGrid2.DataBind()

DataGrid2.Visible =

True
0
Hawk2k6
4/18/2006 6:15:06 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
690 Views

Similar Articles

[PageSpeed] 51

Which line throws the error? What is the error message?

My Blog
0
booler
4/18/2006 8:01:08 AM
I figured it out. Importing from Excel via Web is different than in a win32 desktop app.
0
Hawk2k6
4/18/2006 10:46:14 PM
Reply:

Similar Artilces:

Importing text file (possibly a excel file) via a web-form to a database.
Hey there - I'm sort of new to this and have a question - which in itself is probably easy, I'm just having trouble finding it. I need to import a text file - possibly later an excel file - into a SQL database via a web-form upload function. Can anyone point me in the right direction? A tutorial page that you know of or sample code, possibly? Any help would be appreciated. Thanks Hi, Take a look @ : - Reading a Delimited File Using ASP.Net and VB.Net - HTHK B ShajudeenAreYaar.comDubai, United Arab Emirates. That was perfect - thank you!...

Exporting data from web form to excel file
I have a page with datgrid and one button called export into excel. I use this code to export data into excel sheet. If my excel file size become more then 50k then i am having error and i can not open or save the excel file. Here is the code:  Server.ScriptTimeout = 12000 Response.ContentType = "application/vnd.ms-excel" dvwdetail = GetSQLData(VSQL) grdapex.DataSource = dvwdetail.Tables(0) grdapex.DataBind() If i have less row means the excel file size is less then 50k then it works fine but if i have more data file size is more then 50k then it give me error m...

Reading Excel Files from a .Net Web Form
Hi, This might be a dumb question, but ... When reading an Excel file from a .Net Web Form, is it necessary to have Microsoft Excel actually installed on the client machine running the web form? Also, do the Excel files being read need to be saved as "values only" or can the values be extracted from a spreadsheet where the cells contain formulas? Thanks. -Wayne Hi, For the 1st part, Office is not necessary to be installed. But Download the Office XP PIAs and use them to develop Office XP solutions with Visual Studio .NET. For 2nd Part I think you need to use Values.Regar...

importing data from a excel file into a database on my web account
Hi everyone , I'm learning asp.net ,and would like to know how I can import an excel file or access file and save the data from the file into a database in my web account Thanks for getting back to me    One of the option is to use an Excel COM object in your application and read the Excel file. U can read the Excel file row by row and update the data into the database. Try this, of course replace the Response.Write with your method to INSERT a row: string fileName = @"C:\Inetpub\wwwroot\Test\filename.xls";string sheetName = "sheet1"; string c...

importing an excel file and save data into a database in my web account
Hi everyone, sorry if this message is not supposed to be posted here. I'm learning asp.net , and would like to know how I can insert data from a excel file into a database on my web account. Pretty much insert/update information in the database using excel file or a access file.  Thanks a lot in advance Checkout thses links: http://support.microsoft.com/kb/311731 http://www.thescripts.com/forum/thread302753.html http://support.microsoft.com/kb/316934 http://www.vbdotnetheaven.com/UploadFile/mahesh/AccessExcelDatabase04252005014321AM/AccessExcelDatabase.aspx I hope they wil...

Importing data from either Excel Files or CSV files
Hi, I am having trouble uploading data from Excel/CSV files.  Any idea how I can get my ASP.NET application to do this?  Also, I need to transfer the data into SQL Server tables.  Any suggestion is greatly appreciated.  Thank you, Jules  this link help youhttp://www.codeproject.com/cs/database/CsvReader.asp  Try this one... its a good option http://www.codeproject.com/cs/database/FinalCSVReader.asp Thank you Bupender Thanks chrisjob012!  Mark as answer if reply helped you  this gives us the confident to reply further I am new to progra...

Aspose.Excel.Web 1.0 Released!
Aspose.Excel.Web 1.0 Released! Version 1.0 Released on March 10 2005 ...

passing the data to the dll file and then get the data back to web form
 I want to input data to the text box and then that text box is reading and combining data to the dll file and then get the data back to the web form and show the result.I don't konw how to write this application.  I hope the dll you have is a .NET assembly. If so, you can follow the below steps.1) You must first give reference to the dll in your web application by using the Add Reference menu. Then place the "using <namespace>" at the top in your codebehind.2) Instantiate the class file in the dll and invoke the method with the appropriate parameter value (t...

Import excel data from Microsoft excel to SQL Server usin C sharp .net
Hi Could anyone help me with the sample code in C sharp to import data from excel to SQL server 2005 using C sharp. I have a table called Accounting Calendar ACCT_DATE with 10 columns I have the excel file called example.xls with the same column name as in SQL Server.Please help me with the sample code in C sharp Thanks      Here's a simple way to do it without the need to have excel installedhttp://davidhayden.com/blog/dave/archive/2006/05/26/2973.aspx Hope this helpsJaime Don't forget to click "Mark as Answer" on the post that helped you. That wa...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

Export data from web form to excel -- using client's excel app
I am currently trying to figure out if there is any way to export data to the client's excel app. I do not want to use the web server's excel application as it is cutting into the site's performance. Is there any way to use something similar to the what is included below (ExportComponent.vb), but to use the client's excel app? Imports System.Drawing.Color Public Class ExportComponent Inherits System.ComponentModel.Component Public Shared Sub DataToExcel(ByVal dgData As DataGrid, ByVal response As HttpResponse) response.Clear() response.Charse...

How to Import data from Excel file
Hi all How to import the data from excel file to datastore or datawindow during the runtime without using the DDE function. I am using PB9. Thanks in advance Regards Shivkumar K Datawindow pipeline comes to mind. "Shivkumar K" <shiv@cgvakindia.com> wrote in message news:42789ebd@forums-1-dub... > Hi all > > How to import the data from excel file to datastore or datawindow during > the > runtime without using > the DDE function. > > > I am using PB9. > > Thanks in advance > > Regards > Shivk...

How to import data from excel file?
Hi I want to import the data from excel file in to datawindow or datastore. How to do this ? or How to open the excel file and read the content cell by cell of all rows TIA Save XLS as Tab delimited file and use ImportFile function. Use Import..(from menu) or PipeLine control. -- Max (m_pavlov@mail.ru) -- "ewak" <ewak@vsnl.com> �������/�������� � �������� ���������: news:nLzZoNiqBHA.206@forums.sybase.com... > Hi > > I want to import the data from excel file in to datawindow or datastore. > How to do this ? > > or > > H...

import data through excel file
  hii all,         i've to import bulk data from excel file to sql server 2000 , i'm using asp.net 1.1 with C# and i've to make a front end(windows application) for this. help me out if any1 knows that... Thanks & Regards anant vijay u can use bulk insert.Plz check these linkshttp://www.thescripts.com/forum/thread246959.htmlhttp://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic16463.aspxhttp://weblogs.sqlteam.com/mladenp/archive/2006/08/26/11368.aspxThank uBabaPlease remember to click "Mark as Answ...

Web resources about - Importing Data From an Excel file - asp.net.web-forms

Facebook Expands Feed Connect (er, Feed Importing) to More Sites
About six weeks ago, Facebook launched Feed Importing for the first time, allowing users to connect their Facebook accounts to Flickr, Yelp, ...

YouTube - iPad importing photos from floppy disk.
You are using an outdated browser, which YouTube no longer supports. Since some features on YouTube may not work, you are viewing a lightweight ...

Tony Abbott considers importing US-style school program with private industry involvement
Tony Abbott is considering an unprecedented Americanisation of the school education system with radical changes that could see HECS-style fees ...

Importing fuel will prove better for the consumer
Importing fuel will prove better for the consumer

Man accused of importing drugs to Canberra post office boxes to stand trial
A man accused of importing MDMA and cocaine into the ACT using false identities and a series of post office boxes has pleaded not guilty and ...

Canberra restaurateur jailed for importing cocaine
A Canberra restaurateur has been jailed for importing $114,000 worth of cocaine from the United States.

Urine test fail for man facing drug importing sentence
A Canberra man who pleaded guilty to importing a commercial quantity of drugs to his front door has admitted&nbsp;taking a banned drug&nbsp;weeks ...

Hong Kong man charged with importing 150kg of crystal methamphetamine into Sydney
A Hong Kong national is charged with importing 150 kilograms of ice following a joint-agency investigation in Sydney.

Man, 91, charged with importing cocaine hidden in soap boxes into Australia
A 91-year-old Sydney man has been charged with importing cocaine hidden in soap into Australia, prompting police to warn travellers to beware ...

Google Drive adds support for importing OpenOffice (ODF) file formats
Google announced today that it’s now officially supporting ODF files in Google Drive allowing users to import all three major ODF file formats. ...

Resources last updated: 12/27/2015 11:31:52 PM