Hi,
I have 1000 xml files.
I want to convert them as excel files.
Thanks,
Darma
Xml to excel
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Dec 13, 2012, 7:35 PM EST
//Creating Excel book and sheet
object misValue = System.Reflection.Missing.Value;
Excel.Application myApp=new Excel.Application() ;
Excel.Workbook myWbk = myApp.Workbooks.Add(misValue);
Excel.Worksheet myWst = (Excel.Worksheet)myWbk.Worksheets.get_Item(1);
//reading xml and load into datasheet
DataSet ds = new DataSet();
XmlReader xmlFile ;
xmlFile = XmlReader.Create("C:\\Staff.xml", new XmlReaderSettings());
ds.ReadXml(xmlFile);
//writing into excel
int i = 0;
int j = 0;
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
for (j = 0; j <= ds.Tables[0].Columns.Count - 1; j++)
{
myWst.Cells[i + 1, j + 1] = ds.Tables[0].Rows[i].ItemArray[j].ToString ();
}
}
//saving and closing excel
myWbk.SaveAs("C:\\Staffexcel.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
myWbk.Close(true, misValue, misValue);
myApp.Quit();
source:http://csharp.net-informations.com/xml/excel-from-xml.htm
Lacy Michelle148 reputationPosted Dec 13, 2012, 7:39 PM EST
Convert Excel to XML and XML to Excel
Generate Excel from XML and Generate XML from Excel