Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Filter_XlsxToText Class Reference

Filter to convert a Microsoft Excel 2007 document to text. More...

List of all members.

Public Member Functions

 filter ($xlsx)
 Extract text contents from an Excel format.

Detailed Description

Filter to convert a Microsoft Excel 2007 document to text.

This implementation uses Zend_Search_Lucene_Docuemtn_Xlsx to extract text contents from an Excel document (supports Excel 2007 format only.)

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

P4Cms_Filter_XlsxToText::filter ( xlsx)

Extract text contents from an Excel format.

Parameters:
string$xlsxthe Excel contents to be filtered.
Returns:
string the plain text output.
    {
        // shortcut if we have an empty string
        if (!strlen($xlsx)) {
            return;
        }

        // write contents to a tmp file
        $tempFile = tempnam(sys_get_temp_dir(), 'excel');
        file_put_contents($tempFile, $xlsx);

        $document = Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($tempFile);

        // remove the temp file
        unlink($tempFile);
        
        return $document->getFieldValue('body');
    }

The documentation for this class was generated from the following file: