I'm building a custom application that generates and stores a layout template using the DocuTemplate apis. This process seems to work fine. I'm able to create and store a template for an excel document. The issue I'm having is on spreadsheet generation. The columns I've defined in the template appear fine but I'm not getting any entity data.
Below is the prototype code I'm using to generate the excel file. What's not clear to me is when/where the data entity is invoked to extract the data. I assume it's during the DocuTemplateRender.renderToStream operation. I feel I may be missing a step or I'm using the wrong APIs. Any thoughts or guidance would be appreciated.
private boolean tryGenerateReport(CustomContract _contract)
{
boolean success = false;
DocuTemplate template = DocuTemplate::findTemplate(OfficeAppApplicationType::Excel, _contract.parmLayoutName() + filename);
if (template)
{
boolean initialFiltersAreValid = true;
container filterContainer;
DocuFileSaveResult saveResult = DocuFileSave::promptForSaveLocation(template.TemplateID, MyConstants::ExcelExtension, "layout", "journal");
Map filtersToApply = new Map(Types::String, Types::Class);
this.prepareForExport(_contract.parmLayoutName());
// Create header filters.
ExportToExcelFilterTreeBuilder filterBuilder = new ExportToExcelFilterTreeBuilder(tablestr(ReportHeaderEntity));
var filter = filterBuilder.and(
filterBuilder.areEqual(fieldStr(ReportHeaderEntity, Company), curExt()),
filterBuilder.areEqual(fieldStr(ReportHeaderEntity, Name), _contract.parmLayoutName()));
filtersToApply.insert(tablestr(ReportHeaderEntity), filter);
if (initialFiltersAreValid)
{
System.IO.MemoryStream templateStream = new System.IO.MemoryStream();;
try
{
DocuTemplateRender renderer = new DocuTemplateRender();
renderer.renderTemplateToStream(template, filtersToApply, templateStream);
templateStream.Seek(0, System.IO.SeekOrigin::Begin);
success = this.processExport(templateStream);
// Pass the workbook to the user.
DocuFileSave::processSaveResult(templateStream, saveResult);
}
finally
{
if (templateStream != null)
{
templateStream.Dispose();
}
}
}
}
return success;
}
private boolean processExport(System.IO.Stream _stream)
{
boolean success;
str upLoadResult = ExportToExcelStorageHelper::uploadExportStream(_stream, OfficeAppApplicationType::Excel);
return success;
}