Class Stringifier
java.lang.Object
pro.verron.officestamper.test.Stringifier
- Since:
- 1.6.5
- Version:
- ${version}
- Author:
- Joseph Verron
-
Constructor Summary
ConstructorsConstructorDescriptionStringifier
(Supplier<org.docx4j.openpackaging.packages.WordprocessingMLPackage> documentSupplier) -
Method Summary
Modifier and TypeMethodDescriptionConverts the given object into its string representation based on its type.static String
stringifyExcel
(org.docx4j.openpackaging.packages.SpreadsheetMLPackage presentation) Converts the content of a SpreadsheetMLPackage into a string by extracting and formatting cell data from the Excel file.static String
stringifyPowerpoint
(org.docx4j.openpackaging.packages.PresentationMLPackage presentation) Converts the content of a PowerPoint presentation into a string by extracting text paragraphs from the presentation and formatting them as strings.
-
Constructor Details
-
Stringifier
public Stringifier(Supplier<org.docx4j.openpackaging.packages.WordprocessingMLPackage> documentSupplier) - Since:
- 1.6.6
-
-
Method Details
-
stringifyPowerpoint
public static String stringifyPowerpoint(org.docx4j.openpackaging.packages.PresentationMLPackage presentation) Converts the content of a PowerPoint presentation into a string by extracting text paragraphs from the presentation and formatting them as strings.- Parameters:
presentation
- the PowerPoint presentation represented as aPresentationMLPackage
.- Returns:
- a string representation of the text content within the PowerPoint presentation.
-
stringifyExcel
public static String stringifyExcel(org.docx4j.openpackaging.packages.SpreadsheetMLPackage presentation) Converts the content of a SpreadsheetMLPackage into a string by extracting and formatting cell data from the Excel file.- Parameters:
presentation
- the Excel file represented as aSpreadsheetMLPackage
- Returns:
- a string representation of the cell content within the Excel spreadsheet
-
stringify
Converts the given object into its string representation based on its type. The method supports various object types and applies the appropriate logic to stringify the content. For unsupported object types, an exception is thrown.- Parameters:
o
- the object to be converted into a string representation. It supports specific types including JAXBElement, WordprocessingMLPackage, Tbl, Tr, Tc, MainDocumentPart, Body, List, Text, P, R, Drawing, Inline, Graphic, and other types defined in the method. Passing null or unsupported types will result in an exception.- Returns:
- the string representation of the provided object.
For some specific types like
R.LastRenderedPageBreak
orCTMarkupRange
, an empty string may be returned. For objects likeR.Tab
orR.Cr
, specific strings such as tab or carriage return characters may be returned. In case of unsupported types or null, an exception is thrown.
-