Write an excel file to XML file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Write an excel file to XML file

guhan_77guhan_77 Posts: 7Member
i have coded like this

using System.Data.OleDb;
using System.Xml;
using System.IO;

protected void btnSubmit_Click(object sender, EventArgs e)
{
string strFileName;
if (UploadFile.PostedFile != null)
{
strFileName = UploadFile.PostedFile.FileName;
strFileName = strFileName.Substring(strFileName.LastIndexOf("\") + 1);
str="C:\Documents and Settings\134447\My Documents\a.xml";
try
{
paths = Server.MapPath("Attach/");
paths = paths + strFileName;
UploadFile.PostedFile.SaveAs(paths);

lblMessage.Text= "Uploaded successfully: c:\upload\" + strFileName + "
";
}
catch (Exception err)
{
lblMessage.Text= "Error Uploading c:\upload\" + strFileName + "
";
}



DataSet Mydataset = new DataSet();
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("Attach/") + strFileName + ";" + "Extended Properties=Excel 11.0;IMEX=1;";
OleDbDataAdapter myData = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);

myData.AcceptChangesDuringFill = false;
//Fill Dataset
myData.Fill(Mydataset);
//Covert to XML
Mydataset.WriteXml(str);

}

We are using Excel 11.0 version in office 2003 .I am getting this error
"Could not find installable ISAM." - Excel OleDb

How to solve this problem?
Can anyone give the code?


Sign In or Register to comment.