Generate HTML flat-table report (PivotData microservice sample)

How to generate HTML flat-table report with PivotData microservice API.

HTML

<a href="https://www.nrecosite.com/pivotdata_service.aspx">PivotData microservice</a> web API usage demo
<br/><br/>
<button id="exportToPdf" onclick="$('#exportToPdfForm').submit()" style="margin-bottom:10px;">
Export to PDF
</button>

<!-- Sample code that renders HTML flat-table (tabular report) with PivotData microservice web API -->
<div id="pivotTablePlaceholder">
  
</div>
<br/>


<!-- use form to download export as file -->
<form id="exportToPdfForm" method="POST" action="https://pivotdataservice.nrecosite.com/pivotdataservice/api/cube/7f74de2546804cf9b12da34d7e5af382/table/export/pdf" target="_blank">
 <input type="hidden" name="tableReportJson" value=""/>
 <input type="hidden" name="__JwtAuthorization" value=""/>
</form>

CSS

table {
				border-collapse: collapse;
				width:100%;
				font-family:Arial;
				font-size:10px;
				margin:0px;
				padding:0px;
			} 
			td,th {
				border:1px solid silver;padding:2px;
			}
			td {
				text-align:left;
			}
			th {
				text-align:left;
			}

JavaScript

var jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6WyJkZW1vQHNlZWt0YWJsZS5jb20iLCJkZW1vQHNlZWt0YWJsZS5jb20iXSwibmFtZWlkIjpbIjEiLCIxIl0sInVuaXF1ZV9uYW1lIjpbIlNlZWtUYWJsZSBEZW1vIiwiU2Vla1RhYmxlIERlbW8iXSwicmVhZG9ubHkiOlsiVHJ1ZSIsIlRydWUiXSwibmJmIjoxNTM4NTczMTI2LCJleHAiOjE4ODQxNzMxMjYsImlhdCI6MTUzODU3MzEyNiwiaXNzIjoiU1QifQ.LlMWzVC0E0gcLCn6Wb9gw03y4IealqLRKPnCiZm-kr8";
$.ajaxSetup({
	headers: {'Authorization': "Bearer " + jwt}
});
 
 var reportCfg = {
   "Rows": [ {"Name":"Region"} ],
   "Columns": [ {"Name":"Order Date"}, {"Name":"Region"}, {"Name":"Product Name"}, {"Name":"Order Quantity"}, {"Name":"Unit Price"} ],
   "OrderBy": [
   	{"Name": "Order Date", "Direction":"Descending"}
   ],
   "OffsetRows": 0,
   "LimitRows": 50
 };
 
$.ajax("https://pivotdataservice.nrecosite.com/pivotdataservice/api/cube/7f74de2546804cf9b12da34d7e5af382/table/export/html", {
  type: "POST",
	data: {
	 "tableReportJson": JSON.stringify(reportCfg)
	}
}).done(function(res) {
  $('#pivotTablePlaceholder').html(res);
});

// set export form values
$('input[name="tableReportJson"]').val(JSON.stringify(reportCfg));
$('input[name="__JwtAuthorization"]').val(jwt);