1
当我尝试在单元格周围设置中等边框时,它将无法正确显示(可在图片中看到)。在编辑单元格而不更改其值(输入单元格编辑并按下Enter键)后,它正常显示。 我使用Excel 2007中PHPExcel公式边框厚度问题
<?php
include 'mySQLconnect.php';
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
require_once dirname(__FILE__) . '/PHPExcel_1.8.0/Classes/PHPExcel.php';
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet();
$objPHPExcel->getActiveSheet()->setTitle('Sheet 1');
$objPHPExcel->getActiveSheet()->setCellValue('B2', '1');
$objPHPExcel->getActiveSheet()->setCellValue('B2', '1');
$objPHPExcel->getActiveSheet()->setCellValue('B3', '1');
$objPHPExcel->getActiveSheet()->setCellValue('B4', '1');
$objPHPExcel->getActiveSheet()->setCellValue('B6', '=SUM(B2:B4)');
$objPHPExcel->getActiveSheet()->getStyle('B6')->applyFromArray(
array('borders' => array(
'bottom' => array('style' =>PHPExcel_Style_Border::BORDER_MEDIUM),
'right' => array('style' =>PHPExcel_Style_Border::BORDER_MEDIUM),
'left' => array('style' =>PHPExcel_Style_Border::BORDER_MEDIUM),
'top' => array('style' =>PHPExcel_Style_Border::BORDER_MEDIUM)
)
)
);
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="data.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
?>
任何帮助将不胜感激。
我试过allboarders,但rersult仍然是一样的。底部边界比其他边界更薄。当我在单元格B6中写入文本而不是公式时,所有边界都从头开始正确显示。这似乎是与PHPExcel或Excel 2007的问题。 – Toni
我需要它为另一个项目。上面的代码只是为了向社区描述问题。我已经在这里上传了测试文件:[link](http://tv-laufach.de/ExcelExportTest.php)。可能每个人都打开它并在此处报告他的结果。我知道这不是一个大问题,但每次手动编辑单元格都很麻烦,而且Excel显示屏没有任何好的照片。 – Toni
您是否尝试将'createWriter'上的excel格式更改为'Excel2007'? – Nue