Sunday, September 1, 2013

How to Serialize the Excel data with the XML Serialization Method ?

Hi Girithara,


It seems that you've already known the answer.


About how to load the excel data into a DataSet, please see the following code:



private DataSet ReadExcelToDataSet(string filePath)
{
DataSet ds= new DataSet();
string strConn = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text\"", filePath);
using (OleDbConnection dbConnection = new OleDbConnection(strConn))
{
using (OleDbDataAdapter dbAdapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", dbConnection)) //rename sheet if required!
dbAdapter.Fill(set);
return set;
}
}



About how to serialize and deserialize xml using XmlSerializer, please take a look at the below sample:


http://dotnet.dzone.com/articles/serializing-and-deserializing


Caillen

<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>

Thanks

MSDN Community Support



Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


No comments:

Post a Comment