Sunday, 26 December 2021

Copy Slides in PowerPoint Documents using Java

In some cases, you want to copy slides in a PowerPoint document to another specified place. You can copy and paste manually, but it is faster and more efficient to use Java codes for automatic operation. This article will show you how to copy slides from the two aspects below using Free Spire.Presentation forJava.

l  Copy slides within one PowerPoint document

l  Copy slides between two PowerPoint documents

DEPENDENCY

First of all, you’re required to download the package of Free Spire.Presentation for Java from the link, and then add Spire.Presentation.jar as a dependency to your Java program. Or if you use Maven, you can directly add the following code to your project’s pom.xml file to import the JAR file.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.presentation.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>

Copy Slides within One PowerPoint Document

Spire.Presentation for Java supports getting a specific slide of a PowerPoint document using Presentation.getSlides().get() method and insert it to the specified position of the document using Presentation.getSlides().insert() method or append it at the end of the document using Presentation.getSlides().append() method. You can follow the steps below.

l  Create a Presentation object and load a sample PowerPoint document using Presentation.loadFromFile() method.

l  Get a list of all slides and choose a specific slide to be copied using Presentation.getSlides().get() method.

l  Insert the desired slide to the specified position of the document using Presentation.getSlides().insert() method.

l  Append the slide at the end of the document using Presentation.getSlides().append() method.

l  Save the document to another file using Presentation.saveToFile() method.

import com.spire.presentation.*;

public class CopySlidesWithinPPT {
public static void main(String[] args) throws Exception {
//Create a Presentation object
Presentation ppt = new Presentation();
//Load a sample PowerPoint document
ppt.loadFromFile("C:\\Users\\Test1\\Desktop\\sample1.pptx");

//Get a list of slides and choose the second slide to be copied
ISlide slide = ppt.getSlides().get(1);

//Insert the desired slide to the specified index in the same presentation
int index = 3;
ppt.getSlides().insert(index, slide);

//Append the slide at the end of the document
ppt.getSlides().append(slide);

//Save the document to another file
String result = "output/CopySlideWithinAPPT.pptx";
ppt.saveToFile(result, FileFormat.PPTX_2013);
}
}



Copy Slides between Two PowerPoint Documents

The following are detailed steps to copy a slide from one PowerPoint document to a specified position or the end of the other document.

l  Create a Presentation object and load one sample document using Presentation.loadFromFile() method.

l  Create another Presentation object and load the other sample document using Presentation.loadFromFile() method.

l  Get a specific slide of document one using Presentation.getSlides().get() method and insert its copy into the specified position of document two using Presentation.getSlides().insert() method.

l  Get another specific slide of document one using Presentation.getSlides().get() method and add its copy to the end of document two using Presentation.getSlides().append() method.

l  Save the document two to another file using Presentation.saveToFile() method.

import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;

public class CopySlidesBetweenPPT {
public static void main(String[] args) throws Exception {
//Create a Presentation object to load one sample document
Presentation pptOne= new Presentation();
pptOne.loadFromFile("C:\\Users\\Test1\\Desktop\\sample1.pptx");

//Create another Presentation object to load another sample document
Presentation pptTwo = new Presentation();
pptTwo.loadFromFile("C:\\Users\\Test1\\Desktop\\sample2.pptx");

//Insert the first slide of sample 1 into the first slide of sample 2
pptTwo.getSlides().insert(0,pptOne.getSlides().get(0));

//Append the last slide of sample 1 to the end of the sample 2
pptTwo.getSlides().append(pptOne.getSlides().get(3));

//Save the sample 2 to another file
pptTwo.saveToFile("output/CopySlidesBetweenPPT.pptx", FileFormat.PPTX_2013);
}
}



Monday, 20 December 2021

Count the Number of Words in Word Documents Using Java

Microsoft Word can count the number of words, pages, paragraphs, lines and characters (with or without spaces) in a Word document. In addition, it can also count the number of words in footnotes and endnotes. This article will show you how to count the number of words and characters (with or without spaces) in a Word document using Java codes.

DEPENDENCY

To programmatically achieve the operation mentioned above using Java, you’re required to download the package of Free Spire.Doc for Java, and then add Spire.Doc.jar to your Java program. If you use Maven, you can easily add the following code to your project’s pom.xml file to import the JAR file.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url> https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>

USING THE CODE

Free Spire.Doc for Java supports counting the number of words, the number of characters with or without spaces using methods provided by the class SummaryDocumentProperties. The following are detailed steps.

l  Create a Document instance.

