Created
April 5, 2016 17:24
-
-
Save paul-xor/261d9357b88e84e3e781a1793055b930 to your computer and use it in GitHub Desktop.
Error. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package ua.cons; | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.FilenameFilter; | |
import java.io.IOException; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | |
import org.apache.poi.openxml4j.opc.OPCPackage; | |
import org.apache.poi.ss.usermodel.Workbook; | |
import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |
/** | |
* | |
* @author smolov | |
*/ | |
public class Jcons { | |
private final String temp; | |
private final String path; | |
public Jcons(String temp, String path) { | |
this.temp = temp; | |
this.path = path; | |
} | |
public void Iocon(){ | |
File directory = new File(path); | |
File[] items; | |
FilenameFilter filter = (File dir, String name) -> { | |
if(name.lastIndexOf('.')>0) | |
{ | |
// get last index for '.' char | |
int lastIndex = name.lastIndexOf('.'); | |
// get extension | |
String str = name.substring(lastIndex); | |
// match path name extension | |
if(str.equals(".xlsm")) | |
{ | |
return true; | |
} | |
} | |
return false; | |
}; | |
items = directory.listFiles(filter); | |
if(items==null){ | |
System.out.println("ERRROR: No files in the folder"); | |
} | |
for(File item:items){ | |
if(item.isFile()){ | |
//System.out.println(item.getName() + "; " + item.getPath()); | |
try (Workbook wbSrc = new XSSFWorkbook(OPCPackage.open(item.getPath()))) { | |
// todo ... | |
wbSrc.createSheet("New Sheet"); | |
FileOutputStream fos = new FileOutputStream("x:\\tmp\\new_edited.xlsm"); | |
wbSrc.write(fos); | |
fos.close(); | |
} catch (IOException | InvalidFormatException ex) { | |
//Logger.getLogger(Jcons.class.getName()).log(Level.SEVERE, null, ex); | |
} | |
} | |
} | |
} | |
} |
RESOLVED:
- xlmbeans-2.6.0.jar to Libraries and everything running smoothly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
C:\Users\smolov\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)`