asposeslidesjava 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/LICENSE +21 -0
  4. data/README.md +31 -0
  5. data/Rakefile +2 -0
  6. data/asposeslidesjava.gemspec +27 -0
  7. data/config/aspose.yml +5 -0
  8. data/data/Aspose.html +55 -0
  9. data/data/Aspose.pptx +0 -0
  10. data/data/AsposeChart.pptx +0 -0
  11. data/data/Bass-Drum.wav +0 -0
  12. data/data/HelloWorld.pptx +0 -0
  13. data/data/Presentation1.ppt +0 -0
  14. data/data/Shapes/OleEmbed.pptx +0 -0
  15. data/data/Shapes/Wildlife.mp4 +0 -0
  16. data/data/Shapes/sample.xlsx +0 -0
  17. data/data/Source.odp +0 -0
  18. data/data/Tables/aspose-logo.jpg +0 -0
  19. data/data/Tables/demotable.pptx +0 -0
  20. data/data/Text/Welcome.pptx +0 -0
  21. data/data/Text/import.html +119 -0
  22. data/data/Text/input.pptx +0 -0
  23. data/data/Wildlife.mp4 +0 -0
  24. data/data/WithActiveX.pptm +0 -0
  25. data/data/aspose-logo.jpg +0 -0
  26. data/data/demo.pptx +0 -0
  27. data/data/night.jpg +0 -0
  28. data/data/vbamacro.pptx +0 -0
  29. data/lib/asposeslidesjava.rb +71 -0
  30. data/lib/asposeslidesjava/ActiveX/addactivex.rb +21 -0
  31. data/lib/asposeslidesjava/Charts/chartlegend.rb +33 -0
  32. data/lib/asposeslidesjava/Charts/chartproperties.rb +120 -0
  33. data/lib/asposeslidesjava/Charts/chartseries.rb +28 -0
  34. data/lib/asposeslidesjava/Charts/charttrendlines.rb +53 -0
  35. data/lib/asposeslidesjava/Charts/createchart.rb +163 -0
  36. data/lib/asposeslidesjava/Charts/errorbars.rb +84 -0
  37. data/lib/asposeslidesjava/Charts/existingchart.rb +66 -0
  38. data/lib/asposeslidesjava/Charts/formattingchartentities.rb +163 -0
  39. data/lib/asposeslidesjava/Charts/setlabeldistance.rb +24 -0
  40. data/lib/asposeslidesjava/Charts/setpiechartcolors.rb +118 -0
  41. data/lib/asposeslidesjava/Presentation/convertingtohtml.rb +25 -0
  42. data/lib/asposeslidesjava/Presentation/convertingtonotes.rb +37 -0
  43. data/lib/asposeslidesjava/Presentation/convertingtopdf.rb +16 -0
  44. data/lib/asposeslidesjava/Presentation/convertingtotiff.rb +62 -0
  45. data/lib/asposeslidesjava/Presentation/convertingtoxps.rb +43 -0
  46. data/lib/asposeslidesjava/Presentation/odptopptx.rb +16 -0
  47. data/lib/asposeslidesjava/Presentation/ppttopptx.rb +16 -0
  48. data/lib/asposeslidesjava/Presentation/properties.rb +106 -0
  49. data/lib/asposeslidesjava/Presentation/zoom.rb +20 -0
  50. data/lib/asposeslidesjava/Shapes/addellipseshape.rb +60 -0
  51. data/lib/asposeslidesjava/Shapes/addinglineshape.rb +65 -0
  52. data/lib/asposeslidesjava/Shapes/addrectangleshape.rb +58 -0
  53. data/lib/asposeslidesjava/Shapes/cloneshape.rb +32 -0
  54. data/lib/asposeslidesjava/Shapes/connectshapes.rb +83 -0
  55. data/lib/asposeslidesjava/Shapes/embedvideo.rb +32 -0
  56. data/lib/asposeslidesjava/Shapes/fillingshapes.rb +98 -0
  57. data/lib/asposeslidesjava/Shapes/findshape.rb +30 -0
  58. data/lib/asposeslidesjava/Shapes/formatlines.rb +99 -0
  59. data/lib/asposeslidesjava/Shapes/frame.rb +85 -0
  60. data/lib/asposeslidesjava/Shapes/groupshape.rb +35 -0
  61. data/lib/asposeslidesjava/Shapes/oleobject.rb +26 -0
  62. data/lib/asposeslidesjava/Shapes/rotatingshapes.rb +25 -0
  63. data/lib/asposeslidesjava/Shapes/shapeproperties.rb +30 -0
  64. data/lib/asposeslidesjava/Shapes/shapethumbnail.rb +18 -0
  65. data/lib/asposeslidesjava/Slides/accessslides.rb +38 -0
  66. data/lib/asposeslidesjava/Slides/addslides.rb +28 -0
  67. data/lib/asposeslidesjava/Slides/background.rb +76 -0
  68. data/lib/asposeslidesjava/Slides/changingposition.rb +22 -0
  69. data/lib/asposeslidesjava/Slides/cloneslides.rb +72 -0
  70. data/lib/asposeslidesjava/Slides/creatingsvg.rb +27 -0
  71. data/lib/asposeslidesjava/Slides/hyperlinks.rb +19 -0
  72. data/lib/asposeslidesjava/Slides/removeslides.rb +46 -0
  73. data/lib/asposeslidesjava/Slides/sizeandlayout.rb +55 -0
  74. data/lib/asposeslidesjava/Slides/thumbnail.rb +113 -0
  75. data/lib/asposeslidesjava/Slides/transitions.rb +24 -0
  76. data/lib/asposeslidesjava/SmartArt/addsmartart.rb +26 -0
  77. data/lib/asposeslidesjava/SmartArt/fillformat.rb +28 -0
  78. data/lib/asposeslidesjava/Tables/addimage.rb +34 -0
  79. data/lib/asposeslidesjava/Tables/aligntext.rb +48 -0
  80. data/lib/asposeslidesjava/Tables/clonerowcolumn.rb +76 -0
  81. data/lib/asposeslidesjava/Tables/createtable.rb +61 -0
  82. data/lib/asposeslidesjava/Tables/removerowcolumn.rb +27 -0
  83. data/lib/asposeslidesjava/Text/createtextbox.rb +79 -0
  84. data/lib/asposeslidesjava/Text/exporttexttohtml.rb +30 -0
  85. data/lib/asposeslidesjava/Text/importhtml.rb +51 -0
  86. data/lib/asposeslidesjava/Text/managefont.rb +30 -0
  87. data/lib/asposeslidesjava/Text/managetext.rb +128 -0
  88. data/lib/asposeslidesjava/Text/paragraphs.rb +260 -0
  89. data/lib/asposeslidesjava/Text/replacetext.rb +23 -0
  90. data/lib/asposeslidesjava/Text/shadoweffects.rb +37 -0
  91. data/lib/asposeslidesjava/Text/textfont.rb +130 -0
  92. data/lib/asposeslidesjava/Text/wordart.rb +45 -0
  93. data/lib/asposeslidesjava/VBAMacros/removevbamacro.rb +18 -0
  94. data/lib/asposeslidesjava/activex.rb +1 -0
  95. data/lib/asposeslidesjava/asposeslides.rb +10 -0
  96. data/lib/asposeslidesjava/charts.rb +9 -0
  97. data/lib/asposeslidesjava/helloworld.rb +38 -0
  98. data/lib/asposeslidesjava/presentation.rb +9 -0
  99. data/lib/asposeslidesjava/shapes.rb +15 -0
  100. data/lib/asposeslidesjava/slides.rb +11 -0
  101. data/lib/asposeslidesjava/smartart.rb +2 -0
  102. data/lib/asposeslidesjava/tables.rb +5 -0
  103. data/lib/asposeslidesjava/text.rb +10 -0
  104. data/lib/asposeslidesjava/vbamacros.rb +1 -0
  105. data/lib/asposeslidesjava/version.rb +3 -0
  106. data/samples/test.rb +8 -0
  107. metadata +206 -0
