繁体   English   中英

使用Tha数据动态创建表

[英]Table dynamic created with tha data

我在php上有此脚本,我需要从中自动创建表

foreach ( $GetJobResult->Components->Component as $component_index => $component ) {
    $quote_title = ($component_index + 1) . ') ' . $component->Title . "-Machine :\r\n";
    if (isset ( $component->Paper->Family )) {
        if (isset ( $component->Paper->Type ) && isset ( $component->Paper->Color )) {
            if ($component->Ink->FrontColors == '0') {
                $quote_impression = "sans impression\r\n";
            }
            $getPaperInfoResult = $ws->getPaperInfo ( $component->Paper->Family, $component->Paper->Type );
            foreach ( $getPaperInfoResult->PapFamType as $paper_index => $paperinfo ) {
                if (($paperinfo->Ccoul == $component->Paper->Color) && ($paperinfo->Gramm == $component->Paper->Weight)) {
                    $quote_support = $paperinfo->Lfam . ' - ' . $paperinfo->Lcoul . ' - ' . $paperinfo->Gramm . ' g/m2' . "\n";
                    $quote_impression = $component->Ink->FrontColors . ' Couleur(s) ( ' . $component->Ink->FrontColorDesc . ') au recto / ' . $component->Ink->BackColors . ' Couleur(s)' . ' ( ' . $component->Ink->BackColorDesc . ' ) ' . "\n";
                    break;
                }
                // $quote_desc[]= $getPaperInfoResult->PapFamType [$component_index + 1]->Lfam . ' - ' . $getPaperInfoResult->PapFamType [$component_index + 1]->Lcoul . ' - ' . $getPaperInfoResult->PapFamType [$component_index + 1]->Gramm . ' g/m2' . "\n";
            }
        }
        $row++; $col++;
        $tbl = $p->add_table_cell($tbl, $col, $row, $quote_title, $opttitrecontact);
        $imp_text_element1.=$quote_title."-Support : ".$quote_support."-Impression : ".$quote_impression;
    }
 }

它完成了每个单元格中的数据表,并跳过了放置数据的一个单元格,所以我只需要包含数据的表我该怎么做。

我看到一个可能的问题,顺便说一下,您增加了

$row++; $col++;

这意味着,对于每个其他内容,您将增加行和单元格。 我希望,仅在需要新行时才应增加该行。

我想您不仅要为foreach循环中的每次运行添加一个单元格:$ tbl = $ p-> add_table_cell($ tbl,$ col,$ row,$ quote_title,$ opttitrecontact); 也许您想添加更多的单元格,如果要添加,则应添加多个add_table_cell()调用以及要放置的数据。

但是,如Twisty所述,您可能会更精确地描述您的问题。 另外,PDFlib的支持团队可能会为您提供进一步的帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM