Converting Excel to Image in Java Application

NateBennett
2 min readJul 1, 2020

--

In daily work, it’s inevitably that we will need to convert the format of the document to meet the needs of different work occasions. Today I’m going to demonstrate how to convert Excel to Image by using Free Spire.XLS for Java.

Installation

Method 1: Download the Free Spire.XLS for Java and unzip it. Then add the Spire.Xls.jar file to your project as dependency.

Method 2: You can also add the jar dependency to maven project by adding

the following configurations to the pom.xml.

<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.free</artifactId>      <version>2.2.0</version>   </dependency></dependencies>

The input Excel file we used for demonstration:

Convert Excel to Image:

import com.spire.xls.*;
import java.io.*;

public class ExcelToImg {
public static void main(String[] args) throws IOException {
//Create a workbook instance
Workbook workbook = new Workbook();
//Load the Excel file
workbook.loadFromFile("file1.xlsx");

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

//Save the sheet to image
sheet.saveToImage("image.png");
}
}

The output image file:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

NateBennett
NateBennett

Written by NateBennett

Sharing code to help developers deal with office files

No responses yet

Write a response