Convert string text to rich text for chart title and axis labels

This commit is contained in:
Mark Baker 2012-06-18 23:43:53 +01:00
parent ccc562dea8
commit d700807ed0
2 changed files with 14 additions and 5 deletions

View File

@ -52,7 +52,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$aFlippedStringTable = null; // For faster lookup
// Is an existing table given?
if (!is_null($pExistingTable) && is_array($pExistingTable)) {
if (($pExistingTable !== NULL) && is_array($pExistingTable)) {
$aStringTable = $pExistingTable;
}
@ -94,7 +94,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
*/
public function writeStringTable($pStringTable = null)
{
if (!is_null($pStringTable)) {
if ($pStringTable !== NULL) {
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
@ -225,12 +225,18 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
* Write Rich Text
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_RichText $pRichText Rich text
* @param string|PHPExcel_RichText $pRichText text string or Rich text
* @param string $prefix Optional Namespace prefix
* @throws Exception
*/
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix=NULL)
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix=NULL)
{
if (!$pRichText instanceof PHPExcel_RichText) {
$textRun = $pRichText;
$pRichText = new PHPExcel_RichText();
$pRichText->createTextRun($textRun);
}
if ($prefix !== NULL)
$prefix .= ':';
// Loop through rich text elements

View File

@ -83,10 +83,13 @@ $plotarea = new PHPExcel_Chart_PlotArea(null, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, null, false);
$title = new PHPExcel_Chart_Title('Test Chart');
// Create the chart
$chart = new PHPExcel_Chart(
'chart1', // name
null, // title
$title, // title
$legend, // legend
$plotarea, // plotArea
true, // plotVisibleOnly