l  Load a sample Word document using Document.loadFromFile() method.

l  Get the document’s built-in properties using Document.getBuiltinDocumentProperties() method.

l  Count the number of words using SummaryDocumentProperties.getWordCount() method.

l  Count the number of characters with or without spaces using the getChartCount and getChartCount methods provided by the class SummaryDocumentProperties.

l  Output the result.

import com.spire.doc.*;

public class CountWords {
public static void main(String[] args) {
//Create a Document instance
Document document = new Document();

//Load a sample Word document
document.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.docx");

//Count the number of words
System.out.println("WordCount: " + document.getBuiltinDocumentProperties().getWordCount());

//Count the number of characters without spaces
System.out.println("CharCount: " + document.getBuiltinDocumentProperties().getCharCount());

//Count the number of characters with spaces
System.out.println("CharCountWithSpace: " + document.getBuiltinDocumentProperties().getCharCountWithSpace());
}
}



Monday, 13 December 2021

Split a PDF Page into Multiple Pages in Java

Typically, when a page is split into multiple pages, the content of the source page will be displayed on several smaller pages. In this article, you will learn how to split a PDF document into multiple pages horizontally or vertically using Java codes.

DEPENDENCY

To achieve the operation mentioned above, you’re required to download a free third-party library called Free Spire.PDF for Java from the link, and then add Spire.PDF.jar file as a dependency in your Java program. If you use Maven, you can easily add the following code to the pom.xml file to import the JAR file.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.pdf.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>

USING THE CODE

Free Spire.PDF for Java supports splitting a single page into multiple pages horizontally or vertically by using methods provided by PdfDocument class. The following are detailed steps for your reference.

l  Create a PdfDocument instance and load a sample PDF document using PdfDocument.loadFromFile() method.

l  Get a specific page of PDF using PdfDocument.getPages().get() method.

l  Create another PdfDocument instance and set the page margins as 0.

l  Set the page size of the new PDF as half or a fraction of the original page.

l  Add a new page to the new PDF document using PdfDocument.getPages().add() method.

l  Create a PdfTextLayout instance and set the PdfLayoutType as Paginate to make the content paginated automatically.

l  Draw the content of the source page on the new page using PdfPageBase.createTemplate().draw() method.

l  Save the document to another file using PdfDocument.saveToFile() method.

import com.spire.pdf.*;
import com.spire.pdf.graphics.*;
import java.awt.geom.Point2D;

public class SplitPDFPage {
public static void main(String[] args) {
//Create a PdfDocument instance
PdfDocument pdf = new PdfDocument();

//Load the sample PDF document
pdf.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.pdf");

//Get the first page of PDF
PdfPageBase page = pdf.getPages().get(0);

//Create a new PDF document and remove page margins
PdfDocument newPdf = new PdfDocument();
newPdf.getPageSettings().getMargins().setAll(0);

//Horizontally Split
newPdf.getPageSettings().setWidth((float) page.getSize().getWidth());
newPdf.getPageSettings().setHeight((float) page.getSize().getHeight()/2);

////Vertically Split
//newPdf.getPageSettings().setWidth((float) page.getSize().getWidth()/2);
//newPdf.getPageSettings().setHeight((float) page.getSize().getHeight());

// Add a new page to the new PDF document
PdfPageBase newPage = newPdf.getPages().add();

//Set the PdfLayoutType as Paginate to make the content paginated automatically
PdfTextLayout layout = new PdfTextLayout();
layout.setBreak(PdfLayoutBreakType.Fit_Page);
layout.setLayout(PdfLayoutType.Paginate);

//Draw the content of source page in the new page
page.createTemplate().draw(newPage, new Point2D.Float(0, 0), layout);

//Save the document to another file
newPdf.saveToFile("output/SplitPDFPage.pdf");
newPdf.close();

}
}





Wednesday, 8 December 2021

Get the Intersection of Two Cell Ranges in Excel using Java

In the process of manipulating Excel worksheets, we might occasionally have to find the common values between two ranges of cells. In this case, Java codes can be used to automatically find the intersection of certain cell ranges.

DEPENDENCY

To achieve the operation listed above, we need a free third-party library called FreeSpire.XLS for Java to be installed in the Java program. It can be downloaded from the link, or create a Maven project and add the following code to the pom.xml file.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls.free</artifactId>
<version>3.9.1</version>
</dependency>
</dependencies>

USING THE CODE

The following are detailed steps to get the intersection of two cell ranges in an Excel worksheet.

