Answer the question
In order to leave comments, you need to log in
Why is the sheet not being created in Excel (apach poi)?
Good evening.
I try Apache Poi, the file can be created, but the sheets are not in any.
Here is a link to the docks I use (the new sheet section is almost at the very top)
https://poi.apache.org/components/spreadsheet/quic...
Here is my code:
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class Main {
public static void main(String[] args) {
Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
Sheet sheet = wb.createSheet("fhgfgh");
OutputStream file = null;
try {
file = new FileOutputStream("111.xls");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
wb.write(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/math3/util/ArithmeticUtils
at org.apache.poi.poifs.property.RootProperty.setSize(RootProperty.java:59)
at org.apache.poi .poifs.property.DirectoryProperty.(DirectoryProperty.java:52)
at org.apache.poi.poifs.property.RootProperty.(RootProperty.java:31)
at org.apache.poi.poifs.property.PropertyTable.(PropertyTable. java:58)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.(POIFSFileSystem.java:99)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.(POIFSFileSystem.java:121)
at org.apache.poi .hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1357)
at Main.main(Main.java:22)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.util.ArithmeticUtils
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal. loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 8 more
Answer the question
In order to leave comments, you need to log in
It looks like the problem is that the org.apache.commons package is missing, which the apache.poi library needs. Master
maven - the problem will be solved by itself
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/math3/util/ArithmeticUtils
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question