ユーザーが表示する行数を選択し、続いてデータを Excel にエクスポートするフォーム内のボタンを選択する Web ページがあります。
<form method="post" action="">
<input type="Submit" name="excel" value="Export" class="button">
</form>
データを取得して、次の方法でExcelファイルに入れることができます
if($_POST['excel']){
$phpExcel = new PHPExcel();
$styleArray = array(
'font' => array(
'bold' => true,
)
);
//Get the active sheet and assign to a variable
$foo = $phpExcel->getActiveSheet();
//add column headers, set the title and make the text bold
$foo->setCellValue("A1", "Nombre")
->setCellValue("B1", "Paterno")
->setCellValue("C1", "Pkey")
->setCellValue("D1", "Telefono")
->setCellValue("E1", "Ciudad")
->setCellValue("F1", "Used")
->setTitle("Contactos Encuestas")
->getStyle("A1:F1")->applyFromArray($styleArray);
$xlsRow = 1;
foreach ($rows as $column) {
$foo->setCellValue("A".$xlsRow++, $column[2])
->setCellValue("B".$xlsRow++, $column[3])
->setCellValue("C".$xlsRow++, $column[0])
->setCellValue("D".$xlsRow++, $column[1])
->setCellValue("E".$xlsRow++, $column[5])
->setCellValue("F".$xlsRow++, $column[4]);
}
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"ENcuestas_Contactos.xls\"");
header("Cache-Control: max-age=0");
$objWriter = PHPExcel_IOFactory::createWriter($phpExcel, "Excel5");
$objWriter->save("php://output");
$phpExcel->disconnectWorksheets();
unset($phpExcel);
}
これはちょっとうまくいきますが、問題は、ボタンや画像などの Web ページ要素に沿った奇妙なテキストが Excel ファイルに配置されることです。
問題は何ですか?
私が行方不明の設定はありますか?