l  Create a Workbook instance and load a sample Excel file using Workbook.loadFromFile() method.

l  Get a specific worksheet of the file using Workbook.getWorksheets().get() method.

l  Specify two cell ranges using Worksheet.getRange().get() method and get their intersection using XlsRange.intersect() method.

l  Create a StringBuilder instance.

l  Loop through the intersection and obtain cell values using CellRange.getValue() method.

l  Append the result to the StringBuilder instance using StringBuilder.append() method.

import com.spire.xls.*;

public class getIntersectionOfTwoRanges {
public static void main(String[] args) {
//Create a Workbook instance
Workbook workbook = new Workbook();

//Load a sample Excel file
workbook.loadFromFile( "C:\\Users\\Test1\\Desktop\\sample.xlsx");

//Get the first worksheet
Worksheet sheet = workbook.getWorksheets().get(0);

//Specify two cell ranges and get their intersection
CellRange range = sheet.getRange().get("B2:F10").intersect(sheet.getRange().get("E3:F8"));

//Create a StringBuilder instance
StringBuilder content = new StringBuilder();
content.append("The intersection of the two ranges \"B2:F10\" and \"E3:F8\" is:"+"\n");

//Loop through the intersection and obtain the values of cells
for(CellRange r : range.getCellList())
{
content.append(r.getValue()+"\n");
}

//Output the result
System.out.println(content);
}
}
The input Excel:

The output result:





Monday, 6 December 2021

Add Superscript and Subscript to PowerPoint in Java

Frequently, superscript and subscript are used when making lesson plans for math and chemistry in PowerPoint. A superscript refers to text that is slightly higher than other text on the same line, while a subscript indicates text that is slightly lower than other text on the same line. This article will introduce how to add superscript and subscript to a PowerPoint slide using Java codes.

DEPENDENCY

In this tutorial, we’ll use a free third-party library called Free Spire.Presentation for Java. First of all, we need to download the product package from the link, and manually add the Spire.Presentation.jar file as a dependency in the Java program. Or we can create a Maven project and add the following code to the pom.xml file.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.presentation.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>

USING THE CODE

Free Spire.Presentation for Java provides the PortionEx.getFormat().setScriptDistance(float value) method for applying superscript or subscript formatting to text. The value can be set as positive or negative. The bigger the positive value are, the higher the superscript will appear above your text. The smaller the negative value are, the lower the subscript will appear below your text.

The following are the steps to achieve the operations:

l  Create a Presentation instance and load a sample PowerPoint document using Presentation.loadFromFile() method.

l  Get a specific slide of the file using Presentation.getSlides().get() method.

l  Add a shape to the slide using ISlide.getShapes().appendShape() method and set shape fill type and line color.

l  Access the text frame of the shape using IAutoShape.getTextFrame() method, then clear the default paragraph in the text frame using ITextFrameProperties.getParagraphs().clear() method.

l  Create a paragraph using ParagraphEx class, and add normal text to the paragraph using ParagraphEx.setText() method.

l  Create a portion with text using PortionEx class, and then apply superscript or subscript formatting to the text using PortionEx.getFormat().setScriptDistance(float value) method.

l  Set text color, font and font size for the normal text and the superscript or subscript text.

l  Append the paragraph to the text frame of the shape using ITextFrameProperties.getParagraphs().append() method.

l  Save the document to another file using Presentation.saveToFile() method.

import com.spire.presentation.*;
import com.spire.presentation.drawing.*;
import java.awt.*;

