使用OpenTBS mergeField方法导出原始数据

时间:2016-06-01 09:12:30

标签: php symfony libreoffice-calc opentbs

我使用OpenTBS将统计信息导出到.ods文件。 我希望能够在生成的文档中生成图表。 问题是导出的每个数据都在生成的文档中使用单引号(')进行转义。我无法在不删除图表的情况下生成图表。

有没有办法用OpenTBS mergeField()方法指定原始数据?

这是代码中的一个高峰:

$model = __DIR__ . "/../../Resources/public/models/Stats/Stats_mensuelles_template.ods";

$targetDir = __DIR__ . self::Z2_DOCGEN_TARGETDIR;

$this->setDocumentName($document, $this->type);

// (...) fetching the data (...)


// each getComptage* method return an integer value
$sm = array(
    "date" => $statistique->getDateFin()->format('M Y'),
    "pn" => $statsCurrentMonth->getComptagePaliersNormaux(),
    "pe" => $statsCurrentMonth->getComptagePaliersExceptionnels(),
    "cu" => $statsCurrentMonth->getComptagePaliersUrgents(),
    "pb" => $statsCurrentMonth->getComptagePatchesBIRDe(),
);

//Chargement de la page principale
$this->tbsManager->LoadTemplate($model, OPENTBS_ALREADY_UTF8);
$this->tbsManager->MergeField('sm', $sm);
$this->tbsManager->Show(OPENTBS_FILE, $targetDir . $document->getNom());

这里是.ods模板中的单元格([sm。*]和标签位于单独的单元格中):

Statistiques mensuelles [sm.date]
Palier normal             [sm.pn]
Palier exceptionnel               [sm.pe]
Palier urgent             [sm.cu]
Patch BIRDe               [sm.pb]
Autres paliers                [sm.div]

最后,这是生成单元格的一个例子

Palier normal             '30
Palier exceptionnel               '8
Palier urgent             '15
Patch BIRDe               '41
Autres paliers                '28

由于

1 个答案:

答案 0 :(得分:1)

我最终在OpenTBS Documentation - section "create OpenOffice and Ms Office documents with PHP"

中找到了答案

填写时,单引号会在文档方面添加。并且无论实际发送的是什么,它通常都会将每个数据视为一个字符串。

OpenTBS可以通过明确指定模板中的字段类型来处理此障碍。

因此,如果我们采用模板,请按照以下方式处理第一个数字字段:

[sm.pn;ope=tbs:num]

等等

相关问题