XML使用Windows XP和C#.NET的Excel(2007)思路思路、XP、Windows、XML

2023-09-06 10:11:10 作者:咒

我有我已经修改到XML文档,然后使用XSL表转换到Excel XML格式,以便允许编程开通了我的应用程序中的数据的数据集。我遇到了两个问题:

Excel不是默认的Windows应用程序打开Excel文件,因此当Program.Start(xmlfilename.xml)运行时,IE浏览器打开和XML文件是不是很可读。

如果您重命名为原来的.xlsx文件,您会收到警告,这不是一个Excel文件,你是否想继续。这是不理想的客户。

在理想情况下,我希望Windows在Excel中打开该文件,而无需修改默认的操作系统设置在打开Excel文件。办公室互操作是可能的,但似乎有点矫枉过正了这个应用程序。没有人有任何的想法,使这项工作?

解决的办法是在.net / C#中,但我开到其他的可能性,创造一个干净的解决方案。

解决方案

 的Process.Start(@C:\ Program Files文件\微软的Office \ Officexx \ EXCEL.EXE,yourfile的.xml);
 

话虽这么说,您仍将得到的消息框。我想,你可以使用互操作的,但我不知道它如何会为你工作。

Window XP

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:

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.

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.

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?

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

解决方案

Process.Start(@"C:\Program Files\Microsoft Office\Officexx\excel.exe", "yourfile.xml");

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.