public class AddSuperscriptAndSubscript {
public static void main(String[] args) throws Exception {
//Load a PowerPoint document
Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.pptx");

//Get the first slide
ISlide slide = presentation.getSlides().get(0);

//Add a shape to the slide
IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, new Rectangle(200, 200, 400, 150));
shape.getFill().setFillType(FillFormatType.NONE);
shape.getShapeStyle().getLineColor().setColor(Color.white);

//Access the text frame of the shape
ITextFrameProperties textFrame = shape.getTextFrame();
//Clear the default paragraph in the text frame
textFrame.getParagraphs().clear();

//Create a paragraph with normal text
ParagraphEx para = new ParagraphEx();
para.setText("E=mc");

//Create a portion with superscript text
PortionEx tr = new PortionEx("2");
tr.getFormat().setScriptDistance(40);

//Append the portion to the paragraph
para.getTextRanges().append(tr);

para.getTextRanges().append(new PortionEx("\n"));

//Set text color, font and font size for the normal text
tr = para.getTextRanges().get(0);
tr.getFill().setFillType(FillFormatType.SOLID);
tr.getFill().getSolidColor().setColor(new Color(128,0,128));
tr.setFontHeight(20);
tr.setLatinFont(new TextFont("Arial"));

//Set text color and font for the superscript text
tr = para.getTextRanges().get(1);
tr.getFill().setFillType(FillFormatType.SOLID);
tr.getFill().getSolidColor().setColor(Color.BLUE);
tr.setLatinFont(new TextFont("Arial"));

//Append the paragraph to the text frame of the shape
textFrame.getParagraphs().append(para);

//Create another paragraph with normal text
para = new ParagraphEx();
para.setText("X");

//Create a portion with subscript text
tr = new PortionEx("100");
tr.getFormat().setScriptDistance(-25);

//Append the portion to the paragraph
para.getTextRanges().append(tr);

//Set text color, font and font size for the normal text
tr = para.getTextRanges().get(0);
tr.getFill().setFillType(FillFormatType.SOLID);
tr.getFill().getSolidColor().setColor(new Color(128,0,128));
tr.setFontHeight(20);
tr.setLatinFont(new TextFont("Arial"));

//Set text color and font for the subscript text
tr = para.getTextRanges().get(1);
tr.getFill().setFillType(FillFormatType.SOLID);
tr.getFill().getSolidColor().setColor(Color.BLUE);
tr.setLatinFont(new TextFont("Arial"));

//Append the paragraph to the text frame of the shape
textFrame.getParagraphs().append(para);

//Save the result document
presentation.saveToFile("output/AddSuperscriptAndSubscript.pptx", FileFormat.PPTX_2013);
}
}


Thursday, 2 December 2021

Set Paragraph Indents for Word Documents in Java

In Word, Paragraph Indents mainly consist of Left Indent, Right Indent, First Line Indent and Hanging Indent. The Left Indent and the Right Indent control the left and right sides of the entire paragraph respectively, the First Line Indent controls the first line of the paragraph and the Hanging Indent controls the rest of the paragraph except for the first line. This article will show you how to set the four different types of Paragraph Indents for a Word document using Java codes.

DEPENDENCY

First of all, you need to download the product package of Free Spire.Doc for Java from the link, and manually add the Spire.Doc.jar file as a dependency in the Java program. If you use Maven, you can easily import the JAR file in your application by adding the following code to the pom.xml file.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>

USING THE CODE

Free Spire.Doc for Java supports setting four different types of Paragraph Indents for a Word document using methods provided by the ParagraphFormat class. Below you can see the corresponding steps used to carry out the operations.

l  Create a Document instance and load a sample Word document using Document.loadFromFile() method.

l  Get a specific section of the file using Document.getSections.get() method and find the desired paragraph using Section.getParagraphs.get() method.

l  Get the paragraph format using Paragraph.getFormat() method.

l  Call the methods provided by the ParagraphFormat class to set paragraph indents.

l  Save the document using Document.saveToFile() method.

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.Section;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.formatting.ParagraphFormat;

public class ParagraphIndents {
public static void main(String[] args) {
//Create a Document instance
Document document= new Document();
//Load a sample Word document
document.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.docx");

//Get the first section
Section section = document.getSections().get(0);

//Get the second paragraph and set left indent
Paragraph para = section.getParagraphs().get(1);
ParagraphFormat format = para.getFormat();
format.setLeftIndent(30);

//Get the paragraph and set right indent
para = section.getParagraphs().get(2);
format = para.getFormat();
format.setRightIndent(30);

//Get the paragraph and set first line indent
para = section.getParagraphs().get(3);
format = para.getFormat();
format.setFirstLineIndent(30);

//Get the fifth paragraph and set hanging indent
para = section.getParagraphs().get(4);
format = para.getFormat();
format.setFirstLineIndent(-30);

//Save the document to another file
document.saveToFile("output/SetParagraphIndents.docx", FileFormat.Docx_2013);
}
}


Monday, 29 November 2021

Convert PDF to Image with Transparent Background

In a previous article, I introduced how to use the PdfDocument.saveAsImage() method provided by Free Spire.PDF for Java to convert each page of a PDF document to a normal image. This tutorial will demonstrate how to set the background transparency of the image converted from PDF using Spire.PDF for Java.

Install Spire.PDF for Java

First of all, you need to download the product package from the link, and then manually add the Spire.Pdf.jar file as a dependency in the Java program. Or you can create a Maven project in the Java application, and add the following code to the pom.xml file. 

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.pdf</artifactId>
<version>4.11.1</version>
</dependency>
</dependencies>

