Tutorials Navigation
Apache POI PPT Tutorial - Classes and Methods
Tutorial Name: Apache POI PPT Tutorial - Classes and Methods
Category: PC Tutorials
Submitted By: hoot
Date Added:
Comments: 0
Views: 1,246
Related Forum: PC Building Forum
Share:
In this chapter, we will learn about a few classes and methods under Apache POI API that are crucial to work on PPT files using Java programs.
Presentation
To create and manage a presentation, you have a class called XMLSlideShow in the package org.apache.poi.xslf.usermodel. Given below are some important methods and a constructor of this class.
Class XMLSlideShow
Package org.apache.poi.xslf.usermodel
S.No.1 - XMLSlideShow(java.io.InputStream inputStream)
You can instantiate this class by passing an inputstream class object to it.
S.No.1
Methods & Description: int addPicture (byte[] pictureData, int format)
Using this method, you can add a picture to a presentation.
S.No.2
Methods & Description: XSLFSlide createSlide()
Creates a blank slide in a presentation.
S.No.3
Methods & Description: XSLFSlide createSlide(XSLFSlideLayout layout)
Creates a slide with a given slide layout.
S.No.4
Methods & Description: java.util.List <XSLFPictureData> getAllPictures()
Returns an array of all the pictures in a presentation.
S.No.5
Methods & Description:java.awt.Dimension getPageSize()
Using this method, you can get to know the current page size.
S.No.6
Methods & Description: XSLFSlideMaster[] getSlideMasters()
Returns the array of all the slides in a presentation.
S.No.7
Methods & Description: XSLFSlide[] getSlides()
Returns all the slides in a presentation.
S.No.8
Methods & Description: XSLFSlide removeSlide(int index)
Using this method, you can remove a slide from a presentation.
S.No.9
Methods & Description: void setPageSize(java.awt.Dimension pgSize)
Using this method, you can reset the page size.
S.No.10
Methods & Description: void setSlideOrder(XSLFSlide slide, int newIndex)
Using this method, you can reorder the slides.
Slide
To create and manage a slide in a presentation, the methods of the XSLFSlide class are used. Some important methods of this class are mentioned below.
Class XSLFSlide
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFBackground getBackground()
Returns the XSLFBackground object which can be used to retrieve details like color and anchor of the background of the slide. You can also draw shapes in the slide using this object.
S.No.2
Methods & Description: XSLFSlideLayout getSlideLayout()
Provides access to the XSLFSlideLayout object of the current slide.
S.No.3
Methods & Description: XSLFSlideMaster getSlideMaster()
Provides access to the slide master of the current slide.
S.No.4
Methods & Description: XSLFTheme getTheme()
Returns the XSLFTheme object of the current slide.
S.No.5
Methods & Description: java.lang.String getTitle()
Returns the title of the current slide.
S.No.6
Methods & Description: XSLFSlide importContent(XSLFSheet src)
Copies the contents of another slide to this slide.
Slide Master
It is the component of the presentation having different slide layouts. The XSLFSlideMaster class gives you access to it. Mentioned below are some important methods of this class.
Class XSLFSlideMaster
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFBackground getBackground()
Returns the common background of the slide master.
S.No.2
Methods & Description: XSLFSlideLayout getLayout(SlideLayout type)
Returns the XSLFSlideLayout object.
S.No.3
Methods & Description: XSLFSlideLayout[] getSlideLayouts()
Returns all the slide layouts in this slide master.
Slide Layout
The POI library has a class called XSLFSlideLayout, using which you can manage the layouts of a slide.
Class XSLFSlideLayout
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: void copyLayout(XSLFSlide slide)
This method will copy the placeholders from this layout to the given slide.
Text Paragraph
You can write content to the slide using XSLFTextParagraph class. Below mentioned are some important methods of this class.
Class XSLFTextParagraph
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFTextRun addLineBreak()
Inserts a line break in a paragraph.
S.No.2
Methods & Description: XSLFTextRun addNewTextRun()
Adds a new run of text in a paragraph.
S.No.3
Methods & Description: void setBulletAutoNumber(ListAutoNumber scheme, int startAt)
Applies automatic numbered bullet points to the paragraph.
S.No.4
Methods & Description: void setIndent(double value)
Sets the indent to the text in the paragraph.
S.No.5
Methods & Description: void setLeftMargin(double value)
This method is used to add the left margin of the paragraph.
S.No.6
Methods & Description: void setLineSpacing(double linespacing)
This method is used to set line spacing in the paragraph.
S.No.7
Methods & Description: void setTextAlign(TextAlign align)
This method is used to set alignment that is to be set to the paragraph.
Text Run
This is the lowest level of text separation within a text body. You have XSLFTextRun class to manage the text run of a paragraph. Below mentioned are some important methods of this class.
Class XSLFTextParagraph
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFHyperlink createHyperlink()
Creates a hyperlink in the presentation.
S.No.2
Methods & Description: XSLFHyperlink getHyperlink()
This method is used to get the hyperlink.
S.No.3
Methods & Description: java.lang.String getText()
Returns the value of this Text node as a Java string.
S.No.4
Methods & Description: void setBold(boolean bold)
This method is used to set the text in Bold.
S.No.5
Methods & Description: void setCharacterSpacing(double spc)
Sets the spacing between characters within a text run.
S.No.6
Methods & Description: void setFontColor(java.awt.Color color)
Sets the font color of the text.
S.No.7
Methods & Description: void setFontSize(double fontSize)
Sets the font size of the text.
S.No.8
Methods & Description: void setItalic(boolean italic)
This method is used to make the paragraph italicized.
S.No.9
Methods & Description: void setStrikethrough(boolean strike)
This method is used to format a run of text as strikethrough text.
S.No.10
Methods & Description: void setSubscript(boolean flag)
This method is used to format the text as subscript.
S.No.11
Methods and Description: void setSuperscript(boolean flag)
This method is used to format the text in this run as superscript.
S.No.12
Methods and Description:void setText(java.lang.String text)
This method is used to set the text in a run.
S.No.13
Methods and Description: void setUnderline(boolean underline)
This method is used to underline the text in a text run.
Text shape
In PPT, we have shapes that can hold text within them. We can manage these using XSLFTextShape class. Mentioned below are some important methods of this class.
Class XSLFTextShape
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: void setPlaceholder(Placeholder placeholder)
Using this method, you can choose a place holder.
S.No.2
Methods & Description: Placeholder getTextType()
Returns the type of the current placeholder.
S.No.3
Methods & Description: void clearText()
Clears the text area of the current text shape.
S.No.4
Methods & Description: XSLFTextParagraph addNewTextParagraph()
Adds a new paragraph run to a shape.
S.No.5
Methods & Description: void drawContent(java.awt.Graphics2D graphics)
This method allows you to draw any content on the slide.
HyperLink
The POI library has a class called XSLFHyperlink using which you can create a hyperlink in the presentation. Mentioned below are some important methods of this class.
Class XSLFHyperlink
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: java.net.URI getTargetURL()
Returns the URL existing in a slide of the presentation.
S.No.2
Methods & Description: void setAddress(java.lang.String address)
This method is used to set address to a URL.
S.No.3
Methods & Description: void setAddress(XSLFSlide slide)
Sets address to the URL present in a slide of the presentation.
Presentation
To create and manage a presentation, you have a class called XMLSlideShow in the package org.apache.poi.xslf.usermodel. Given below are some important methods and a constructor of this class.
Class XMLSlideShow
Package org.apache.poi.xslf.usermodel
S.No.1 - XMLSlideShow(java.io.InputStream inputStream)
You can instantiate this class by passing an inputstream class object to it.
S.No.1
Methods & Description: int addPicture (byte[] pictureData, int format)
Using this method, you can add a picture to a presentation.
S.No.2
Methods & Description: XSLFSlide createSlide()
Creates a blank slide in a presentation.
S.No.3
Methods & Description: XSLFSlide createSlide(XSLFSlideLayout layout)
Creates a slide with a given slide layout.
S.No.4
Methods & Description: java.util.List <XSLFPictureData> getAllPictures()
Returns an array of all the pictures in a presentation.
S.No.5
Methods & Description:java.awt.Dimension getPageSize()
Using this method, you can get to know the current page size.
S.No.6
Methods & Description: XSLFSlideMaster[] getSlideMasters()
Returns the array of all the slides in a presentation.
S.No.7
Methods & Description: XSLFSlide[] getSlides()
Returns all the slides in a presentation.
S.No.8
Methods & Description: XSLFSlide removeSlide(int index)
Using this method, you can remove a slide from a presentation.
S.No.9
Methods & Description: void setPageSize(java.awt.Dimension pgSize)
Using this method, you can reset the page size.
S.No.10
Methods & Description: void setSlideOrder(XSLFSlide slide, int newIndex)
Using this method, you can reorder the slides.
Slide
To create and manage a slide in a presentation, the methods of the XSLFSlide class are used. Some important methods of this class are mentioned below.
Class XSLFSlide
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFBackground getBackground()
Returns the XSLFBackground object which can be used to retrieve details like color and anchor of the background of the slide. You can also draw shapes in the slide using this object.
S.No.2
Methods & Description: XSLFSlideLayout getSlideLayout()
Provides access to the XSLFSlideLayout object of the current slide.
S.No.3
Methods & Description: XSLFSlideMaster getSlideMaster()
Provides access to the slide master of the current slide.
S.No.4
Methods & Description: XSLFTheme getTheme()
Returns the XSLFTheme object of the current slide.
S.No.5
Methods & Description: java.lang.String getTitle()
Returns the title of the current slide.
S.No.6
Methods & Description: XSLFSlide importContent(XSLFSheet src)
Copies the contents of another slide to this slide.
Slide Master
It is the component of the presentation having different slide layouts. The XSLFSlideMaster class gives you access to it. Mentioned below are some important methods of this class.
Class XSLFSlideMaster
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFBackground getBackground()
Returns the common background of the slide master.
S.No.2
Methods & Description: XSLFSlideLayout getLayout(SlideLayout type)
Returns the XSLFSlideLayout object.
S.No.3
Methods & Description: XSLFSlideLayout[] getSlideLayouts()
Returns all the slide layouts in this slide master.
Slide Layout
The POI library has a class called XSLFSlideLayout, using which you can manage the layouts of a slide.
Class XSLFSlideLayout
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: void copyLayout(XSLFSlide slide)
This method will copy the placeholders from this layout to the given slide.
Text Paragraph
You can write content to the slide using XSLFTextParagraph class. Below mentioned are some important methods of this class.
Class XSLFTextParagraph
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFTextRun addLineBreak()
Inserts a line break in a paragraph.
S.No.2
Methods & Description: XSLFTextRun addNewTextRun()
Adds a new run of text in a paragraph.
S.No.3
Methods & Description: void setBulletAutoNumber(ListAutoNumber scheme, int startAt)
Applies automatic numbered bullet points to the paragraph.
S.No.4
Methods & Description: void setIndent(double value)
Sets the indent to the text in the paragraph.
S.No.5
Methods & Description: void setLeftMargin(double value)
This method is used to add the left margin of the paragraph.
S.No.6
Methods & Description: void setLineSpacing(double linespacing)
This method is used to set line spacing in the paragraph.
S.No.7
Methods & Description: void setTextAlign(TextAlign align)
This method is used to set alignment that is to be set to the paragraph.
Text Run
This is the lowest level of text separation within a text body. You have XSLFTextRun class to manage the text run of a paragraph. Below mentioned are some important methods of this class.
Class XSLFTextParagraph
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: XSLFHyperlink createHyperlink()
Creates a hyperlink in the presentation.
S.No.2
Methods & Description: XSLFHyperlink getHyperlink()
This method is used to get the hyperlink.
S.No.3
Methods & Description: java.lang.String getText()
Returns the value of this Text node as a Java string.
S.No.4
Methods & Description: void setBold(boolean bold)
This method is used to set the text in Bold.
S.No.5
Methods & Description: void setCharacterSpacing(double spc)
Sets the spacing between characters within a text run.
S.No.6
Methods & Description: void setFontColor(java.awt.Color color)
Sets the font color of the text.
S.No.7
Methods & Description: void setFontSize(double fontSize)
Sets the font size of the text.
S.No.8
Methods & Description: void setItalic(boolean italic)
This method is used to make the paragraph italicized.
S.No.9
Methods & Description: void setStrikethrough(boolean strike)
This method is used to format a run of text as strikethrough text.
S.No.10
Methods & Description: void setSubscript(boolean flag)
This method is used to format the text as subscript.
S.No.11
Methods and Description: void setSuperscript(boolean flag)
This method is used to format the text in this run as superscript.
S.No.12
Methods and Description:void setText(java.lang.String text)
This method is used to set the text in a run.
S.No.13
Methods and Description: void setUnderline(boolean underline)
This method is used to underline the text in a text run.
Text shape
In PPT, we have shapes that can hold text within them. We can manage these using XSLFTextShape class. Mentioned below are some important methods of this class.
Class XSLFTextShape
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: void setPlaceholder(Placeholder placeholder)
Using this method, you can choose a place holder.
S.No.2
Methods & Description: Placeholder getTextType()
Returns the type of the current placeholder.
S.No.3
Methods & Description: void clearText()
Clears the text area of the current text shape.
S.No.4
Methods & Description: XSLFTextParagraph addNewTextParagraph()
Adds a new paragraph run to a shape.
S.No.5
Methods & Description: void drawContent(java.awt.Graphics2D graphics)
This method allows you to draw any content on the slide.
HyperLink
The POI library has a class called XSLFHyperlink using which you can create a hyperlink in the presentation. Mentioned below are some important methods of this class.
Class XSLFHyperlink
Package org.apache.poi.xslf.usermodel
S.No.1
Methods & Description: java.net.URI getTargetURL()
Returns the URL existing in a slide of the presentation.
S.No.2
Methods & Description: void setAddress(java.lang.String address)
This method is used to set address to a URL.
S.No.3
Methods & Description: void setAddress(XSLFSlide slide)
Sets address to the URL present in a slide of the presentation.
Ratings
Comments
Related Tutorials
- 01. Emulating Xbox 360 on PC for Running COD4 With Mods(3,492)
- 02. How to: Matrix Numbers | Batch File(1,903)
- 03. How to Password Protect Files on Windows(857)
- 04. How to play Socom 2/3/ and Combined Assault on PC(6,716)
- 05. Modern Warfare 2 Vac Ban Bypass Tutorial(6,133)
- 06. How to embed an image on TheTechGame(3,098)
- 07. [PC] NIOH 2 OTHER USER SAVE RESIGN(12,981)
- 08. Host bot lobbies! Full Tutorial!(11,241)
- 09. Unban yourself [Plutonium BO2](14,240)
- 10. Fall Guys - How to Change Your Name Color on Fall Guys(8,385)
- 11. Best Crosshair Settings for Valorant(6,525)
- 12. Othercide The Surgeon Boss Guide(2,539)
- 13. Othercide Remembrances Unlock Guide(4,460)
- 14. Othercide Beginners Tips and Tricks(2,708)
- 15. How to Fix Grounded Crashes, Loading Time, Low FPS and Other(4,845)
"Apache POI PPT Tutorial - Classes and Methods" :: Login/Create an Account :: 0 comments