3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/asposeslidesjava/Charts/existingchart.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir+ "AsposeChart.pptx")
sld = pres.getSlides().get_Item(0)
chart = sld.getShapes().get_Item(0)
defaultWorksheetIndex = 0
fact = chart.getChartData().getChartDataWorkbook()
fact.getCell(defaultWorksheetIndex, 1, 0, "Modified Category 1")
fact.getCell(defaultWorksheetIndex, 2, 0, "Modified Category 2")
series = chart.getChartData().getSeries().get_Item(0)
fact.getCell(defaultWorksheetIndex, 0, 1, "New_Series1") series.getDataPoints().get_Item(0).getValue().setData(90)
series.getDataPoints().get_Item(1).getValue().setData(123)
series.getDataPoints().get_Item(2).getValue().setData(44)
series = chart.getChartData().getSeries().get_Item(1)
fact.getCell(defaultWorksheetIndex, 0, 2, "New_Series2") series.getDataPoints().get_Item(0).getValue().setData(23)
series.getDataPoints().get_Item(1).getValue().setData(67)
series.getDataPoints().get_Item(2).getValue().setData(99)
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 3, "Series 3"), chart.getType())
series = chart.getChartData().getSeries().get_Item(2)
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 3, 20))
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 50))
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 30))
chart.setType(Rjb::import('com.aspose.slides.ChartType').ClusteredCylinder)
save_format = Rjb::import('com.aspose.slides.SaveFormat')
pres.save(data_dir + "AsposeChartModified.pptx", save_format.Pptx)
puts "Updated chart, please check the output file."
end
|