Using the code

Spire.PDF for Java provides PdfDocument.getConvertOptions().setPdfToImageOptions() method to set the transparent value of the resulted image’s background. The following are detailed steps for your reference.

l  Create a PdfDocument instance.

l  Load a sample PDF document using PdfDocument.loadFromFile() method.

l  Set the background transparent value of the image converted from PDF using PdfDocument.getConvertOptions().setPdfToImageOptions() method.

l  Save the document to another file using PdfDocument.saveAsImage() method.

import com.spire.pdf.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class PdfToImage {
public static void main(String[] args) throws IOException {
//Create a PdfDocument instance
PdfDocument pdf = new PdfDocument();

//Load a sample PDF document
pdf.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.pdf");

//Set the background transparent value as 0
pdf.getConvertOptions().setPdfToImageOptions(0);

//Save the document to a .png image
BufferedImage image = pdf.saveAsImage(0);
File file = new File( String.format("output/ToImage.png"));
ImageIO.write(image, "PNG", file);
}
}



Thursday, 25 November 2021

Java: Convert Excel to CSV and Vice Versa

A CSV (Comma Separated Values) file is a plain text file that contains only text and numbers and you can create and edit it in Excel. Rather than storing information in columns, A CSV file stores information separated by commas. This article will show you how to convert Excel to CSV and convert CSV to Excel using Java codes.

DEPENDENCY

In this code sample, we’ll use a third-party library called Spire.XLS for Java. First of all, we can get the product package from the link, and add the Spire.Xls.jar file as a dependency in the Java program. Or create a Maven project and then add the following code to the pom.xml file to add the JAR file to the Java application.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls </artifactId>
<version>4.11.3</version>
</dependency>
</dependencies>

Convert Excel to CSV

Spire.XLS for Java supports converting Excel to CSV with only several lines of codes. Here are steps to follow.

l  Create a Workbook instance.

l  Load a sample Excel document using Workbook.loadFromFile() method.

l  Get a specific worksheet of the document using Workbook.getWorksheets().get() method.

l  Save the worksheet to CSV using Worksheet.saveToFile() method.

import com.spire.xls.*;
import java.nio.charset.Charset;

public class ExcelToCSV {
public static void main(String[] args) {

//Create a workbook
Workbook workbook = new Workbook();

//Load a sample excel file
workbook.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.xlsx");

//Get the first sheet
Worksheet sheet = workbook.getWorksheets().get(0);

//Save the document to CSV
sheet.saveToFile("output/ToCSV_out.csv", ",", Charset.forName("UTF-8"));
}
}

Convert CSV to Excel

In addition to converting Excel to CSV, Free Spire.XLS for Java also supports converting CSV to Excel by using Workbook.saveToFile() method. In this process, we can set ignore error options when setting numbers in cells as text and can adjust the height of rows and width of columns too. The following are detailed steps for your reference.

l  Create a Workbook instance and load a sample CSV file using Workbook.loadFromFile() method.

l  Get a specific worksheet using Workbook.getWorksheets().get() method.

l  Specify the cell range using Worksheet.getCellRange() method and ignore errors when setting numbers in the cells as text using CellRange.setIgnoreErrorOptions(java.util.EnumSet<IgnoreErrorType> ignoreErrorOptions) method.

l  Automatically adjust the height of rows and width of columns using methods provided by CellRange class.

l  Save the document to an XLSX file using Workbook.saveToFile() method.

import com.spire.xls.*;
import java.util.EnumSet;

public class CSVToExcel {
public static void main(String[] args) {
//Create a workbook
Workbook workbook = new Workbook();
//Load a sample CSV file
workbook.loadFromFile("C:\\Users\\Test1\\Desktop\\test.csv", ",", 1, 1);

//Get the first worksheet
Worksheet sheet = workbook.getWorksheets().get(0);

//Specify the cell range and ignore errors when setting numbers in the cells as text
sheet.getCellRange("A1:D6").setIgnoreErrorOptions(EnumSet.of(IgnoreErrorType.NumberAsText));

//Automatically adjust the height of the rows and width of the columns
sheet.getAllocatedRange().autoFitColumns();
sheet.getAllocatedRange().autoFitRows();

//Save the document to Xlsx
workbook.saveToFile("output/CSVToExcel_out.xlsx", ExcelVersion.Version2013);
}
}



Change PDF Versions in Java

In daily work, you might need to change the version of a PDF document you have in order to ensure compatibility with another version which a...