@OperationMethod
 public Blob run(DocumentModel targetDocument) throws Exception {
   TemplateBasedDocument renderable = targetDocument.getAdapter(TemplateBasedDocument.class);
   if (renderable != null) {
     if (store) {
       return renderable.renderAndStoreAsAttachment(templateName, save);
     } else {
       return renderable.renderWithTemplate(templateName);
     }
   } else {
     BlobHolder bh = targetDocument.getAdapter(BlobHolder.class);
     if (bh != null) {
       return bh.getBlob();
     } else {
       return null;
     }
   }
 }
  @Override
  public Blob renderTemplate(TemplateBasedDocument templateBasedDocument, String templateName)
      throws Exception {

    Blob sourceTemplateBlob = getSourceTemplateBlob(templateBasedDocument, templateName);
    List<TemplateInput> params = templateBasedDocument.getParams(templateName);

    DocumentModel doc = templateBasedDocument.getAdaptedDoc();
    Map<String, Object> ctx = FMContextBuilder.build(doc, false);

    JXLSBindingResolver resolver = new JXLSBindingResolver();

    resolver.resolve(params, ctx, templateBasedDocument);

    File workingDir = getWorkingDir();
    File generated = new File(workingDir, "JXLSresult-" + System.currentTimeMillis());
    generated.createNewFile();

    File input = new File(workingDir, "JXLSInput-" + System.currentTimeMillis());
    input.createNewFile();

    sourceTemplateBlob.transferTo(input);

    XLSTransformer transformer = new XLSTransformer();

    transformer.transformXLS(input.getAbsolutePath(), ctx, generated.getAbsolutePath());

    input.delete();

    Blob newBlob = new FileBlob(generated);

    String templateFileName = sourceTemplateBlob.getFilename();

    // set the output file name
    String targetFileExt = FileUtils.getFileExtension(templateFileName);
    String targetFileName =
        FileUtils.getFileNameNoExt(templateBasedDocument.getAdaptedDoc().getTitle());
    targetFileName = targetFileName + "." + targetFileExt;
    newBlob.setFilename(targetFileName);

    // mark the file for automatic deletion on GC
    Framework.trackFile(generated, newBlob);
    return newBlob;
  }