问题
I want to export rtf file with php, but I do not know why the css files involved.
When I open a file with extension. Rtf with Microsoft Office 2007.
it says "Problems came up in the following areas during load:
- Missing File: C / Users / user pc / Downloads / style.css
- Missing File: C / Users / user pc / Downloads / css / templates.css
- Missing File: C / Users / user pc / Downloads / css / mainmenu-horizontal.css "
This is my code:
<form name="frm" method="post">
<input class="textbox" type="hidden" name="data[judulbeasiswa]" value="<?php echo $info['jdlbeasiswa']; ?>" />
<table class="modform" width="100%">
<tr class="<?php echo bg(); ?>">
<td width="15%">Nama Lengkap</td>
<td width="85%"><input class="textbox" type="text" name="data[nmdaftar]" value="<?php echo $data['nmdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Tempat Lahir</td>
<td><input class="textbox" type="text" name="data[tmpdaftar]" value="<?php echo $data['tmpdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Tanggal Lahir</td>
<td><input class="textbox" type="text" name="data[tgllahirdaftar]" value="<?php echo FormatDate($data['tgllahirdaftar']); ?>"/><br />
<b>Valid date format:</b> dd-mm-YYYY</td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Fakultas</td>
<td><input class="textbox" type="text" name="data[fkdaftar]" value="<?php echo $data['fkdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Jurusan/Prodi</td>
<td><input class="textbox" type="text" name="data[jurdaftar]" value="<?php echo $data['jurdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Semester</td>
<td><input class="textbox_short" type="text" name="data[smsdaftar]" value="<?php echo $data['smsdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>IPK</td>
<td><input class="textbox_short" type="text" name="data[ipkdaftar]" value="<?php echo $data['ipkdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Alamat Tinggal</td>
<td><textarea name="data[almdaftar]" class="textbox" style="height:100px;"><?php echo $data['almdaftar']; ?></textarea></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Telephone/Handphone</td>
<td><input class="textbox" type="text" name="data[hubdaftar]" value="<?php echo $data['hubdaftar']; ?>" /><br />
<b>example : 027412345678</td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Asal SLTA</td>
<td><input class="textbox" type="text" name="data[asaldaftar]" value="<?php echo $data['asaldaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Jumlah Kiriman per bulan</td>
<td><input class="textbox" type="text" name="data[jumkirdaftar]" value="<?php echo $data['jumkirdaftar']; ?>" /></td>
</tr>
<tr class="readonly">
<td colspan="2" class="modsubtitle">Penanggung Jawab Utama</td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Penanggung Utama Biaya</td>
<td>
<input name="data[pubdaftar]" type="radio" value="Ayah" checked="checked" <?php if($data['pubdaftar']=='Ayah') echo checked ; ?>>Ayah
<input name="data[pubdaftar]" type="radio" value="Ibu" <?php if($data['pubdaftar']=='Ibu') echo checked ; ?>>Ibu
<input name="data[pubdaftar]" type="radio" value="Saudara/Famili" <?php if($data['pubdaftar']=='Saudara/Famili') echo checked ; ?> >Saudara/Famili
</td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Nama</td>
<td><input class="textbox" type="text" name="data[nmpubdaftar]" value="<?php echo $data['nmpubdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Pekerjaan</td>
<td><input class="textbox" type="text" name="data[pkpubdaftar]" value="<?php echo $data['pkpubdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Alamat</td>
<td><textarea name="data[alpubdaftar]" class="textbox" style="height:100px;"><?php echo $data['alpubdaftar']; ?></textarea></td>
</tr>
<tr class="readonly">
<td colspan="2" class="modsubtitle">Rekening Tujuan</td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Nama Rekening</td>
<td><input class="textbox" type="text" name="data[nmrekdaftar]" value="<?php echo $data['nmrekdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>No Rekening</td>
<td><input class="textbox" type="text" name="data[norekdaftar]" value="<?php echo $data['norekdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Nama Bank</td>
<td><input class="textbox" type="text" name="data[nmbankdaftar]" value="<?php echo $data['nmbankdaftar']; ?>" /></td>
</tr>
<tr class="<?php echo bg(); ?>">
<td>Cabang Bank</td>
<td><input class="textbox" type="text" name="data[cbbankdaftar]" value="<?php echo $data['cbbankdaftar']; ?>" /></td>
</tr>
</table>
<div class="modform">
<?php
echo $row['descbeasiswa'];
?>
<hr />
Bahwasannya saya menyatakan dengan form diatas adalah benar adanya, dan apabila ditemukan tindak kecurangan maka terkait akademik dan yang melekat dengan anda menjadi kewajiban perguruan tinggi
</div>
<div class="modtitle" align="center">
<input class="tombol" type="submit" name="SUPDATE" value="SUBMIT"/>
<input class="tombol" type="submit" name="EXPORT" value="CETAK"/>
</div>
<input type="hidden" name="_nim" value="<?php echo $_POST['_nim']; ?>"/>
<input type="hidden" name="_bea" value="<?php echo $_POST['_bea']; ?>"/>
</form>
and this is when I call the function _exportRTF()
$mydata = _ceknim();
$data = $_POST['data'];
if ($_POST['EXPORT']){
_exportRTF($mydata,$data);
}
My Function _exportRTF()
function _exportRTF($mydata,$data){
$document = file_get_contents("modules/mod_beasiswa/tes/pendaftaranbeasiswa.rtf");
// replace
$document = str_replace("%%NAMA%%", $mydata['nama'], $document);
$document = str_replace("%%PRODI%%", $mydata['jenjang'], $document);
$document = str_replace("%%FAKULTAS%%", $mydata['fakultas'], $document);
$document = str_replace("%%ANGKATAN%%", $mydata['angkatan'], $document);
$document = str_replace("%%BEASISWA%%", $data['judulbeasiswa'], $document);
$document = str_replace("%%NAMALENGKAP%%", $data['nmdaftar'], $document);
$document = str_replace("%%TEMPATLAHIR%%", $data['tmpdaftar'], $document);
$document = str_replace("%%TANGGALLAHIR%%", $data['tgllahirdaftar'], $document);
$document = str_replace("%%FAKULTAS2%%", $data['fkdaftar'], $document);
$document = str_replace("%%PRODI2%%", $data['jurdaftar'], $document);
$document = str_replace("%%SEMESTER%%", $data['smsdaftar'], $document);
$document = str_replace("%%IPK%%", $data['ipkdaftar'], $document);
$document = str_replace("%%ALAMAT%%", $data['almdaftar'], $document);
$document = str_replace("%%TELEPHONE%%", $data['hubdaftar'], $document);
$document = str_replace("%%SLTA%%", $data['asaldaftar'], $document);
$document = str_replace("%%JUMLAHKIRIMAN%%", $data['jumkirdaftar'], $document);
$document = str_replace("%%PENANGGUNGUTAMA%%", $data['pubdaftar'], $document);
$document = str_replace("%%NAMAPENANGGUNG%%", $data['nmpubdaftar'], $document);
$document = str_replace("%%PEKERJAANPENANGGUNG%%", $data['pkpubdaftar'], $document);
$document = str_replace("%%ALAMATPENANGGUNG%%", $data['alpubdaftar'], $document);
$document = str_replace("%%NAMAREKENING%%", $data['nmrekdaftar'], $document);
$document = str_replace("%%NOREKENING%%", $data['norekdaftar'], $document);
$document = str_replace("%%NAMABANK%%", $data['nmbankdaftar'], $document);
$document = str_replace("%%CABANGBANK%%", $data['cbbankdaftar'], $document);
// header untuk membuka file output RTF dengan MS. Word
header("Content-type: application/msword");
header("Content-disposition: inline; filename='permohonanbeasiswa.rtf'");
header("Content-length: " . strlen($document));
echo $document;
}
来源:https://stackoverflow.com/questions/22549701/php-export-rtf-include-css-files