locked
How to convert Xml Spreadsheet 2003 (openxml) to Excel (xls) RRS feed

  • السؤال

  • Can somebody help me on how to convert my xml spreadsheet 2003 to Excel? I have a page which uses openxml template but the problem is after i rename it to xls extension. this error prompts up.

    "The file you are trying to open is in different format that specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

    Whats great is that excel can actually convert that xml to excel. maybe i can do the same programmatically. Btw im using asp.net c#. Pls help.

    Thanks


    29/شوال/1434 05:58 م

الإجابات

  • I'm not certain I understand exactly what you have and what you need to do with it...

    You have a spreadsheet that was saved in Excel 2003 to a *.xml file format? So, essentially, you're able to view the content of the file in Notepad or some other text editor? (I'm just checking that this is the format of the file in question.)

    In that case, you either need to write code to transform that information to the Excel 2007-2013 Office Open XML file format, license a third-party software with that capability to integrate into your aspx, or you'd need to automate the Excel application. You cannot simply rename the file to *.xls or *.xlsx.

    Automating the Excel application is not supported or recommended in a server-side environment, so ideally you should transform the data to the *.xlsx file format... This is not directly supported by the Open XML SDK (there's no tool that can do it for you in a single step), but you could certainly use the Open XML SDK to accomplish the task. The Excel *.xml file format is documented in the information for Excel 2002:

    http://msdn.microsoft.com/en-us/library/office/aa140066(v=office.10).aspx


    Cindy Meister, VSTO/Word MVP, my blog

    03/ذو القعدة/1434 03:25 م
  • Hi Joebet

    You have to understand that this is a non-trivial process: no one here can write the code for you. There is no "plug-in" solution available in the documentation that you can simply pick up and modify.

    All we can do here in the forum is guide you and try to help you with specific problems you encounter. This task requires good XML skills and a thorough understanding of both file formats. That means digging in and researching.

    You may also want to reference this discussion, which pretty much says it all:
    http://stackoverflow.com/questions/1329262/excel-conversion-of-spreadsheetml-to-open-xml-xlsx

    In the end, it may be cheaper (and a lot faster) to invest in a third-party tool, such as supplied by Aspose.


    Cindy Meister, VSTO/Word MVP, my blog

    06/ذو القعدة/1434 08:51 ص

جميع الردود

  • I'm not certain I understand exactly what you have and what you need to do with it...

    You have a spreadsheet that was saved in Excel 2003 to a *.xml file format? So, essentially, you're able to view the content of the file in Notepad or some other text editor? (I'm just checking that this is the format of the file in question.)

    In that case, you either need to write code to transform that information to the Excel 2007-2013 Office Open XML file format, license a third-party software with that capability to integrate into your aspx, or you'd need to automate the Excel application. You cannot simply rename the file to *.xls or *.xlsx.

    Automating the Excel application is not supported or recommended in a server-side environment, so ideally you should transform the data to the *.xlsx file format... This is not directly supported by the Open XML SDK (there's no tool that can do it for you in a single step), but you could certainly use the Open XML SDK to accomplish the task. The Excel *.xml file format is documented in the information for Excel 2002:

    http://msdn.microsoft.com/en-us/library/office/aa140066(v=office.10).aspx


    Cindy Meister, VSTO/Word MVP, my blog

    03/ذو القعدة/1434 03:25 م
  • Hi Cindy.

    You have a spreadsheet that was saved in Excel 2003 to a *.xml file format? Yes. i created a template from excel and export it as spreadsheet 2003 and it gives me openxml spreadsheet xml codes.

    So, essentially, you're able to view the content of the file in Notepad or some other text editor?  (I'm just checking that this is the format of the file in question.) Yes

    "Automating the Excel application is not supported or recommended in a server-side environment, so ideally you should transform the data to the *.xlsx file format... This is not directly supported by the Open XML SDK (there's no tool that can do it for you in a single step), but you could certainly use the Open XML SDK to accomplish the task. The Excel *.xml file format is documented in the information for Excel 2002:"

    can i ask how can i convert my spreadsheet xml to xlsx using open xml sdk? i already skimmed on that page and got nothing helpful.

    Im also not required to use non free 3rd party tools and also tried to free one "close xml" but it doesnt suit the requirements

    pls help


    03/ذو القعدة/1434 03:42 م
  • Hi Joebet

    You have to understand that this is a non-trivial process: no one here can write the code for you. There is no "plug-in" solution available in the documentation that you can simply pick up and modify.

    All we can do here in the forum is guide you and try to help you with specific problems you encounter. This task requires good XML skills and a thorough understanding of both file formats. That means digging in and researching.

    You may also want to reference this discussion, which pretty much says it all:
    http://stackoverflow.com/questions/1329262/excel-conversion-of-spreadsheetml-to-open-xml-xlsx

    In the end, it may be cheaper (and a lot faster) to invest in a third-party tool, such as supplied by Aspose.


    Cindy Meister, VSTO/Word MVP, my blog

    06/ذو القعدة/1434 08:51 ص
  • Hi Joebet

    You have to understand that this is a non-trivial process: no one here can write the code for you. There is no "plug-in" solution available in the documentation that you can simply pick up and modify.

    All we can do here in the forum is guide you and try to help you with specific problems you encounter. This task requires good XML skills and a thorough understanding of both file formats. That means digging in and researching.

    You may also want to reference this discussion, which pretty much says it all:
    http://stackoverflow.com/questions/1329262/excel-conversion-of-spreadsheetml-to-open-xml-xlsx

    In the end, it may be cheaper (and a lot faster) to invest in a third-party tool, such as supplied by Aspose.


    Cindy Meister, VSTO/Word MVP, my blog

    Hi Cindy,

    Im certainly not asking for anyone to do the job for me. Like what you had said i just needed a guide or any documentation Microsoft had provided for us. But since you already pointed another forum post.. this only means that this problem dont have a straightforward and proper documentation from Microsoft. I guess we just have to let this popup appear rather than buying $1k worth of library.

    I hope MS will put some guides or something in the future.

    Thanks

    10/ذو القعدة/1434 05:51 ص
  • This answer might come a wee bit late (6 years), but for the latecomers (such as myself) it should be noted that there exists programmatic ways of doing this using the JODConverter project. That open source project came to life in 2006 so it could have been used at the time of the post as well. It basically relies on scripting the Libre Office engine to do the conversion from SpreadsheetML to the Office 2007 Excel format (or whatever else you would like).

    The original project is defunct (as of 2011), but has been forked multiple times and is alive and well at Github. Here is a snippet from a thread on how to do the conversion (not allowed to paste the link, but it is issue 145 on sbraconnier/jodconverter:

    public class ConvertSpreadsheetML {
    
      public static void main(String[] args) {
    
        LocalOfficeManager officeManager = LocalOfficeManager.install();
        try {
          officeManager.start();
          File source = new File("C:\\tmp\\jodc\\input.xml");
          File target = new File("C:\\tmp\\jodc\\output.xlsx");
          LocalConverter.builder().build().convert(source).to(target).execute();
        } catch (Exception e) {
          OfficeUtils.stopQuietly(officeManager);
        }
      }
    }


    01/ربيع الثاني/1441 10:12 ص