Open Amamatthew opened 8 years ago
Yes, proper way is to add those properties as configurable parameters, becouse currently it's set to A4 source
If you want to change it yourself in the code, you can add any value supported by phpexcel found here
YES. I pass the arguments to the __construct() later: $R=new PHPReport(array("PaperSize"=>64));
/**
* Creates new report with some configuration parameters
* @param array $config
*/
public function __construct($config=array())
{
$this->setConfig($config);
if(!empty($this->_PaperSize)){
$this->init($this->_PaperSize);
}else{
$this->init("default");
}
}
/**
* Initializes internal objects
*/
private function init($_PaperSize)
{
if($this->_template!='')
{
$this->loadTemplate();
}
else
{
$this->createTemplate($_PaperSize);
}
}
/**
* Creates PHPExcel object and template for report
*/
private function createTemplate()
{
$this->objPHPExcel = new PHPExcel();
$this->objPHPExcel->setActiveSheetIndex(0);
$this->objWorksheet = $this->objPHPExcel->getActiveSheet();
//TODO: other parameters
$this->objWorksheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
if("default"==$this->_PaperSize){
$this->objWorksheet->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
}else{
$this->objWorksheet->getPageSetup()->setPaperSize($this->_PaperSize);
}
$this->objWorksheet->getPageSetup()->setHorizontalCentered(true);
$this->objWorksheet->getPageSetup()->setVerticalCentered(false);
$this->_usingTemplate=false;
}
Sometimes there's a extra width with too many table columns we need to specify the papersize property for the PDF output.