Setting a chart's title

How do I set a chart's title with FlexCel? In Excel OLE automation I can do this by setting the property ActiveSheet.ChartObjects['Chart 10'].Chart.ChartTitle.Text.

I wonder if it is possible at all to set a chart's title with FlexCel. I found the TXlsFile.GetChart function and it even returns an object, but the GetDataLabels function returns an empty array which seems not to be correct since the Chart has a title.

Hi,
First of all sorry for the delay, there was a little too much support in the last days and this post (slong with others) got delayed. Thankfully things are coming back to normal now.

About the question:
In xls files, GetDataLabels should return an array, I've just tested it here and it seems to work. And since the chart rendering engine uses GetDataLabels to render the xls charts to pdf/html, GetDataLabels is a very well tested method. If it is returning an empty array, there are a couple of possibilities, but the most likely is that it is not a real chart title, but a textbox put to look like a chart title. Of course, if you can send me an example to adrian@tmssoftware.com I can tell you more exactly what is happening.

Now, about the solution: The main issue is that while GetDataLabels should work fine, SetDataLabels is not yet fully implemented and won't change the titles. There are 2 workarounds that I can think of:

1)If this is not a real title but a textbox, you can change the text with Chart.SetObjectText as in any normal textbox. If this is an actual title but you have control over the file, you could remove the title and change it for a textbox.

2)You can link either the chart title or the textbox inside the chart to a cell in the file. Just select the title, and write say =A100 in the formula bar (not in the box itself, but on the formula bar at the top). Then the title will be linked to whatever you write in cell A100, and so to change the title you just change cell A100. FlexCel is fully aware of this and when exporting the chart it will also update the title to whatever is in the cell.

If you have control over the file, I would go for option 2), it is the most elegant, and I would actually even prefer it to manually modifying the chart title when we add the possibility to do that most likely in FlexCel 7 which should be the next version.


Hi Adrian,

Ok I have an xlsx file (not an xls file) where the chart object can be retrieved with FlexCel but the data label array has length 0. Your suggested option 2) is surely the one to go for for the moment, but I would appreciate it, if the chart title could be set directly. If you want I can send you the xlsx file mentioned above.

Hi,

Sorry about that, but indeed, allowing you to modify charts and add new ones in both xls or xlsx is the feature we are working on right now (and also rendering xlsx charts to pdf), and it will be the most important feature in FlexCel 7 which should be some months away. There is a lot of work to be done in the chart front yet, specially in the rendering front since xlsx charts are completely different from xls charts so we need to write a new chart engine.

But work is going well in that front, and I hope FlexCel 7 won't take too long. As always we are kind of slow doing new features because there is just a lot of testing to do to guarantee this all works as expected. We prefer to be slow but reliable, than really fast and full of bugs.