<p>I have a dataset that I have modified into an xml document and then used a xsl sheet to transform into an Excel xml format in order to allow the data to be opened programatically from my application.  I have run into two problems with this:</p>

<ol>
<li><p>Excel is not the default Windows application to open Excel files, therefore when Program.Start("xmlfilename.xml") is run, IE is opened and the XML file is not very readable.</p></li>
<li><p>If you rename the file to .xlsx, you receive a warning, "This is not an excel file, do you wish to continue".  This is not ideal for customers.</p></li>
</ol>

<p>Ideally, I would like Windows to open the file in Excel without modifying the default OS setting for opening Excel files. Office interop is a possibility, but seems like a little overkill for this application.  Does anyone have any ideas to make this work?</p>

<p>The solution is in .Net/C#, but I am open to other possibilities to create a clean solution.</p>

[{'answer_id': 78246, 'author': 'sgwill', 'author_id': 1204, 'author_profile': 'https://Stackoverflow.com/users/1204', 'pm_score': 1, 'selected': False, 'text': '<p>What if you save the file as an xlsx, the extension for XML-Excel?</p>\n'}, {'answer_id': 78292, 'author': 'MagicKat', 'author_id': 8505, 'author_profile': 'https://Stackoverflow.com/users/8505', 'pm_score': 2, 'selected': True, 'text': '<pre><code>Process.Start(@"C:\\Program Files\\Microsoft Office\\Officexx\\excel.exe", "yourfile.xml");\n</code></pre>\n\n<p>That being said, you will still get the message box.  I suppose that you could use the Interop, but I am not sure how well it will work for you.</p>\n'}, {'answer_id': 78298, 'author': 'Bryant', 'author_id': 10893, 'author_profile': 'https://Stackoverflow.com/users/10893', 'pm_score': 0, 'selected': False, 'text': '<p>As Sam mentioned, the xlsx file extension is probably a good route to go. However, there is more involved than just saving the xml file as xlsx. An xlsx is actually a zip file with a bunch of xml files inside folders. I found some good sample code <a href="http://www.gemboxsoftware.com/Excel2007/DemoApp.htm" rel="nofollow noreferrer">here</a> which seems to give some good explanations although I haven\'t personally given it a try.</p>\n'}, {'answer_id': 78818, 'author': 'Dave Neeley', 'author_id': 9660, 'author_profile': 'https://Stackoverflow.com/users/9660', 'pm_score': 0, 'selected': False, 'text': '<p>Apologies in advance for plugging a third party library, and I know it\'s not free, but I use <a href="http://www.tmssoftware.com/site/flexcelnet.asp" rel="nofollow noreferrer">FlexCel Studio</a> from TMS Software. If you\'re looking to do more than just dump data (formatting, dynamic cross-tabs, etc) it works very well. We generate hundreds of reports a week using it. </p>\n\n<p>FlexCel accepts strongly-typed datasets, it can group data according to relationships, and the generated Excel file looks so much cleaner than what you can get from a Crystal Reports excel export. I\'ve done the crystal reports thing, and the OLE automation thing. FlexCel is a steal at $125 EU.</p>\n'}, {'answer_id': 82799, 'author': 'Jason Z', 'author_id': 2470, 'author_profile': 'https://Stackoverflow.com/users/2470', 'pm_score': 2, 'selected': False, 'text': '<p>If you insert the following into the 2nd line of your XML it directs Windows to open with Excel</p>\n\n<pre><code>&lt;?mso-application progid="Excel.Sheet"?&gt;\n</code></pre>\n'}, {'answer_id': 15773216, 'author': 'aked', 'author_id': 1060656, 'author_profile': 'https://Stackoverflow.com/users/1060656', 'pm_score': 0, 'selected': False, 'text': '<p>Hope this helps.</p>\n\n<p>OpenXML in MSDN - <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.openxml%28v=office.11%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.openxml(v=office.11).aspx</a></p>\n\n<pre><code>using Excel = Microsoft.Office.Interop.Excel;\n\nstring workbookPath= @"C:\\temp\\Results_2013Apr02_110133_6692.xml";\n\n            this.lblResultFile.Text = string.Format(@" File:{0}",workbookPath);\n            if (File.Exists(workbookPath))\n            {\n                Excel.Application excelApp = new Excel.Application();\n                excelApp.Visible = true;\n                Excel.Workbook excelWorkbook = excelApp.Workbooks.OpenXML(workbookPath, Type.Missing, Excel.XlXmlLoadOption.xlXmlLoadPromptUser);\n            }\n            else\n            {\n                MessageBox.Show(String.Format("File:{0} does not exists", workbookPath));\n            }\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/78233', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2916/']