J'ai utilisé Dreamweaver pour écrire le code, mais PHPExcel ne parvient pas à exporter le fichier xls correct dans la page Web.
phpcn_u13074
phpcn_u13074 2017-08-03 16:16:40
0
2
1620

Ceci est mon code

<?php

$dir=dirname(_FILE_);

require $dir."/PHPExcel/PHPExcel.php";

$objPHPExcel=new PHPExcel();

$ objSheet =$objPHPExcel->getActiveSheet();

$objSheet->setTitle("demo");

//$objSheet->setCellValue("A1","Coco")->setCellValue(" b1 ","Egg");

$array=array(

array("Nom","Age"),

array("Dake","58")

);

$objSheet -> fromArray($array);

$objWriter=PHPExcel_IOFactory::createWriter($objPHPExcel,"Excel5");

$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);

header( 'Content-Type: application/vnd .ms-excel');

header('Content-Disposition: attachment;filename="ch3.xls"');

header('Cache-Control: max-age=0');

$objWriter- >save("php://output");

?> Mais le fichier xls généré fait exactement ceci :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional// FR" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/ xhtml"> ;

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Document sans titre< ;/title>

</tête>

<corps>�� ࡱ �; ��  ���� ����������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ������� ����   


���� ������������ ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ����Oh �� +'��0� @ H h � �

� � � Feuille de calcul sans titre Créateur inconnu Créateur inconnu@� � �@ � @�� �@ �     �

� � B � = �%r 8 X " 1 � � Calibri� �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    � �� �    �  � � ����8���������������� ��������������3f������ff����f���������������������� ������������̙��̙3f�3���������fff����3f3�f333�3�3f33�333� démo� � g� � �Y

T t^�� 'Y�S

     �

� � * + � � � � � & ffffff�?' ffffff�?( �?) �?�" d X X 333333�?333333�? U } $    } $  �

M@> � @d� � d g g �����

�� ���� � � +,��0� H P X` h p

x � �

Worksheet Feuilles de calcul Root Entry ��������   �F�� �@ � �� �@ � � SummaryInformation( ����   �F�Cahier d'exercices ������������  �F � DocumentSummaryInformation8 ������������ �F �� ��� ������������������������������������������ ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� ���������������������������������������������� �� 

</body>

</html>无法显示.jpg

phpcn_u13074
phpcn_u13074

répondre à tous(1)
Ty80

$dir=dirname(_FILE_); La première ligne est fausse. La constante magique est __FILE__, pas _FILE_.

QQ截图20170805085356.png

  • répondre Comment parvenir à lire les données dans la base de données ?
    木槿 auteur 2017-11-01 08:52:02
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!