phpexceltransformmathmlspreadsheetml

Export AsciiMathML equations to Excel Format


I have to export a list of mathematical questions which have AsciiMathML notation to an Excel spreadsheet and I want to show the equations properly. My code is written in PHP and I want to create the Excel file on the server side and make it available for download.

I found that there are number of libraries which are in JavaScript to convert AsciiMathML to images, such as http://dlippman.imathas.com/asciimathtex/AMT.html

But what I need is to convert the equations to images or most preferably to Excel equations on the server side with PHP. Is there anyone aware of any libraries that I can use? I really appreciate if anyone can help me on this.

Thank you.


Solution

  • Use a spreadsheetML stylesheet to convert the MathML to Excel, using the transformToXML function like this:

    $xml = new DOMDocument;
    $xml->load($file_name);
    
    $xsl = new DOMDocument;
    $xsl->load('convert.xsl');
    
    $proc = new XSLTProcessor;
    $proc->importStyleSheet($xsl);
    
    $result = $proc->transformToXML($xml)
    

    References