コード例 #1
0
ファイル: ods.php プロジェクト: Ibrahim1/aec
 public function finishExport()
 {
     include_once JPATH_SITE . '/components/com_acctexp/lib/ods-php/ods.php';
     $ods = newOds();
     $ofs = 0;
     if (!empty($this->description) && !empty($this->sum)) {
         $ofs++;
         foreach ($this->description as $cid => $cell) {
             $ods->addCell(0, $ofs, $cid, htmlentities($cell), 'string');
         }
     }
     foreach ($this->lines as $line) {
         $ofs++;
         foreach ($line as $cid => $cell) {
             $ods->addCell(0, $ofs, $cid, htmlentities($cell), 'string');
         }
     }
     if (!empty($this->sum)) {
         $ofs++;
         foreach ($this->sum as $cid => $cell) {
             $ods->addCell(0, $ofs, $cid, htmlentities($cell), 'string');
         }
     }
     $fname = 'aecexport_' . urlencode(stripslashes($this->name)) . '_' . date('Y_m_d', (int) gmdate('U'));
     $fpath = '/tmp/' . $fname . '.' . $this->params['export_method'];
     saveOds($ods, $fpath);
     $handle = fopen($fpath, "r");
     echo fread($handle, filesize($fpath));
     exit;
 }
コード例 #2
0
 public function output()
 {
     $ods = newOds();
     $i = 0;
     foreach ($this->getBody() as $row) {
         $j = 0;
         foreach ($row as $cell) {
             $ods->addCell(0, $i, $j++, iconv('iso-8859-1', 'utf-8', str_ireplace('\\n', '', $this->relstrip($cell))), 'string');
         }
         $i++;
     }
     $ods->output();
 }
コード例 #3
0
ファイル: metrics.php プロジェクト: Norky/PBS-tools
function result_as_ods($result, $mycolumnname, $filebase)
{
    $myresult = $result;
    $cache = APACHE_CACHE_DIR;
    if (!file_exists("/tmp/" . $cache)) {
        mkdir("/tmp/" . $cache, 0750);
    }
    $odsfile = $filebase . ".ods";
    $workbook = newOds();
    $sheet = 0;
    $rowctr = 0;
    $colctr = 0;
    foreach ($mycolumnname as $header) {
        $workbook->addCell($sheet, $rowctr, $colctr, "{$header}", "string");
        $colctr++;
    }
    while ($myresult->fetchInto($row)) {
        $rowctr++;
        $colctr = 0;
        $keys = array_keys($row);
        foreach ($keys as $key) {
            $data = array_shift($row);
            $type = "string";
            # regex found on http://www.regular-expressions.info/floatingpoint.html
            if (preg_match('/^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$/', $data)) {
                $type = "float";
            }
            $workbook->addCell($sheet, $rowctr, $colctr, htmlspecialchars("{$data}"), $type);
            $colctr++;
        }
    }
    saveOds($workbook, "/tmp/" . $cache . $odsfile);
    echo "<P>ODF file:  <A href=\"" . $cache . rawurlencode($odsfile) . "\">" . $odsfile . "</A></P>\n";
}
コード例 #4
0
ファイル: tax_build.php プロジェクト: kgbase/KGBase
             $x_content->addChild($xkey, $xvalue);
         }
     } else {
         $content_text = $content->{$key};
         $content->addChild($key, $value);
     }
 }
 //add tree to trees index
 $tree_index = simplexml_load_file($tree_dir . 'trees.xml');
 $tree_add = $tree_index->addChild('tree', '&#xA;');
 $tree_add->addChild('name', $tree_name);
 $tree_add->addChild('description', $post['nt_desc']);
 $tree_add->addChild('author', $post['nt_author']);
 $tree_index->asXML($tree_dir . 'trees.xml');
 //write tree ods
 $tree_ods = newOds();
 //make "index" tab
 $tree_ods->addSheet('index');
 $tree_ods->addCell('index', 1, 1, 'name', 'string');
 $tree_ods->addCell('index', 1, 2, $tree_name, 'string');
 $tree_ods->addCell('index', 2, 1, 'description', 'string');
 $tree_ods->addCell('index', 2, 2, $post['nt_desc'], 'string');
 $tree_ods->addCell('index', 3, 1, 'author', 'string');
 $tree_ods->addCell('index', 3, 2, $post['nt_author'], 'string');
 $tree_ods->addCell('index', 4, 1, 'rank', 'string');
 $tree_ods->addCell('index', 5, 1, 'pseudonym', 'string');
 //make "content" tab
 $tree_ods->addSheet('content');
 $n_row = 1;
 foreach ($content as $key => $value) {
     $value_child = $value->children();
コード例 #5
0
<?php

/*
ods-php a library to read and write ods files from php.
This library has been forked from eyeOS project and licended under the LGPL3
terms available at: http://www.gnu.org/licenses/lgpl-3.0.txt (relicenced
with permission of the copyright holders)
Copyright: Juan Lao Tebar (juanlao@eyeos.org) and Jose Carlos Norte (jose@eyeos.org) - 2008 
https://sourceforge.net/projects/ods-php/
*/
include "ods.php";
//include the class and wrappers
$object = newOds();
//create a new ods file
$object->addCell(0, 0, 0, 1, 'float');
//add a cell to sheet 0, row 0, cell 0, with value 1 and type float
$object->addCell(0, 0, 1, 2, 'float');
//add a cell to sheet 0, row 0, cell 1, with value 1 and type float
$object->addCell(0, 1, 0, 1, 'float');
//add a cell to sheet 0, row 1, cell 0, with value 1 and type float
$object->addCell(0, 1, 1, 2, 'float');
//add a cell to sheet 0, row 1, cell 1, with value 1 and type float
saveOds($object, '/tmp/new.ods');
//save the object to a ods file
$object = parseOds('/tmp/new.ods');
//load the ods file
$object->editCell(0, 0, 0, 25);
//change the value for the cell in sheet 0, row 0, cell 0, to 25
saveOds($object, '/tmp/new2.ods');
//save with other name