更新时间:2023-02-19 20:13:06
更新1: 目前,我可以使用PDF.这就是我的操作方式:首先,我从其站点下载了TCPdf,并在Yii中将其打开作为第三方库.然后:
UPDATE 1: At the moment I got PDFs working. This is how I did it: First I downloaded TCPdf from its site and open it in Yii as a 3rd-party library. Then:
Controller: protected/controllers/mycontroller.php
public function actionGeneratePdf() {
Yii::import('application.vendors.*');
require_once('tcpdf/tcpdf.php');
require_once('tcpdf/config/lang/eng.php');
$pdf = new TCPDF();
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 001');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetHeaderData('', 0, PDF_HEADER_TITLE, '');
$pdf->setHeaderFont(Array('helvetica', '', 8));
$pdf->setFooterFont(Array('helvetica', '', 6));
$pdf->SetMargins(15, 18, 15);
$pdf->SetHeaderMargin(5);
$pdf->SetFooterMargin(10);
$pdf->SetAutoPageBreak(TRUE, 0);
$pdf->SetFont('dejavusans', '', 7);
$pdf->AddPage();
$pdf->writeHTML("<span>Hello World!</span>", true, false, true, false, '');
$pdf->LastPage();
$pdf->Output("example_002.pdf", "I");
}
View: Wherever you want to place a trigger to your controller:
echo CHtml::link('Generate PDF', array('mycontroller/generatePdf'));
无论如何,我希望能够生成Word文档,因为需求表明报表将在生成后由用户进行编辑.
Anyway I want to be able to generate a word document as the requirement says the report is going to be edited by the user after generation.
更新2: 对于Word文档的报告生成,这就是我正在做的事情.
UPDATE 2: For the Word document's report generation this is what I am doing.