导出PHP为Excel,文本alignment不起作用

嗨,大家好,我一直在遇到一个罕见的alignment,而出口PHP表到Excel。 我已经设置了文本alignment方式:离开但仍然不工作。 我也寻找细胞alignment,但没有find解决办法。

这里是我的表没有出口到VEND – MS – Excel的形象: 在这里输入图像说明

而出口这种情况发生:

在这里输入图像说明

我不知道为什么excel文件有这个alignment,我将添加我的代码,但不是很干净,所以我会显示标题:

// The function header by sending raw excel header("Content-type: application/vnd-ms-excel"); // Defines the name of the export file "codelution-export.xls" header("Content-Disposition: attachment; filename=horarios-$fecha.xls"); 

这是我的代码,我添加样式到我的表的一部分:

 echo '<style>table {width:595px;text-align:left;} table{border-collapse: collapse;}table,th,td{border:1px solid #000;}</style>'; 

正如您在第二张图片中看到的,一些文字左alignment,右alignment和其他居中。

您可以使用PHPExcel库设置路线。 这两个url可能会帮助你。

PHPExcel如何为从mysql表创build的整个文档应用alignment

PHP的Excel – 设置单元格或列方向(RTL)