Export reportExport to different file extensions
|
|
|
To view this page ensure that Adobe Flash Player version 10.2.0 or greater is installed.
|
View source code
Source code for the Flexmonster Pivot JS API demo:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FlexMonster Pivot Table & Charts</title>
<link href="css/panels.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>
<body>
<table width="100%">
<tr>
<td style="width:250px;height:65px;border-right:1px dotted #555555;"><div class="header-title">Exporting report</div>
<div class="header-prompt">Choose target format to export</div></td>
<td>
<div class="ViewIconsArea">
<a href="javascript:void(0)" onclick="onBtnClick('print')" id="print"><span>Print</span></a>
<a href="javascript:void(0)" onclick="onBtnClick('html')" id="html"><span>To HTML</span></a> <a href="javascript:void(0)" onclick="onBtnClick('csv')" id="csv"><span>To CSV</span></a>
<a href="javascript:void(0)" onclick="onBtnClick('excel')" id="excel"><span>To Excel</span></a>
<a href="javascript:void(0)" onclick="onBtnClick('image')" id="image"><span>To Image</span></a>
<a href="javascript:void(0)" onclick="onBtnClick('pdf')" id="pdf"><span>To PDF</span></a>
</div>
</td>
</tr>
<tr>
<td colspan="2"><div class="flexmonster-panel">
<div id="title" class="title">Exporting report</div>
<div id="flashContent">
</div>
</div>
</tr>
</table>
<script type="text/javascript" src="flexmonster/flexmonster.js"></script>
<script type="text/javascript">
flexmonster.embedPivotComponent("flexmonster/", "flashContent", "100%", "600", {configUrl: "reports/report.xml"});
function onBtnClick(type)
{
if(type=="print") {
flexmonster.print();
} else if(type=="html") {
var exportOptions = {
htmlTemplateURL: "template/export.html" // path to HTML template
};
flexmonster.exportTo(type, exportOptions);
} else if(type=="csv" || type=="excel" || type=="image" || type=="pdf") {
flexmonster.exportTo(type);
}
}
</script>
</body>
</html>
To view this page ensure that Adobe Flash Player version
10.2.0 or greater is installed.
View source code
Source code for the Flexmonster Pivot Flex API demo:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="706" minHeight="400"
xmlns:pivot="com.flexmonster.pivot.*" xmlns:custom="assets.custom.*">
<fx:Script>
<![CDATA[
import com.flexmonster.pivot.model.export.ExportType;
import com.flexmonster.pivot.vo.ExportOptions;
private function onBtnClick(event:MouseEvent):void
{
var type:String = event.currentTarget.id;
if(type == "print")
{
this.pivot.print();
}
else if(type == ExportType.HTML)
{
var exportOptions:ExportOptions = new ExportOptions();
exportOptions.htmlTemplateURL = "template/export.html";
this.pivot.export(type, exportOptions);
}
else if(ExportType.validType(type))
{
this.pivot.export(type);
}
}
]]>
</fx:Script>
<fx:Style source="assets/css/styles.css"/>
<s:VGroup width="100%" height="100%" gap="0">
<s:HGroup height="70">
<s:VGroup height="100%" paddingTop="10" paddingBottom="10" paddingRight="20">
<s:Label text="Exporting report" styleName="header-text-format"/>
<s:Label text="Choose target format to export" styleName="header-prompt-format"/>
</s:VGroup>
<s:Line height="100%">
<s:stroke>
<s:SolidColorStroke color="0xDCDCDC" weight="1"/>
</s:stroke>
</s:Line>
<s:HGroup paddingTop="10" paddingBottom="10" gap="10">
<custom:ImageButton id="print" click="onBtnClick(event)" text="Print" upImg="@Embed('assets/images/print.png')"/>
<custom:ImageButton id="html" click="onBtnClick(event)" text="To HTML" upImg="@Embed('assets/images/html.png')"/>
<custom:ImageButton id="csv" click="onBtnClick(event)" text="To CSV" upImg="@Embed('assets/images/csv.png')"/>
<custom:ImageButton id="excel" click="onBtnClick(event)" text="To Excel" upImg="@Embed('assets/images/excel.png')"/>
<custom:ImageButton id="image" click="onBtnClick(event)" text="To Image" upImg="@Embed('assets/images/image.png')"/>
<custom:ImageButton id="pdf" click="onBtnClick(event)" text="To PDF" upImg="@Embed('assets/images/pdf.png')"/>
</s:HGroup>
</s:HGroup>
<s:Panel id="panel" title="Exporting report" width="100%" height="100%">
<s:Rect top="0" bottom="1" left="1" right="1" radiusX="5" radiusY="5">
<s:fill>
<s:SolidColor color="#ffffff" />
</s:fill>
</s:Rect>
<pivot:FlexPivotComponent id="pivot" width="100%" height="100%"
configUrl="reports/report.xml"
componentFolder="flexmonster/"/>
</s:Panel>
</s:VGroup>
</s:Application>