0

我正在使用 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

谢谢

4

1 回答 1

1

我最终在OpenTBS 文档中找到了答案 - “使用 PHP 创建 OpenOffice 和 Ms Office 文档”部分

单引号在填写时添加到文档一侧。无论实际发送什么,它通常都将每条数据视为一个字符串。

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

所以,如果我们使用我的模板,下面是我们如何处理第一个数字字段:

[sm.pn;ope=tbs:num]

等等

于 2016-06-01T14:30:07.350 回答