Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My program exported a excel file by using
C#
Context.Response.AddHeader("content-disposition", attachment)
Context.Response.ContentType ="application/vnd.ms-excel"

my excel file saved in webpage format, after downloading the same when i import it back to my system using Microsoft Excel driver, i got an error:
External table is not in the expected format.

Do anyone know how to solve it?
Expecting for your help very urgent

kalai



My Export Excel coding
" Dim form As New HtmlForm()
Dim attachment As String = "attachment; filename=Patients.xls"
Context.Response.ClearContent()
Context.Response.AddHeader("content-disposition", attachment)
Context.Response.ContentType = "application/ms-excel"
Dim stw As New StringWriter()
Dim htextw As New HtmlTextWriter(stw)
form.Controls.Add(GridView1)
Me.Controls.Add(form)
form.RenderControl(htextw)
Context.Response.Write(sb.ToString())"

MyConnection = New system.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Users\develope\Downloads\Patients.xls; " & "Extended Properties=Excel 8.0;")

This is my connection string but i get same error
"External table is not in the expected format.
Posted
Updated 7-Apr-13 6:19am
v4

1 solution

Similar issue discussions:
External table is not in the expected format.[^]
Excel “External table is not in the expected format.”[^]

"External table is not in the expected format." typically occurs when trying to use an Excel 2007 file with a connection string that uses: Microsoft.Jet.OLEDB.4.0 and Extended Properties=Excel 8.0



If needed, look here[^] for more.
 
Share this answer
 
Comments
Maciej Los 7-Apr-13 5:25am    
+5!
Sandeep Mewara 7-Apr-13 5:27am    
Thanks Mac. :)
kalaiselvansurya 7-Apr-13 12:18pm    
My Export Excel coding
" Dim form As New HtmlForm()
Dim attachment As String = "attachment; filename=Patients.xls"
Context.Response.ClearContent()
Context.Response.AddHeader("content-disposition", attachment)
Context.Response.ContentType = "application/ms-excel"
Dim stw As New StringWriter()
Dim htextw As New HtmlTextWriter(stw)
form.Controls.Add(GridView1)
Me.Controls.Add(form)
form.RenderControl(htextw)
Context.Response.Write(sb.ToString())"

MyConnection = New system.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Users\develope\Downloads\Patients.xls; " & "Extended Properties=Excel 8.0;")

This is my connection string but i get same error
"External table is not in the expected format. "

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900