@@ -0,0 +1,55 @@
1
+ module Asposeslidesjava
2
+ module SizeAndLayout
3
+ def initialize()
4
+ # Setting the Size and Type of a slide
5
+ set_size_and_type()
6
+
7
+ # Setting the page size when generating PDF
8
+ set_page_size_for_pdf()
9
+ end
10
+
11
+ def set_size_and_type()
12
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
13
+
14
+ # Instantiate Presentation class that represents the presentation file
15
+ pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
16
+ aux_pres = Rjb::import('com.aspose.slides.Presentation').new
17
+
18
+ slide = pres.getSlides().get_Item(0)
19
+
20
+ # Set the slide size of generated presentations to that of source
21
+ aux_pres.getSlideSize().setType(pres.getSlideSize().getType())
22
+ aux_pres.getSlideSize().setSize(pres.getSlideSize().getSize())
23
+
24
+ # Clone required slide
25
+ aux_pres.getSlides().addClone(pres.getSlides().get_Item(0))
26
+ aux_pres.getSlides().removeAt(0)
27
+
28
+ # Saving the presentation
29
+ save_format = Rjb::import('com.aspose.slides.SaveFormat')
30
+ pres.save(data_dir + "Slide_Size_Type.pptx", save_format.Pptx)
31
+
32
+ puts "Set slide size and type, please check the output file."
33
+ end
34
+
35
+ def set_page_size_for_pdf()
36
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
37
+
38
+ # Instantiate Presentation class that represents the presentation file
39
+ pres = Rjb::import('com.aspose.slides.Presentation').new
40
+
41
+ # Set SlideSize.Type Property
42
+ pres.getSlideSize().setType(Rjb::import('com.aspose.slides.SlideSizeType').A4Paper)
43
+
44
+ # Set different properties of PDF Options
45
+ opts = Rjb::import('com.aspose.slides.PdfOptions').new
46
+ opts.setSufficientResolution(600)
47
+
48
+ # Saving the presentation
49
+ save_format = Rjb::import('com.aspose.slides.SaveFormat')
50
+ pres.save(data_dir + "Export.pdf", save_format.Pdf, opts)
51
+
52
+ puts "Set page size for pdf, please check the output file."
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,113 @@
1
+ module Asposeslidesjava
2
+ module Thumbnail
3
+ def initialize()
4
+ # Generating a Thumbnail from a Slide
5
+ create_thumbnail()
6
+
7
+ # Generating a Thumbnail from a Slide with User Defined Dimensions
8
+ create_thumbnail_custom_size()
9
+
10
+ # Generating a Thumbnail from a Slide in Notes Slides View
11
+ create_thumbnail_in_notes_slides_view()
12
+
13
+ # Generating a Thumbnail of User Defined Window from a Slide
14
+ create_thumbnail_of_user_defined_window()
15
+ end
16
+
17
+ # Generating a Thumbnail from a Slide
18
+ def create_thumbnail()
19
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
20
+
21
+ # Instantiate Presentation class that represents the presentation file
22
+ pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
23
+
24
+ # Access the first slide
25
+ slide = pres.getSlides().get_Item(0)
26
+
27
+ # Create a full scale image
28
+ image = slide.getThumbnail()
29
+
30
+ # Save the image to disk in JPEG format
31
+ Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
32
+
33
+ puts "Created thumbnail, please check the output file."
34
+ end
35
+
36
+ # Generating a Thumbnail from a Slide with User Defined Dimensions
37
+ def create_thumbnail_custom_size()
38
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
39
+
40
+ # Instantiate Presentation class that represents the presentation file
41
+ pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
42
+
43
+ # Access the first slide
44
+ slide = pres.getSlides().get_Item(0)
45
+
46
+ # User defined dimension
47
+ desired_x = 1200
48
+ desired_y = 800
49
+
50
+ # Getting scaled value of X and Y
51
+ scale_x = (1.0 / pres.getSlideSize().getSize().getWidth()) * desired_x
52
+ scale_y = (1.0 / pres.getSlideSize().getSize().getHeight()) * desired_y
53
+
54
+ # Create a full scale image
55
+ image = slide.getThumbnail(scale_x, scale_y)
56
+
57
+ # Save the image to disk in JPEG format
58
+ Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
59
+
60
+ puts "Created thumbnail with custom size, please check the output file."
61
+ end
62
+
63
+ # Generating a Thumbnail from a Slide in Notes Slides View
64
+ def create_thumbnail_in_notes_slides_view()
65
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
66
+
67
+ # Instantiate Presentation class that represents the presentation file
68
+ pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
69
+
70
+ # Access the first slide
71
+ slide = pres.getSlides().get_Item(0)
72
+
73
+ # User defined dimension
74
+ desired_x = 1200
75
+ desired_y = 800
76
+
77
+ # Getting scaled value of X and Y
78
+ scale_x = (1.0 / pres.getSlideSize().getSize().getWidth()) * desired_x
79
+ scale_y = (1.0 / pres.getSlideSize().getSize().getHeight()) * desired_y
80
+
81
+ # Create a full scale image
82
+ image = slide.getNotesSlide().getThumbnail(scale_x, scale_y)
83
+
84
+ # Save the image to disk in JPEG format
85
+ Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
86
+
87
+ puts "Created thumbnail in notes slides view, please check the output file."
88
+ end
89
+
90
+ # Generating a Thumbnail of User Defined Window from a Slide
91
+ def create_thumbnail_of_user_defined_window()
92
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
93
+
94
+ # Instantiate Presentation class that represents the presentation file
95
+ pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
96
+
97
+ # Access the first slide
98
+ slide = pres.getSlides().get_Item(0)
99
+
100
+ # Create a full scale image
101
+ image = slide.getThumbnail(1,1)
102
+
103
+ # Getting the image of desired window inside generated slide thumnbnail
104
+ # BufferedImage window = image.getSubimage(windowX, windowY, windowsWidth, windowHeight);
105
+ window_image = image.getSubimage(100, 100, 200, 200)
106
+
107
+ # Save the image to disk in JPEG format
108
+ Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
109
+
110
+ puts "Created thumbnail of user defined window, please check the output file."
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,24 @@
1
+ module Asposeslidesjava
2
+ module Transitions
3
+ def initialize()
4
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
5
+
6
+ # Instantiate Presentation class that represents the presentation file
7
+ pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
8
+
9
+ transition_type = Rjb::import('com.aspose.slides.TransitionType')
10
+
11
+ # Apply circle type transition on slide 1
12
+ pres.getSlides().get_Item(0).getSlideShowTransition().setType(transition_type.Circle)
13
+
14
+ # Apply comb type transition on slide 2
15
+ pres.getSlides().get_Item(1).getSlideShowTransition().setType(transition_type.Comb)
16
+
17
+ # Saving the presentation
18
+ save_format = Rjb::import('com.aspose.slides.SaveFormat')
19
+ pres.save(data_dir + "SimpleTransition.pptx", save_format.Pptx)
20
+
21
+ puts "Done with simple transition, please check the output file."
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ module Asposeslidesjava
2
+ module AddSmartArt
3
+ def initialize()
4
+ # Creating a SmartArt Shape
5
+ create_smartart_shape()
6
+ end
7
+
8
+ def create_smartart_shape()
9
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
10
+
11
+ # Create an instance of Presentation class
12
+ pres = Rjb::import('com.aspose.slides.Presentation').new
13
+
14
+ # Get the first slide
15
+ slide = pres.getSlides().get_Item(0)
16
+
17
+ # Add Smart Art Shape
18
+ smart = slide.getShapes().addSmartArt(0, 0, 400, 400, Rjb::import('com.aspose.slides.SmartArtLayoutType').BasicBlockList)
19
+
20
+ # Write the presentation as a PPTX file
21
+ pres.save(data_dir + "SimpleSmartArt.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
22
+
23
+ puts "Created smartart shape, please check the output file."
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ module Asposeslidesjava
2
+ module FillFormat
3
+ def initialize()
4
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
5
+
6
+ # Create an instance of Presentation class
7
+ pres = Rjb::import('com.aspose.slides.Presentation').new
8
+
9
+ # Get the first slide
10
+ slide = pres.getSlides().get_Item(0)
11
+
12
+ # Adding SmartArt shape and nodes
13
+ chevron = slide.getShapes().addSmartArt(10, 10, 800, 60, Rjb::import('com.aspose.slides.SmartArtLayoutType').ClosedChevronProcess)
14
+ node = chevron.getAllNodes().addNode()
15
+ node.getTextFrame().setText("Some text")
16
+
17
+ # Setting node fill color
18
+ item = node.getShapes().get_Item(0)
19
+ item.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
20
+ item.getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
21
+
22
+ # Write the presentation as a PPTX file
23
+ pres.save(data_dir + "FillFormat.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
24
+
25
+ puts "Set fill format for smartart node, please check the output file."
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,34 @@
1
+ module Asposeslidesjava
2
+ module AddImage
3
+ def initialize()
4
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
5
+
6
+ # Create an instance of Presentation class
7
+ pres = Rjb::import('com.aspose.slides.Presentation').new
8
+
9
+ # Get the first slide
10
+ sld = pres.getSlides().get_Item(0)
11
+
12
+ # Define columns with widths and rows with heights
13
+ dbl_cols = [150,150,150,150]
14
+ dbl_rows = [100,100,100,100,90]
15
+
16
+ # Add table shape to slide
17
+ tbl = sld.getShapes().addTable(50, 50, dbl_cols, dbl_rows)
18
+
19
+ # Creating a Buffered Image object to hold the image file
20
+ image = Rjb::import('javax.imageio.ImageIO').read(Rjb::import('java.io.File').new(data_dir + "aspose-logo.jpg"))
21
+ imgx1 = pres.getImages().addImage(image)
22
+
23
+ tbl.get_Item(0,0).getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Picture)
24
+ tbl.get_Item(0,0).getFillFormat().getPictureFillFormat().setPictureFillMode(Rjb::import('com.aspose.slides.PictureFillMode').Stretch)
25
+ tbl.get_Item(0,0).getFillFormat().getPictureFillFormat().getPicture().setImage(imgx1)
26
+
27
+ # Write the presentation as a PPTX file
28
+ save_format = Rjb::import('com.aspose.slides.SaveFormat')
29
+ pres.save(data_dir + "AddImage.pptx", save_format.Pptx)
30
+
31
+ puts "Added image, please check the output file."
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,48 @@
1
+ module Asposeslidesjava
2
+ module AlignText
3
+ def initialize()
4
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
5
+
6
+ # Create an instance of Presentation class
7
+ pres = Rjb::import('com.aspose.slides.Presentation').new
8
+
9
+ # Get the first slide
10
+ slide = pres.getSlides().get_Item(0)
11
+
12
+ # Define columns with widths and rows with heights
13
+ dbl_cols = [120, 120, 120, 120]
14
+ dbl_rows = [100, 100, 100, 100]
15
+
16
+ # Add table shape to slide
17
+ tbl = slide.getShapes().addTable(100, 50, dbl_cols, dbl_rows)
18
+
19
+ # Add text to the merged cell
20
+ tbl.getRows().get_Item(0).get_Item(1).getTextFrame().setText("10")
21
+ tbl.getRows().get_Item(0).get_Item(2).getTextFrame().setText("20")
22
+ tbl.getRows().get_Item(0).get_Item(3).getTextFrame().setText("30")
23
+
24
+ # Accessing the text frame
25
+ txt_frame = tbl.getRows().get_Item(0).get_Item(0).getTextFrame()
26
+
27
+ # Create the Paragraph object for text frame
28
+ para = txt_frame.getParagraphs().get_Item(0)
29
+
30
+ # Create Portion object for paragraph
31
+ portion = para.getPortions().get_Item(0)
32
+ portion.setText("Text here")
33
+ portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
34
+ portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)
35
+
36
+ # Aligning the text vertically
37
+ cell = tbl.getRows().get_Item(0).get_Item(0)
38
+ cell.setTextAnchorType(Rjb::import('com.aspose.slides.TextAnchorType').Center)
39
+ cell.setTextVerticalType(Rjb::import('com.aspose.slides.TextVerticalType').Vertical270)
40
+
41
+ # Write the presentation as a PPTX file
42
+ save_format = Rjb::import('com.aspose.slides.SaveFormat')
43
+ pres.save(data_dir + "AlignText.pptx", save_format.Pptx)
44
+
45
+ puts "Aligned Text, please check the output file."
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,76 @@
1
+ module Asposeslidesjava
2
+ module CloneRowColumn
3
+ def initialize()
4
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
5
+
6
+ # Create an instance of Presentation class
7
+ pres = Rjb::import('com.aspose.slides.Presentation').new
8
+
9
+ # Get the first slide
10
+ sld = pres.getSlides().get_Item(0)
11
+
12
+ # Define columns with widths and rows with heights
13
+ dbl_cols = [50, 50, 50]
14
+ dbl_rows = [50, 30, 30, 30]
15
+
16
+ # Add table shape to slide
17
+ tbl = sld.getShapes().addTable(100, 50, dbl_cols, dbl_rows)
18
+
19
+ fill_type = Rjb::import('com.aspose.slides.FillType')
20
+ color = Rjb::import('java.awt.Color')
21
+
22
+ # Set border format for each cell
23
+ row = 0
24
+ while row < tbl.getRows().size()
25
+ cell = 0
26
+ while cell < tbl.getRows().get_Item(row).size()
27
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(fill_type.Solid)
28
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor().setColor(color.RED)
29
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5)
30
+
31
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().setFillType(fill_type.Solid)
32
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor().setColor(color.RED)
33
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5)
34
+
35
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(fill_type.Solid)
36
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor().setColor(color.RED)
37
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5)
38
+
39
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(fill_type.Solid)
40
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor().setColor(color.RED)
41
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5)
42
+
43
+ cell +=1
44
+ end
45
+ row +=1
46
+ end
47
+
48
+ tbl.getColumns().get_Item(0).get_Item(0).getTextFrame().setText("00")
49
+ tbl.getColumns().get_Item(0).get_Item(1).getTextFrame().setText("01")
50
+ tbl.getColumns().get_Item(0).get_Item(2).getTextFrame().setText("02")
51
+ tbl.getColumns().get_Item(0).get_Item(3).getTextFrame().setText("03")
52
+ tbl.getColumns().get_Item(1).get_Item(0).getTextFrame().setText("10")
53
+ tbl.getColumns().get_Item(2).get_Item(0).getTextFrame().setText("20")
54
+ tbl.getColumns().get_Item(1).get_Item(1).getTextFrame().setText("11")
55
+ tbl.getColumns().get_Item(2).get_Item(1).getTextFrame().setText("21")
56
+
57
+ # AddClone adds a row in the end of the table
58
+ tbl.getRows().addClone(tbl.getRows().get_Item(0) , false)
59
+
60
+ # AddClone adds a column in the end of the table
61
+ tbl.getColumns().addClone(tbl.getColumns().get_Item(0), false)
62
+
63
+ # InsertClone adds a row at specific position in a table
64
+ tbl.getRows().insertClone(2, tbl.getRows().get_Item(0), false)
65
+
66
+ # InsertClone adds a row at specific position in a table
67
+ tbl.getColumns().insertClone(2, tbl.getColumns().get_Item(0), false)
68
+
69
+ # Write the presentation as a PPTX file
70
+ save_format = Rjb::import('com.aspose.slides.SaveFormat')
71
+ pres.save(data_dir + "CloneRowColumn.pptx", save_format.Pptx)
72
+
73
+ puts "Cloned Row & Column from table, please check the output file."
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,61 @@
1
+ module Asposeslidesjava
2
+ module CreateTable
3
+ def initialize()
4
+ data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
5
+
6
+ # Create an instance of Presentation class
7
+ pres = Rjb::import('com.aspose.slides.Presentation').new
8
+
9
+ # Get the first slide
10
+ sld = pres.getSlides().get_Item(0)
11
+
12
+ # Define columns with widths and rows with heights
13
+ dblCols = [50, 50, 50]
14
+ dblRows = [50, 30, 30, 30, 30]
15
+
16
+ # Add table shape to slide
17
+ tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows)
18
+
19
+ fill_type = Rjb::import('com.aspose.slides.FillType')
20
+ color = Rjb::import('java.awt.Color')
21
+
22
+ # Set border format for each cell
23
+ row = 0
24
+ while row < tbl.getRows().size()
25
+ cell = 0
26
+ while cell < tbl.getRows().get_Item(row).size()
27
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(fill_type.Solid)
28
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor().setColor(color.RED)
29
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5)
30
+
31
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().setFillType(fill_type.Solid)
32
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor().setColor(color.RED)
33
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5)
34
+
35
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(fill_type.Solid)
36
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor().setColor(color.RED)
37
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5)
38
+
39
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(fill_type.Solid)
40
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor().setColor(color.RED)
41
+ tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5)
42
+
43
+ cell +=1
44
+ end
45
+ row +=1
46
+ end
47
+
48
+ # Merge cells 1 & 2 of row 1
49
+ tbl.mergeCells(tbl.getRows().get_Item(0).get_Item(0), tbl.getRows().get_Item(1).get_Item(0), false)
50
+
51
+ # Add text to the merged cell
52
+ tbl.getRows().get_Item(0).get_Item(0).getTextFrame().setText("Merged Cells")
53
+
54
+ # Write the presentation as a PPTX file
55
+ save_format = Rjb::import('com.aspose.slides.SaveFormat')
56
+ pres.save(data_dir + "CreateTable.pptx", save_format.Pptx)
57
+
58
+ puts "Created table, please check the output file."
59
+ end
60
+ end
61
+ end