Importing Excel

I figured this was already posted but I couldn't find it. I'm developing a web app that allowers the user to upload me a formatted excel file and then I need to transfer the data into a database. For the most I got it all working... upload to excel file, throw the data into a dataset and throw the dataset into my table. Whan I'm having trouble with is the first line of the excel file. For whatever reason it's reading the first line as headers. Is there an easy way around that? 

Thanks in advance.
11/12/2004 2:22:51 PM 93655 articles. 6 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 56
Get it on Google Play
Get it on Apple App Store

Before we dive into our sample code, there are a couple of other points to consider. First, by default, the OLE DB provider for Jet assumes that the first row of your Excel spreadsheet consists of column headings that it can use as field names. This isn't a requirement, but if this isn't the case, then you need to tell the provider. Otherwise, it will very happily make the assumption, and you'll lose the first row of your data. To properly inform the provider, add an HDR element to the Extended Properties component of your ConnectionString, like this:

AdoCn.ConnectionString = _
"Data Source=d:\MySpreadsheet.xls;" & _
"Extended Properties=Excel 8.0;HDR=No;"
There are only two possible values, Yes and No, depending upon whether your spreadsheet contains a header row. If you tell the provider that your spreadsheet doesn't have a header row, it will arbitrarily assume each column a field name of the form F1, F2, etc.
A second issue to bear in mind involves mixing data types. Because Excel doesn't maintain the same kind of detailed information about each field that a relational database would, the OLE DB provider has to make certain assumptions about the data format of each spreadsheet column. It does so by scanning a certain number of rows and examining the data in each column. This has the potential to create problems for you, though, so consider yourself advised to populate columns only with the same internally consistent data. For example, one column might consist of numbers only, while another might contain text data.
kind regard,
11/17/2004 9:25:06 AM
Thanks!.. As for the data types I'm giving users a specific format to put the excel spreadsheet in.. so needless to say someone is going to be messing it up! :).. Thanks again. 

11/17/2004 2:09:40 PM
does anyone get an unspecific error when they import data from excel?

System.Data.OleDb.OleDbException: Unspecified error at System.Data.OleDb.OleDbConnectionInternal.InitializeProvider() at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnection conn, OleDbConnectionString constr) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object providerInfo, DbConnectionBase owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnectionBase owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnectionBase owningConnection) at System.Data.ProviderBase.DbConnectionClosed.Open(DbConnectionBase outerConnection) at System.Data.ProviderBase.DbConnectionBase.Open() at ASP.excel1_aspx.LoadExcelIntoDS() in c:\excel_dev\excel1.aspx:line 25
<%@ Page language="c#" %>
<%@ Import Namespace="System.Runtime"%>
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<script runat=server>
void Page_Load(Object src, EventArgs e)
void LoadExcelIntoDS()
OleDbConnection MyConnection = new OleDbConnection();
String conn = "Provider=Microsoft.Jet.OLEDB.4.0;";
conn += @"Data Source=C:\excel_dev\demo_banc.xls;";
conn += "Extended Properties=Excel 8.0;";
MyConnection = new OleDbConnection(conn);
catch(ArgumentException ae)
Response.Write(ae.ToString() + "<BR>");
catch(OleDbException e)
String err_msg = "";
for (int i = 0; i < e.Errors.Count; i++)
err_msg += "----------------<br>Index #" + i + "<br>Message: " + e.Errors[i].Message + "<br>NativeError: " + e.Errors[i].NativeError + "<br>Source: " + e.Errors[i].Source + "<br>SQLState: " + e.Errors[i].SQLState + "<br>";
Response.Write(err_msg + "<br>");
Response.Write(e.ToString() + "<BR>");
catch(Exception e)
Response.Write(e.ToString() + "<br>");
11/30/2004 11:47:48 PM
solved. pls refer to:
12/14/2004 9:08:44 PM

Similar Artilces:

Implementing .Net Form into an web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

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...

Using excel/automation from a .net web form fails, why?
Hi all - From my codebehind I'm attempting to write the contents of a DataSet to Excel. However, it appears that I cannot start Excel from my codebehind to accomplish this. Doing so causes the following error: Cannot execute a program. The command being executed was "c:\winnt\\framework\v1.1.4322\csc.exe" /noconfig @"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\webservice_icspos_consumer\bd8c4cb9\af1c8054\s33rwgwf.cmdline". I've referenced Microsoft Excel 10.0 Object Library which also brings in - Microsoft Office 10.0 Obje...

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!...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

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

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

Sharepoint help! Error msg : "A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe"
hihi, I have set up a testing virtual server on my local machine. I installed win server 2003, wss 2.0, sql server 2000, and visual studio .net 2003. i tried to create a project in C# but when i build it and import the web part (.dwp) into the page, there is this error msg "A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe"  I seached most of the sites and they informed that the problem lies in the safe control in web.config i enter the safe control in web.config but i does not know where to put ...

Importing Individual Web Forms and User Controls from a Web Site
Is there a best practice for importing individual web forms and user  controls from a web site to a web application project (i.e., to ensure the .designer file is generated and all that)? On the new version of an existing web site, we're moving the WAP, but we're changing the project enough that I don't want to just upgrade the whole thing--I just want to import select forms and controls. So far, the best thought I've got is to do a fake upgrade and copy over files from that, but that's a bit heavy for my needs, so if there's an easier or better way to just grab the ones I want, pleas...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

.Net Web Forms
what is the best way to create a multi-page web insurance quote form (similar to Geico) that will insert information into a database? The examples i've seen show one form with a submit button at the bottom. I need to break this form into at least three different aspx or ascx pages. Thanks for the help. I did something similiar since I have like 7 sections to an application. The way I did it was by using the asp:panel control. When the user finished one section and clicks a button it inputs the data into the database and hides the 1st panel and shows the next one. HTH...

Include web form inside web form
I tried to include an aspx file in a web form. However, all the web controls (textbox, button) in the included page are not displayed when called. <Form id="Form1" method="post" runat="server"> <%   Response.writeFile("subPage.aspx"); %> <asp:button id="btnPrev" runat="server" text="Previous"></asp:button> </Form> There are some <asp:textbox> controls in the subPage.aspx file, the file itself works fine, but when it is included in the main page, all the controls are not displayed. Please assist. Thanks   u should u...

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Web resources about - Importing Excel -

Viral Channels: Hi5 Adds Contact Importing to App Invite Flow
... social networking platform I’ve seen, hi5 announced tonight that it is adding the ability for users to invite non-hi5 friends to apps by importing ...

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

Sydney grandmother Lorn Cheng arrested for allegedly importing heroin in 252 pellets
Brenda filed a missing persons report last Friday, concerned that her mother hadn't returned from a holiday in Cambodia when she said she would. ...

Importing more fads from failed systems
Fast-tracking talented professionals into the classroom is yet another imported fad from England and the US - both of which are failed education ...

Mark Clermont sentenced to life in jail for importing drugs worth $260 million inside road roller
A judge has praised police for preventing cocaine and methylamphetamine with a street value of $260 million reaching the streets of Sydney and ...

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 ...

Adobe updates Photoshop Express for Android with blemish removal tool, RAW importing, more
Adobe has actively been rolling out new and powerful tools for mobile platforms in recent months including Lightroom Mobile for iPad followed ...

Resources last updated: 12/13/2015 1:02:42 AM