In Crosstab report, I’m facing an issue where I’m able to download an Excel file, but the changes I made to the file through code aren’t showing up in the downloaded version.
In page render, I’m changing the field caption using the below code,
// Page Render event
function Page_Render()
{
if (isset($_GET['x_PLAN_FY']))
$_SESSION['fy_ctb'] = $_GET['x_PLAN_FY'];
else
$_SESSION['fy_ctb'] = NULL;
if (isset($_GET['x_PLAN_TYPE']))
$_SESSION['plan_type'] = $_GET['x_PLAN_TYPE'];
else
$_SESSION['plan_type'] = NULL;
if (isset($_GET['x_ORDERNO'])){
$_SESSION['orderno_ctb'] = $_GET['x_ORDERNO'];
$_SESSION['orderno_ctb'] = str_replace('|', ',', $_SESSION['orderno_ctb']);
}
else
$_SESSION['orderno_ctb'] = NULL;
$fy_start = substr($_SESSION['fy_ctb'], 2, 2);
$fy_end = substr($_SESSION['fy_ctb'], -2);
if (isset($_GET['x_ORDERNO'])){
$order_nos = $_SESSION['orderno_ctb'];
$plan_type = $_SESSION['plan_type'];
$order_numbers = explode(',', $order_nos);
foreach ($order_numbers as $order_no) {
$order_no = trim($order_no);
$plan_year = ExecuteScalar("SELECT DISTINCT PLAN_YEAR FROM sc_team_wise_occupancy_actual_res_view WHERE ORDERNO = $order_no AND PLAN_TYPE = '$plan_type'");
$plan_year = substr($plan_year, 2, 2);
$plan_month = ExecuteScalar("SELECT DISTINCT PLAN_MONTH FROM sc_team_wise_occupancy_actual_res_view WHERE ORDERNO = $order_no AND PLAN_TYPE = '$plan_type'");
$months = ["January", "February", "March","April", "May", "June", "July", "August", "September", "October", "November", "December"];
$monthIndex = $plan_month - 1;
$month = $months[$monthIndex];
$month = substr($month, 0, 3);
for($i = 1; $i <= $this->ColumnCount; $i++) {
$Column = $this->Columns[$i];
if ($Column->Caption != "") {
if ($Column->Caption == $order_no)
$Column->Caption = $month."-".$plan_year;
}
}
}
}
if (isset($_GET['x_PLAN_FY'])){
for($i = 1; $i <= $this->ColumnCount; $i++) {
$Column = $this->Columns[$i];
if ($Column->Caption != "") {
$months = [
"1" => "Apr",
"2" => "May",
"3" => "Jun",
"4" => "Jul",
"5" => "Aug",
"6" => "Sep",
"7" => "Oct",
"8" => "Nov",
"9" => "Dec",
"10" => "Jan",
"11" => "Feb",
"12" => "Mar"
];
$monthIndex = $Column->Caption % 12;
if ($monthIndex == 0) {
$monthIndex = 12;
}
if ($monthIndex == 10 || $monthIndex == 11 || $monthIndex == 12) {
$Column->Caption = $months["$monthIndex"] . "-" . $fy_end;
} else {
$Column->Caption = $months["$monthIndex"] . "-" . $fy_start;
}
}
}
}
}
this changed captions not coming in excel while downloading.