Generate XML from XLS using macro

Hi ,

Could anyone guide me to create macro which generate XML from XLS …


What is “XML”? Do you mean one of XML-based formats, like ODF or OOXML? Or maybe MS Excel 2003 XML format? Or .FODS? Or something completely different?

What is “macro”? Do you need a LibreOffice macro (that may be assigned to a button in LO UI), say, in StarBasic? Or do you mean a shell script (like .BAT file on Windows, or Bash script for *nix)?

Why’d you wanna do that, anyway ? If none of the other XML documents satisfy, you have to be very specific and know what you’re doing, cuz you’re talking about a different, custom, XML-based data format which’d have to be made. Last time I read, XLS is XML, just in binary form, inside a ZIP file.

Not quite true, XLS isn’t XML-based. XLSX is.

^ Another case of corrupted memory.

I have an excel template , when the excel is saved data from each cell should be exported to a .xml file with specific schema.

This resource may be of some help.

EDIT: Given that you’ve created and installed an export XSLT filter, you may use this (recorded) macro to export an open Calc file using it:

sub ExportToXML(outFileName)
  rem outFileName is in format "file:///path/to/filename.xml"

  dim args(0) as new
  args(0).Name = "FilterName"
  args(0).Value = "YOUR XSLT FILTER NAME" ' like existing "XHTML Calc File"

  ThisComponent.storeToURL(outFileName, args)
end sub

Thanks for your reply. But sorry am not looking in XML filtering using XSLT…I would like to use macros for generating .xml file

Ok, just wanted to notice that there are both filters for import and export.