473,467 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

error in importing excel file

3 New Member
Hi,

I have Exported some data in a Excel file using this code-

Expand|Select|Wrap|Line Numbers
  1. Response.Clear();
  2.         Response.AddHeader("content-disposition", "attachment;filename=dependencymatrix.xls");
  3.         Response.Charset = "";
  4.         Response.ContentType = "application/vnd.xls";
  5.         System.IO.StringWriter stringWrite = new System.IO.StringWriter();
  6.         System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
  7.         resultGrid.AllowPaging = false;
  8.         resultGrid.DataSource = dtResult;
  9.         resultGrid.DataBind();
  10.         resultGrid.RenderControl(htmlWrite);
  11.         Response.Write(stringWrite.ToString());
  12.         stringWrite.Dispose();
  13.         htmlWrite.Dispose();
  14.         Response.End();
Where "resultGrid" is a gridview.
Now I have to import this excel file.For this I have written the below code-

Expand|Select|Wrap|Line Numbers
  1. String strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath.ToString() + ";Extended Properties=Excel 8.0;";
  2.  OleDbDataAdapter da1 = new OleDbDataAdapter("SELECT * FROM [dependencymatrix$]", strConn);
  3.  da1.Fill(ds1);
Here i am getting this error-"The External table is not in correct format".
If I open the excel file and save as it as "Microsoft Excel workbook",then its working perfect.

Could any body help me to solve this problem?

My client dont want to do "save as" to the exported excel file.

Thanks in advance
Nov 16 '07 #1
1 1251
kenobewan
4,871 Recognized Expert Specialist
Here is another way to do it:
ASP.Net 2.0: Export GridView to Excel
Nov 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Grim Reaper | last post by:
I am importing a .csv file into Access that has 37 fields. My problem is that sometimes the last field only has data at the end of the column (it looks like when you import a file into Access, for...
9
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. ...
1
by: Geoff Jones | last post by:
Hi I have a question which I hope somebody can answer. I have written a VB application with which I want to import an Excel file, analyze the data within it and do some calculations. There are...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
5
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All...
3
by: mukeshsrivastav | last post by:
dear sir i want to move form excel to access. i have 5 excel file having same formats and fields.now i want to import all data in one access table. importing one file is easy .but importing and...
1
by: puremetal33 | last post by:
I have worked very little with Access and have hit a snag. My task right now is to import the data from a spreadsheet into an existing table in an Access database. I edited the .xls file so that...
0
by: Anish G | last post by:
Hi All, I am getting the below given error while running my application in live server. In my local machine, its working fine. Please help me as it is very urgent for me. Exception from...
0
by: James Minns | last post by:
Hi all, I have a problem with Excel 2007: it crashes when importing certain xml data, exported from another software This is the smallest file which reproduces the problem: <?xml version="1.0"...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.