Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHPExcel在浏览器中水平对齐excel工作表_Php_Phpexcel - Fatal编程技术网

如何使用PHPExcel在浏览器中水平对齐excel工作表

如何使用PHPExcel在浏览器中水平对齐excel工作表,php,phpexcel,Php,Phpexcel,我有一个使用PHPExcel仅显示/查看excel文件的页面,下面是我的代码: <?php include 'Classes/PHPExcel/IOFactory.php'; $inputFileType = 'Excel2007'; $inputFileName = 'files/myFile.xlsx'; $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader-&

我有一个使用PHPExcel仅显示/查看excel文件的页面,下面是我的代码:

<?php
include 'Classes/PHPExcel/IOFactory.php';
$inputFileType = 'Excel2007';
$inputFileName = 'files/myFile.xlsx';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
exit;
?>
但我没有运气

这是我的最终代码:

<?php
include 'Classes/PHPExcel/IOFactory.php';
$inputFileType = 'Excel2007';
$inputFileName = 'files/myFile.xlsx';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');    

exit;
?>


但这不会给我带来好运。->什么错误?没有错误。虽然我已经将
$objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true)放在浏览器的左侧,但它仍会显示出来属性。我的代码的问题是什么?为什么它总是显示在左侧?您确实意识到,页面设置属性仅适用于从MS Excel中打印工作表的情况。在MS Excel中加载此电子表格时,您实际希望看到什么?@MarkBaker:谢谢您提供的信息,先生!不管怎样,我怎样才能水平对齐我的工作表中心,先生?先生,你有其他选择吗?你是想设置单元格对齐吗?如果是这样,只需查看开发人员文档的第4.6.20节(
对齐和换行文本
),了解设置单元格对齐的示例
<?php
include 'Classes/PHPExcel/IOFactory.php';
$inputFileType = 'Excel2007';
$inputFileName = 'files/myFile.xlsx';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');    

exit;
?>