search
HomeJavajavaTutorialHow to get the row and column coordinates of the picture in Excel in Java

Program environment:

Follow the following method to reference Spire.Xls.jar Version: 5.1.0

Method 1: Free Download the Spire.XLS for Java package locally, unzip it, and find the Spire.Xls.jar file in the lib folder. Then open the "Project Structure" interface in IDEA, and then perform the steps as shown to manually import the jar file in the local path:

How to get the row and column coordinates of the picture in Excel in Java

Method 2: Through the Maven repository Download and import, configure pom.xml as follows:

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.cn/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls.free</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>

Get the row and column position of the image

The following are the detailed steps:

  • Create an object of class Workbook.

  • Call the Workbook.loadFromFile(String fileName) method to load the Excel file.

  • Get the specified worksheet through the Workbook.getWorksheets().get(int Index) method.

  • Get the specified picture through the Worksheet.getPictures().get(int Index) method.

  • Get the row and column position of the picture through the ExcelPicture.getTopRow() method and the ExcelPicture.getLeftColumn() method.

  • Finally, print the obtained results.

The following is the completed code for reference:

Java

import com.spire.xls.*;

public class GetImageLocation {
public static void main(String[] args) {
//加载测试文档
Workbook wb = new Workbook();
wb.loadFromFile("sample.xlsx");

//获取第2个工作表
Worksheet sheet = wb.getWorksheets().get(1);

//获取工作表中的第一张图片
ExcelPicture picture = sheet.getPictures().get(0);

//获取图片所在行、列
int row = picture.getTopRow();
int column = picture.getLeftColumn();

//输出获取结果
System.out.println("location is :(" + row + "," + column + ")");
}
}

Read The result is as shown in the figure. The picture is located in the eighth row and fourth column:

How to get the row and column coordinates of the picture in Excel in Java

The above is the detailed content of How to get the row and column coordinates of the picture in Excel in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment