Question
· Nov 8, 2016

Why my ZEN report displays ok in xml mode but not xlsx excel

I have a following ZEN report:

Class ZENApp.Report Extends %ZEN.Report.reportPage
{

/// Class name of application this report belongs to.
Parameter APPLICATION = "ZENApp.SampleApp";

/// Specifies the default display mode used for this report if
/// the URL parameter, <var>$MODE</var>, is not present.
Parameter DEFAULTMODE As STRING  = "xlsx";

/// This XML defines the logical contents of this report.
XData ReportDefinition [ XMLNamespace = "http://www.intersystems.com/zen/report/definition" ]
{
<report xmlns="http://www.intersystems.com/zen/report/definition"
 name="MyReport"
 sql="SELECT TOP 10 Name,DOB,Age FROM Sample.Person"
 runtimeMode="0">
  <group name="Person">
   <attribute name="name" field="Name"/>
   <attribute name="dob" field="Dob"
    expression="..ToExcelDate(%val)"/>
   <attribute name="age" field="Age"/>
  </group>
</report>
}

/// This XML defines the display for this report.
/// This is used to generate the XSLT stylesheets for both HTML and XSL-FO.
XData ReportDisplay [ XMLNamespace = "http://www.intersystems.com/zen/report/display" ]
{
<report xmlns="http://www.intersystems.com/zen/report/display"
 name="MyReport">
  <body>
   <table group="Person" excelSheetName="Persons"
    excelGroupName="Person" oldSummary="false">
    <item field="@name" excelName="$$$Name" />
    <item field="@dob" isExcelDate="true"
     excelName="$$$Date of Birth" />
    <item field="@age" isExcelNumber="true"
     excelName="$$$Age">
    </item>
   </table>
  </body>
</report>
}

}

If I open it in xml mode in browser via this url:

http://localhost:57772/csp/samples/ZENApp.Report.cls?$MODE=xml

I receive the following output:

<?xml version="1.0"  encoding='UTF-8'?>
<MyReport>
    <Person name='Klein,Agnes E.' dob='31514.0' age='30'/>
    <Person name='Willeke,Imelda R.' dob='12429.0' age='82'/>
    <Person name='Vanzetti,Rhonda Y.' dob='35151.0' age='20'/>
    <Person name='Drabek,Samantha J.' dob='27023.0' age='42'/>
    <Person name='Waterman,Heloisa P.' dob='12195.0' age='83'/>
    <Person name='Koivu,Uma K.' dob='39816.0' age='7'/>
    <Person name='Rotterman,Wilma Z.' dob='34961.0' age='21'/>
    <Person name='Chadbourne,Brian D.' dob='24747.0' age='49'/>
    <Person name='Finn,Bob S.' dob='18627.0' age='65'/>
    <Person name='Adams,Chris Z.' dob='24424.0' age='49'/>
</MyReport>

Yet, when I open it in default xlsx mode, browser starts downloading excel file. It's a valid excel file, but empty.

How do I get my report in xlsx format?

Discussion (2)0
Log in or sign up to continue