Reputation: 106
The constructor of PHPExcel_Chart_DataSeriesValues is:
construct (
$dataType = self::DATASERIES_TYPE_NUMBER,
$dataSource = null,
$formatCode = null,
$pointCount = 0,
$dataValues = array(),
$marker = null
)
I try to insert formatCode in this way:
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', 'worksheet!$A$2:$A$9', 'yyyy-mm-dd hh:mm:ss', NULL, 4));
but it does not work? what is wrong here?
I use PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART.
When I not use 'formatCode' my x-axis shows raw excel datetimes: 41760,41761..,and so on?instead of 2014-05-01 00:00:00,2014-05-01 12:00:00,..,
Does anyone have an good example on how to insert date and time on the x-axis in PHPExcel?
Upvotes: 0
Views: 780
Reputation: 106
I found a solution by making a hack in PHPExcel/Writer/Excel2007/Chart.php line 493
//$objWriter->writeAttribute('formatCode', "General");
$objWriter->writeAttribute('formatCode', "dd/mm/yy\ hh:mm:ss;@");
Change the formatCode to "dd/mm/yy\ hh:mm:ss;@"
but why is "General" hard-coded !?
UPDATE: Found another bug in PHPExcel/Writer/Excel2007/Chart.php Change $id2 to $id1. If you do not want problems with the y-axis label positioning?
if ($id1 > 0) {
$objWriter->startElement('c:crossAx');
//$objWriter->writeAttribute('val', $id2);
$objWriter->writeAttribute('val', $id1);
$objWriter->endElement();
Upvotes: 2