问题
So, I have this application where data is sent to me and I have to make it into an Excel sheet. I use Eclipse IDE, I do not have any errors in the code I have written.
But it gives an exception at setBold(bold) method.
Here is the stacktrace
Sep 27, 2017 5:03:03 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/<appName>] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Font.setBold(Z)V] with root cause
java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Font.setBold(Z)V
at <fullpath>.Excel.setCurrentFont(Excel.java:177)
Now, I know that setBold(boolean bold) accepts only Boolean values. I have not made any error wherever in my code. The stacktrace points a Line in Excel.java which is given below...
public void setCurrentFont(String fontName, short fontSize, boolean bold,
boolean italic, short colorIndex, short offset, byte underline) {
Font font = wb.createFont();
font.setFontName(fontName);
font.setBold(bold);
font.setFontHeightInPoints(fontSize);
font.setColor(colorIndex);
font.setItalic(italic);
font.setTypeOffset(offset);
font.setUnderline(underline);
currentFont = font;
}
By the stacktrace, org.apache.poi.ss.usermodel.Font.setBold(Z)V
, I think it is searching for a method setBold(Z)V;
where Z, V are values (my assumption) but setBold(boolean bold);
is the method in that poi?
I have been using
org.apache.poi V 3.12 Eclipse IDE
来源:https://stackoverflow.com/questions/46447105/java-org-apache-poi-ss-usermodel-font-setboldzv-while-trying-to-make-a-excel