Hello,
I tried to make the Java Class work with the xlsx format.
Bellow the begging of code:
package spreedSheet;
import com.wm.data.*;
import com.wm.util.Values;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public final class isValidDate_SVC
{
public static final void isValidDate(IData pipeline) throws ServiceException {
IDataCursor pipelineCursor = pipeline.getCursor();
String fileName = IDataUtil.getString(pipelineCursor, "file_name");
convertExcelToCSV(fileName);
pipelineCursor.destroy();
}
// --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---
public static void convertExcelToCSV(String fileName) {
File inputFile = new File(fileName);
File outputFile = new File(fileName.substring(0, fileName.lastIndexOf(".")) + ".csv");
StringBuffer data = new StringBuffer();
try {
FileInputStream fis = new FileInputStream(inputFile);
if (inputFile.getName().endsWith(".xlsx")) {
workbook = new XSSFWorkbook(fis);//PROBLEMATIC LINE
} else {
fis.close();
throw new Exception("File not supported!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
I did a local project in IntelliJ and it worked. I added all JARs to the:
path: \code\jars inside the package where I have class.
Eroor:
java.lang.reflect.InvocationTargetException: Could not initialize class org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocumen
IS version: 10.15
Java version: 11
Of course, I reload the package after adding the jars.
Any idea?
#Integration-Server-and-ESB#webMethods#Flow-and-Java-services