OpenOffice Calc自动化如何更改散点图的图表标签

时间:2010-11-16 10:27:16

标签: delphi automation openoffice-calc

您好,请帮我解决以下问题。我创建了一个分散的图表,并从列的数据中绘制图表。使用的数据不仅仅在确定标签的单元格之后:

Column O:

Pwm1   <-- This is the cell I want to see as the label
27114  <-- not used data for graph
27055  <-- etc
27092
27070  <-- data for graph starts here
27105
27024
27092  <-- data for graph ends here

我希望LABEL单元格显示为Y列标签名称(现在是'Column O'),但是如何? 据我所知(代码是Delphi,但如果有人可以帮助我一个基本的例子也可以):

(* Turn the symbol of the data points off *)
oChart.Diagram.SymbolType := _chartChartSymbolTypeNONE;

oDataSeries := oChart.getUsedData;
oDataSequences := oDataSeries.getDataSequences;
ShowMessage(oDataSequences[1].Label.SourceRangeRepresentation);

SourceRangeRepresentation返回当前标签,但如何更改?

谢谢广告

1 个答案:

答案 0 :(得分:1)

这样做了:

(*
creat new DataSequence from range representaion
that provides real data and its role in the series
oDataProvider: com.sun.star.chart2.data.XDataProvider
sRangeRepresentation: range address e.g. Sheet1.A1:B2
sRole: role is defined in com.sun.star.chart2.data.DataSequenceRole
*)
Function CreateDataSequence( oDataProvider : Variant; sRangeRepresentation : String; sRole :String ) : Variant;
Var
        oDataSequence : Variant;

Begin
 (* create .chart2.data.DataSequence from range representation *)
 oDataSequence := oDataProvider.createDataSequenceByRangeRepresentation(sRangeRepresentation);
 If NOT VarIsEmpty(oDataSequence) Then
  oDataSequence.Role := sRole;

 Result := oDataSequence;
End;


oNewLabel := CreateDataSequence(oChart.getDataProvider, '$Sheet1.$O$7', 'label');
oDataSequences[1].setLabel(oNewLabel);