Comments (5)
from php_xlsxwriter.
<?php
include_once("xlsxwriter.class.php");
ini_set('display_errors', 1);
ini_set('log_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);
$filename = "example.xlsx";
header('Content-disposition: attachment; filename="' . XLSXWriter::sanitize_filename($filename) . '"');
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
ob_clean();
flush();
$start = isset($_GET['startdate']) ? $_GET['startdate'] : '';
$end = isset($_GET['enddate']) ? $_GET['enddate'] : '';
$campaign_id = isset($_GET['campaign_id']) ? $_GET['campaign_id'] : '';
$campaign_id_lead_list = isset($_GET['campaign_id_lead_list']) ? $_GET['campaign_id_lead_list'] : '';
$campaign_id_selected = isset($_GET['campaign_id_selected']) ? $_GET['campaign_id_selected'] : '';
$campaign_id_selected_lead_list = isset($_GET['campaign_id_selected_lead_list']) ? $_GET['campaign_id_selected_lead_list'] : '';
$status_selected_list = isset($_GET['status_selected_list']) ? $_GET['status_selected_list'] : '';
//echo $start . "+" . $end . "+" . $campaign_id_selected_lead_list;
// $tmp = json_decode($_POST['data'], true);
// $root = "temp/";
// $start = $tmp["startdate"];
// $end = $tmp["enddate"];
// $campaign_id = $tmp["campaign_id"];
// $campaign_id_lead_list = $tmp["campaign_id_lead_list"];
// $campaign_id_selected = $tmp["campaign_id_selected"];
// $campaign_id_selected_lead_list = $tmp["campaign_id_selected_lead_list"];
$start_dd = substr($start, 0, 2); // 16/03/2016
$start_mm = substr($start, 3, 2);
$start_yy = substr($start, 6, 4);
$startdate = $start_yy . $start_mm . $start_dd;
$startdate2 = $start_yy . '-' . $start_mm . '-' . $start_dd;
$startdatelead = $start_yy . $start_mm;
$end_dd = substr($end, 0, 2); // 16/03/2016
$end_mm = substr($end, 3, 2);
$end_yy = substr($end, 6, 4);
$enddate = $end_yy . $end_mm . $end_dd;
$enddate2 = $end_yy . '-' . $end_mm . '-' . $end_dd;
$enddatelead = $end_yy . $end_mm;
//$currentdatetime = date("Y") . '-' . date("m") . '-' . date("d") . ' ' . date("H:i:s");
$report_date = $startdate2 . ' - ' . $enddate2;
// $campaign_name_header = "";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($rLeadName = mysqli_fetch_assoc($resultLeadName)) {
$rowLDN[] = [
$rLeadName['list_name']
];
}
while ($rStatusName = mysqli_fetch_assoc($resultStatusName)) {
$rowSTSN[] = [
$rStatusName['status']
];
}
$currentDate = date("Y-m-d");
$headerReportName = array(
'ReportStatusCustomer' => '@', //text
'REASON' => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
// $headerCampaignName = array(
// 'Campaign Name :' => '@', //text
// '$list_name' => $rCampaignName['campaign_name'], //text
// 'Customer' => '@',
// '4' => '@',
// '5' => '@',
// '6' => '@', //custom
// '7' => '@',
// '8' => '@',
// 'TSR' => '@',
// 'Date Time' => '@',
// );
$headerListLotName = array(
'List Lot Name :' => '@', //text
' ' => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
// $headerLeadSource = array(
// 'Lead Source :' => '@', //text
// '$list_name' => '@', //text
// 'Customer' => '@',
// '4' => '@',
// '5' => '@',
// '6' => '@', //custom
// '7' => '@',
// '8' => '@',
// 'TSR' => '@',
// 'Date Time' => '@',
// );
$headerLeadSource = array(
'Lead Source :' => '@', //text
implode(',', array_column($rowLDN, 0)) => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
$headerPeriod = array(
'Period :' => '@', //text
$startdate2 . " - " . $enddate2 => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
$headerStatus = array(
'Status :' => '@', //text
implode(',', array_column($rowSTSN, 0)) => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
$headerReportasAt = array(
'Report as at :' => '@', //text
$currentDate => 'date', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
$headerWhiteSpace = array(
' ' => '@', //text
' ' => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
$header1 = array(
'STATUS' => '@', //text
'REASON' => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
);
$header2 = array(
'STATUS' => 'string', //text
'REASON' => '@', //text
'No.' => 'integer',
'Refer no' => '0',
'Source' => 'string',
'ID' => '0', //custom
'First Name' => 'string',
'Last Name' => 'string',
'TSR' => 'string',
'Date Time' => 'string',
);
// $rows[] = [
// 'status',
// 'reason',
// 'row_number',
// 'OSR_REFERENC',
// 'list_name',
// 'id_num',
// 'first_name',
// 'last_name',
// 'TSR',
// 'date_time',
// ];
while ($rCampaignName = mysqli_fetch_assoc($resultCampaignName)) {
$rowCPN[] = [
$rCampaignName['campaign_name']
];
}
while ($r = mysqli_fetch_assoc($result)) {
$rows[] = [
$r['status'],
$r['reason'],
$r['row_number'],
$r['OSR_REFERENC'],
$r['list_name'],
$r['id_num'],
$r['first_name'],
$r['last_name'],
$r['TSR'],
$r['date_time'],
];
}
$writer = new XLSXWriter();
$writer->setAuthor('Some Author');
$styles1 = array('font' => 'Arial', 'font-size' => 12, 'font-style' => 'bold', 'fill' => '#eee', 'halign' => 'center', 'border' => 'left,right,top,bottom', 'border-style' => 'medium', 'border-color' => '#222', 'widths' => [35, 55, 10, 20, 70, 10, 15, 20, 30, 15]);
$styles3 = array('font' => 'Arial', 'font-size' => 12, 'font-style' => 'bold', 'fill' => '#eee', 'valign' => 'distributed', 'halign' => 'center', 'border' => 'left,right,top,bottom', 'border-style' => 'medium', 'border-color' => '#222', 'widths' => [35, 55, 10, 20, 70, 10, 15, 20, 30, 15]);
$stylesHeaderReportName = array('font' => 'Arial', 'font-size' => 22, 'font-style' => 'bold', 'halign' => 'left', 'border' => 'left,right,top,bottom', 'border-style' => 'thin', 'widths' => [35, 55, 10, 20, 70, 10, 15, 20, 30, 15]);
$stylesHeaderCol1Merge = array('font' => 'Arial', 'font-size' => 16, 'font-style' => 'bold', 'halign' => 'left', 'border' => 'left,right,top,bottom', 'border-style' => 'thin', 'widths' => [35, 55, 10, 20, 70, 10, 15, 20, 30, 15]);
$stylesHeaderCol1MergeEx = array('font' => 'Arial', 'font-size' => 16, 'font-style' => 'bold', 'color' => '#eee', 'halign' => 'left', 'border' => 'left,right,top,bottom', 'border-style' => 'thin', 'widths' => [35, 55, 10, 20, 70, 10, 15, 20, 30, 15]);
$stylesHeaderWhiteSpace = array('font' => 'Arial', 'font-size' => 16, 'font-style' => 'bold', 'color' => '#FFF', 'halign' => 'left', 'border' => 'left,right,top,bottom', 'border-style' => 'thin', 'border-color' => '#eee', 'widths' => [35, 55, 10, 20, 70, 10, 15, 20, 30, 15]);
$styles2 = array('font' => 'Arial', 'font-size' => 10, 'font-style' => 'bold', 'fill' => '#FFE5B4', 'halign' => 'center', 'border' => 'left,right,top,bottom', 'border-style' => 'medium', 'border-color' => '#222');
$writer->writeSheetHeader('BasicFormats', $headerReportName, $stylesHeaderReportName);
$writer->writeSheetHeader(
'BasicFormats',
array(
'Campaign Name :' => '@', //text
implode(',', array_column($rowCPN, 0)) => '@', //text
'Customer' => '@',
'4' => '@',
'5' => '@',
'6' => '@', //custom
'7' => '@',
'8' => '@',
'TSR' => '@',
'Date Time' => '@',
),
$stylesHeaderCol1Merge
);
$writer->writeSheetHeader('BasicFormats', $headerListLotName, $stylesHeaderCol1Merge);
$writer->writeSheetHeader('BasicFormats', $headerLeadSource, $stylesHeaderCol1Merge);
$writer->writeSheetHeader('BasicFormats', $headerPeriod, $stylesHeaderCol1Merge);
$writer->writeSheetHeader('BasicFormats', $headerStatus, $stylesHeaderCol1Merge);
$writer->writeSheetHeader('BasicFormats', $headerReportasAt, $stylesHeaderCol1MergeEx);
$writer->writeSheetHeader('BasicFormats', $headerWhiteSpace, $stylesHeaderWhiteSpace);
$writer->writeSheetHeader('BasicFormats', $header1, $styles3);
$writer->markMergedCell('BasicFormats', $start_row = 0, $start_col = 0, $end_row = 0, $end_col = 9); // merge $headerReportName change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 1, $start_col = 1, $end_row = 1, $end_col = 9); // merge $headerCampaignName change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 2, $start_col = 1, $end_row = 2, $end_col = 9); // merge $headerListLotName change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 3, $start_col = 1, $end_row = 3, $end_col = 9); // merge $headerLeadSource change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 4, $start_col = 1, $end_row = 4, $end_col = 9); // merge $headerPeriod change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 5, $start_col = 1, $end_row = 5, $end_col = 9); // merge $headerStatus change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 6, $start_col = 1, $end_row = 6, $end_col = 9); // merge headerReportasAt change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 7, $start_col = 0, $end_row = 7, $end_col = 0); // merge $headerWhiteSpace change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 8, $start_col = 2, $end_row = 8, $end_col = 7); // merge customer change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 8, $start_col = 0, $end_row = 9, $end_col = 0); // merge status change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 8, $start_col = 1, $end_row = 9, $end_col = 1); // merge reason change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 8, $start_col = 8, $end_row = 9, $end_col = 8); // merge tsr change start_row and end_row
$writer->markMergedCell('BasicFormats', $start_row = 8, $start_col = 9, $end_row = 9, $end_col = 9); // merge date_time change Start_row and end_row
$writer->writeSheetHeader('BasicFormats', $header2, $styles1);
foreach ($rows as $row)
$writer->writeSheetRow('BasicFormats', $row, $styles2);
$writer->writeToStdOut();
//$writer->writeToFile('example.xlsx');
//echo $writer->writeToString();
mysqli_close($conn);
exit(0);
}
from php_xlsxwriter.
from php_xlsxwriter.
Related Issues (20)
- GitHub About (quick win) HOT 1
- Not Work Xampp PHP v8.1.6 HOT 3
- How to add cell data starting with space or more space (not trimmed) HOT 1
- How to set cell width HOT 2
- Macro HOT 1
- Date format issue in Excel 2021 HOT 1
- Writing excel with title/caption in first two rows then header and then rows HOT 3
- Trouble on styling cells HOT 1
- auto_filter doesn't work when there are rows before table header HOT 1
- Question: Requirements on Docker HOT 1
- вакансия пхп
- how do i set different font color in one cell
- Is it intentional that the default number format formatCode is "GENERAL" instead of "General" HOT 1
- Error when opening file generated with this library in a newer version of excel. HOT 1
- TimeFormat in Excel 365 with only time as input HOT 1
- Set cell width only for some cells HOT 2
- PHP 8.2 deprecation warning, passing NULL to htmlspecialchars HOT 2
- Is this streaming the info from memory to disk?
- `widths` does not take effect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php_xlsxwriter.