Kazi in order to upload excel file you can use simple HTML form that selects file locally and submit HTML form data to your service. In turn the service will have input parameter type (Object) contentStream wich you can read using WM standard service for mime types basic HTTP protocol type operation to turn MIME data into meaningful headers and data stream. Then you can red it in Java as InputStream and write to file. With excel stored localy to IS you can read it with Excel service to convert and map it. No content handler is involved in this process.
But since you started this dicussion on content handlers here is how you would write one if you choose to:
Here is couple of steps to remember in case of your Excel file.
Important to keep in mind that when you use Apache POI to read Excel files the entire file must be read into memeory by POI in order to render the data. Unlike flat file or CVS you cannot read just part of file and get only part of data. This limits to some degree how large a file you can process to your memory resources in IS. Fortunately not many MS Excel are very large.
You can pick any content type name for your handler but I would recomend to use something meaningful like: “application/vnd.ms-excel” wich is vendor specific content - MS Excel.
To register handler you can write 2 Java services:
// Register content handler
ServerAPI.registerContentHandler(“application/vnd.ms-excel”, new ContentHandlerFactory_ExcelFile());
The Handler factory class [ContentHandlerFactory_ExcelFile] I will explain later on.
To unregister handler you can write Java service using simple code like this:
The handler Factory and handler classes you have to write outside WM Developer using JDK or your favorite IDE and use is calsses in package or package it into jar file. Here is ContentHandlerFactory_ExcelFile.java:
public class ContentHandlerFactory_ExcelFile extends ContentHandlerFactory
contentType = “application/vnd.ms-excel”;
public ContentHandlerFactory_ExcelFile(String contenttype)
contentType = contenttype;
public ContentHandler create()
return new ContentHandler_ExcelFile(contentType);
private String contentType;
Now what is left to write actual handler class, in this case ContentHandler_ExcelFile to actually handle your Excel data. I will try to show example in next posting.