none
How to convert file from xml excel format into the xslx file format. RRS feed

  • Question

  •     Hi! I have written the xslt template for my xml file, which converts my xml file into the excel xml format (with the "urn:schemas-microsoft-com:office:spreadsheet" namespace). Next I want convert this xml file (which possible to open in excel)  into the .xlsx file. Is any C++ library that can do it automaticaly? I dont know C# so I should be gratefull if you help me to find  c++ library or any dll that can do such convertion.
    Monday, May 17, 2010 3:53 PM

All replies

  • Converting your generated XML file to an XLSX file, isn't going to be just a single function call. In my opinion, what you need to do is

    • Generate a blank XLSX file.
    • Insert your XML into one of the SheetX.xml files (where X stands for number like 1, 2, 3 etc.)

    I am working on a blog post which will show how to do it. It is not yet complete though, and may take me a day or two to finish it. It will provide the sample code on how to insert the generated XML (from XSLT transform) in to Sheet.xml file. I will surely post the link here for you.

    Having said that, if you have the logic to insert your XML to XLSX sheet, and just want to know how this can be done from C++, you can have a look into Packaging API Programming Guide (Windows). It was introduced with Windows 7, and samples can be found in Windows 7 SDK.

    Apart from that, you could also work your way using any Zip library and MSXML parser. Use the Zip library to extract/package the OpenXML files, and use MSXML (or any such XML parser) to manipulate the XML files.

    Hope this helps!

    Regards,

    Manvir Singh

    Thursday, May 20, 2010 9:24 AM
  • Thanks for care! I'll be wait for your link. You said that I can use any Zip library to get the xml content from .xslx file. May be I am naive, but could I get xslx file by packing my xml file with Zip library or not? (I tested  that a simple packing with winzip not working  -:) )
    Thursday, May 20, 2010 5:34 PM
  • Packaging XML into XLSX file do require one to follow the OpenXML/OpenPackaging specifications, i.e., the set of files being packaged should be interlinked as any XLSX file and they should be at the root of the compressed file. By keeping file at the root is like selecting a set of files and sending them to a compressed folder, and not selecting a folder containing the required files and compressing it.

    I have many times tried modifying OpenXML format files manually by uncompressing them in Winodws Explorer and compressing them back again, and it had worked fine for me. Not sure what could have went wrong in your case... could you explain how you tried to Zip your XML to XLSX?

    Regards,

    Manvir Singh
    http://www.manvirsingh.net/

    • Edited by Manvir Singh Friday, May 21, 2010 2:31 PM updated signature
    Friday, May 21, 2010 10:34 AM
  •  

     

        Oh, I understood! I opened the .xlsx file in WinRaR and saw that there are a lot of files in differents folders. And before I saw it I had tried to pack only my single .xml file without any other actions. It was my mistake.

       Now I see that all files in packed .xslx are xml files too and that these files can be obtained from my initial .xml file by xslt transformation (transformation of single .xml file  to set of xml files (all worksheets, style, workbook... e.t.c)). Did you try to do it in such a manner? Unfortunately msxml do not support xslt 2.0 otherwise such transformations could be rather simple.

     

     

    Friday, May 21, 2010 4:01 PM
  • Hi Alex,

    I have published my blog post at:

    How to efficiently generate OpenXML Workbook from Excel files containing very large amount of data

    Hope this helps!

    Regards,

    Manvir Singh
    http://www.manvirsingh.net/

     

    • Proposed as answer by Manvir Singh Wednesday, August 4, 2010 1:52 PM
    Monday, May 31, 2010 8:58 PM
  • Thanks a lot! But it is for C#. I can use it only with COM, but it will be too difficult.
    Saturday, June 5, 2010 8:00 AM