本文整理汇总了PHP中ExcelWriter::close方法的典型用法代码示例。如果您正苦于以下问题:PHP ExcelWriter::close方法的具体用法?PHP ExcelWriter::close怎么用?PHP ExcelWriter::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExcelWriter
的用法示例。
在下文中一共展示了ExcelWriter::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ImportData
function ImportData($sql, $fileName = "har_excel.xls", $download = false)
{
$excel = new ExcelWriter($fileName);
if ($excel == false) {
$this->error = $excel->error;
return false;
}
$this->db->query($sql);
if ($this->db->numRows() == 0) {
$this->error = "No data found in the table";
return false;
}
if ($row = $this->db->fetchAssoc()) {
for ($i = 0; $i < count($row); $i++) {
$fields[] = $this->db->fieldName($i);
}
$excel->writeLine($fields);
do {
$excel->writeLine($row);
} while ($row = $this->db->fetchAssoc());
}
$excel->close();
$this->db->close();
if ($download) {
if (!headers_sent()) {
$this->download_file($fileName, true);
} else {
$this->error = "Error :Headers already Sent.Can't Download file.";
}
}
return;
}
示例2: googleProduct
/**
* Function generates a excel product report for google base
*
*
* @return file
*/
function googleProduct()
{
include "classes/Lib/excelwriter.inc.php";
$excel = new ExcelWriter("GoogleBase_Product_Feed.xls");
if ($excel == false) {
echo $excel->error;
}
$myArr = array("Product Id", "Product Title", "Description", "Product Price", "Link", "Brand", "Image Link", "Weight");
$excel->writeLine($myArr);
$sql = 'select product_id,title,description,price,brand,thumb_image,weight from products_table';
$obj = new Bin_Query();
if ($obj->executeQuery($sql)) {
$cnt = count($obj->records);
for ($i = 0; $i < $cnt; $i++) {
$product_id = $obj->records[$i]['product_id'];
$title = $obj->records[$i]['title'];
$description = strip_tags($obj->records[$i]['description']);
$price = $obj->records[$i]['price'];
$brand = $obj->records[$i]['brand'];
$thumb_image = $obj->records[$i]['thumb_image'];
$image_link = $_SERVER['SERVER_NAME'] . '/' . $thumb_image;
$weight = $obj->records[$i]['weight'];
$link = $_SERVER['SERVER_NAME'] . '/?do=prodetail&action=showprod&id=' . $product_id;
$excel->writeRow();
$excel->writeCol($product_id);
$excel->writeCol($title);
$excel->writeCol($description);
$excel->writeCol($price);
$excel->writeCol($link);
$excel->writeCol($brand);
$excel->writeCol($image_link);
$excel->writeCol($weight);
}
$excel->close();
}
if (strpos($_SERVER['USER'], 'MSIE')) {
// IE cannot download from sessions without a cache
header('Cache-Control: public');
} else {
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: no-cache");
}
$file = "GoogleBase_Product_Feed.xls";
//chmod ($file, 0755);
header("Pragma: no-cache");
header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
header("Connection: close");
header("Content-Disposition: attachment; filename=" . $file . "\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . (string) filesize("{$file}"));
$fd = fopen($file, "rb");
fpassthru($fd);
}
示例3: ExcelWriter
$arquivoDiretorio = "../relatorios/conciliacao_franquia/" . $nomeArquivo;
$excel = new ExcelWriter($arquivoDiretorio);
if ($excel == false) {
echo $excel->error;
exit;
}
//Unidade
$myArr = array('Relação de pedidos em conciliação franquia:' . $emp->fantasia);
$excel->writeLine($myArr);
//periodo
$myArr = array('Até: ' . date('d') . '/' . date('m') . '/' . date('Y'));
$excel->writeLine($myArr);
//espaço
$myArr = array(' ');
$excel->writeLine($myArr);
//Escreve o nome dos campos de uma tabela
$excel->writeLine(array('PEDIDO', 'ABERTO HÁ (dias) ', 'ATENDENTE'));
$total_comissao = 0;
$total = 0;
$cont = 0;
$old_id_usuario = '';
$pedidos = $pedidoDAO->listarConciliacaoFranquia($emp->id_empresa);
foreach ($pedidos as $pe) {
$diff = time() - strtotime($pe->data_atividade);
$diff = number_format($diff / 60 / 60 / 24, 0);
$excel->writeLine(array('#' . $pe->id_pedido . '/' . $pe->ordem, $diff, $pe->atendente, date("d/m/Y", strtotime($pe->data_atividade))));
}
$excel->close();
$relatorioDAO->registraRel($id_empresa, $arquivoDiretorio, 'conciliação franquia');
}
echo '</pre>';
示例4: adminActivityDataExport
/**
* Function exports the admin activity report from the database into various file format
* Excel/CSV/TSV/XML Formats
*
* @return file
*/
function adminActivityDataExport()
{
if ($_POST['export'] == 'excel') {
include "classes/Lib/excelwriter.inc.php";
$excel = new ExcelWriter("adminactivity_Detail.xls");
if ($excel == false) {
echo $excel->error;
}
$myArr = array("SlNo", "UserId", "Url", "VisitedOn");
$excel->writeLine($myArr);
$j = 1;
$sql = 'select user_id,url,visited_on from admin_activity_table';
$obj = new Bin_Query();
$obj->executeQuery($sql);
if ($obj->executeQuery($sql)) {
$cnt = count($obj->records);
for ($i = 0; $i < $cnt; $i++) {
$user_id = $obj->records[$i]['user_id'];
$url = $obj->records[$i]['url'];
$visited_on = $obj->records[$i]['visited_on'];
$excel->writeRow();
$excel->writeCol($j);
$excel->writeCol($user_id);
$excel->writeCol($url);
$excel->writeCol($visited_on);
$j++;
}
$excel->close();
}
if (strpos($_SERVER['USER'], 'MSIE')) {
// IE cannot download from sessions without a cache
header('Cache-Control: public');
} else {
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: no-cache");
}
$file = "adminactivity_Detail.xls";
//chmod ($file, 0755);
header("Pragma: no-cache");
header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
header("Connection: close");
header("Content-Disposition: attachment; filename=" . $file . "\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . (string) filesize("{$file}"));
$fd = fopen($file, "rb");
fpassthru($fd);
/*function xlsBOF()
{
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
function xlsEOF()
{
echo pack("ss", 0x0A, 0x00);
return;
}
function xlsWriteNumber($Row, $Col, $Value)
{
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
function xlsWriteLabel($Row, $Col, $Value )
{
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
//Send header
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=user_report.xls");
header("Content-Transfer-Encoding: binary ");
xlsBOF();
xlsWriteLabel(1,0,"No");
xlsWriteLabel(1,1,"First Name");
xlsWriteLabel(1,2,"Last Name");
xlsWriteLabel(1,3,"Display Name");
xlsWriteLabel(1,4,"Email");
xlsWriteLabel(1,5,"Date of Joining");
$xlsRow = 2;
$j=1;
//Query
//.........这里部分代码省略.........
示例5: index
//.........这里部分代码省略.........
}
//DEFINE OS TIPOS DE RELATORIOS
$data['filter_date_start'] = $filter_date_start;
$data['filter_date_end'] = $filter_date_end;
$data['filter_type'] = $filter_type;
$data['filter_zone'] = $filter_zone;
$data['filter_order_status_id'] = $filter_order_status_id;
$data['filter_payment_method'] = $filter_payment_method;
$data['filter_shipping_method'] = $filter_shipping_method;
$data['filter_options'] = $filter_options;
if ($filter_type == '0') {
$this->response->redirect($this->url->link('report/export_reports', 'error_warning=É necessário selecionar o tipo de relatório!&token=' . $this->request->get['token'], 'SSL'));
}
//Incluir a classe excelwriter
require_once DIR_SYSTEM . "library/excel/excelwriter.inc.php";
$name_file = DIR_APPLICATION . 'controller/report/reports/report_' . $filter_type . '_' . date('d-m-Y-H-i-s') . '.xls';
//GERA OS RELATORIOS
//PRODUTOS E PEDIDOS
if ($data['filter_type'] == 'products_orders') {
$results = $this->model_report_export_reports->getProductsOrders($filter_date_start, $filter_date_end);
$excel = new ExcelWriter($name_file);
$myArr = array('Pedido', 'Cliente', 'Email', 'Data', 'Status', 'Código', 'Tamanho', 'Descrição', 'Marca', 'Qtde', 'Preço Un', 'Total Item');
$excel->writeLine($myArr, 'title');
foreach ($results as $result) {
$manufacturer = $this->db->query("SELECT m.name AS manufacturer FROM `" . DB_PREFIX . "product` p LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . $result['product_id'] . "'");
if ($manufacturer->rows) {
$manufacturer = $manufacturer->row['manufacturer'];
} else {
$manufacturer = '';
}
$myArr = array($result['order_id'], $result['customer'], $result['email'], date('d/m/Y', strtotime($result['date_added'])), $result['STATUS'], $result['model'], $result['value'], $result['name'], $manufacturer, $result['quantity'], $this->currency->format($result['price']), $this->currency->format($result['total']));
$excel->writeLine($myArr, 'rows');
}
$excel->close();
$this->model_report_export_reports->setReport('Produtos e Pedidos', str_replace(DIR_APPLICATION, HTTPS_SERVER, $name_file));
$this->response->redirect($this->url->link('report/export_reports', 'success=Arquivo Gerado com Sucesso!&token=' . $this->request->get['token'], 'SSL'));
exit;
}
//ProdutosURL
if ($data['filter_type'] == 'products_URL') {
$results = $this->model_report_export_reports->getProductsURL($filter_date_start, $filter_date_end);
$excel = new ExcelWriter($name_file);
$myArr = array('Descrição', 'Categoria', 'Url Amigável');
$excel->writeLine($myArr, 'title');
foreach ($results as $result) {
$url = $this->model_report_export_reports->rewrite('index.php?route=product/product&product_id=' . $result['product_id']);
$categories = $this->model_report_export_reports->getCategories($result['product_id']);
$myArr = array($result['name'], $categories, $url);
$excel->writeLine($myArr, 'rows');
}
$excel->close();
$this->model_report_export_reports->setReport('Produtos URL', str_replace(DIR_APPLICATION, HTTPS_SERVER, $name_file));
$this->response->redirect($this->url->link('report/export_reports', 'success=Arquivo Gerado com Sucesso!&token=' . $this->request->get['token'], 'SSL'));
exit;
}
//BALANÇO
if ($data['filter_type'] == 'balance') {
$results = $this->model_report_export_reports->getBalance($filter_date_start, $filter_date_end);
$total_geral = 0;
$excel = new ExcelWriter($name_file);
$myArr = array('Pedido', 'Nome', 'Data', 'Total', 'Método', 'Status');
$excel->writeLine($myArr, 'title');
foreach ($results as $result) {
$myArr = array($result['order_id'], $result['nome'], $result['data_compra'], $result['total'], $result['payment_method'], $result['status_pedido']);
$excel->writeLine($myArr, 'rows');
}
示例6: getExcel
/**
* Retourne le tableau au format excel
*
*/
public function getExcel()
{
//Inclusion de la classe pour gnération des fichiers excel
require_once COPIX_PATH . '../excelwriter/excelwriter.inc.php';
$excel = new ExcelWriter("temp.xls", "", "");
if ($excel == false) {
throw new Exception($excel->error);
}
//Création de la ligne de titre
if (count($this->_title) > 0) {
$tabTitle = array();
foreach ($this->_title as $key => $titre) {
$tabTitle[utf8_decode($titre)] = isset($this->_size[$key]) ? $this->_size[$key] : $this->_defaultSize;
}
$excel->writeLine($tabTitle, "gras");
}
//Création des lignes de données
foreach ($this->_array as $line) {
$excel->writeRow();
if (count($this->_mapObject) > 0) {
foreach ($this->_mapObject as $key => $map) {
$size = isset($this->_size[$key]) ? $this->_size[$key] : $this->_defaultSize;
$excel->writeCol(utf8_decode($line->{$map}), $size);
}
} else {
foreach ($line as $key => $cell) {
$size = isset($this->_size[$key]) ? $this->_size[$key] : $this->_defaultSize;
$excel->writeCol(utf8_decode($cell), $size);
}
}
}
//Fin du document
$excel->close();
return $excel->getData();
}
示例7: write_xls
function write_xls($sql)
{
//echo $sql;
$sql = str_replace('\\', '', $sql);
$excel = new ExcelWriter('excel_report/' . date('m_d_Y_s') . '_feedback_report.xls');
$file_name = date('m_d_Y_s') . '_feedback_report.xls';
if ($excel == false) {
echo $excel->error;
}
$result1 = mysql_query($sql);
$arr1 = mysql_fetch_array($result1);
$myArr = array("Branch", branch_name($arr1['b_id']), "", "Semester", sem_name($arr1['sem_id']));
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$myArr = array("Batch", batch_name($arr1['batch_id']), "", "Feedback No", $arr1['feedback_no']);
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$myArr = array("Faculty Name:", faculty_name($arr1['f_id']), "", "Subject:", subject_name($arr1['sub_id']));
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$myArr = array("Remark");
//"Ans1","Ans2","Ans3","Ans4","Ans5","Ans6","Ans7","Ans8","Ans9"
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$result = mysql_query($sql) or die(mysql_error());
$total_ids = "0";
$r_id = 1;
while ($arr = mysql_fetch_array($result)) {
if ($arr['remark'] != NULL) {
$myArr = array($arr['remark']);
//$arr['ans1'],$arr['ans2'],$arr['ans3'],$arr['ans4'],$arr['ans5'],$arr['ans6'],$arr['ans7'],$arr['ans8'],$arr['ans9']
$excel->writeLine($myArr);
//$r_id++;
}
}
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$excel->close();
return $file_name;
}
示例8: createReport
/**
* Function generates a report in the file format.
* @param array $sql
*
* @return file
*/
function createReport($sql)
{
if ($_POST['export'] == 'excel') {
include "classes/Lib/excelwriter.inc.php";
$excel = new ExcelWriter("User_Detail.xls");
if ($excel == false) {
$excel->error;
}
$myArr = array("No", "Display Name", "First Name", "Last Name", "Email", "Address", "City", "State", "Zip Code", "Country");
$excel->writeLine($myArr);
$j = 1;
$sql = 'select * from users_table';
$obj = new Bin_Query();
if ($obj->executeQuery($sql)) {
$cnt = count($obj->records);
for ($i = 0; $i < $cnt; $i++) {
$sqlAdd = "SELECT a.*,b.cou_code,b.cou_name FROM addressbook_table AS a LEFT JOIN country_table AS b ON b.cou_code=a.country WHERE a.user_id='" . $obj->records[$i]['user_id'] . "'";
$objAdd = new Bin_Query();
$objAdd->executeQuery($sqlAdd);
$display_name = $obj->records[$i]['user_display_name'];
$first_name = $obj->records[$i]['user_fname'];
$last_name = $obj->records[$i]['user_lname'];
$email = $obj->records[$i]['user_email'];
$address = $objAdd->records[0]['address'];
$city = $objAdd->records[0]['city'];
$state = $objAdd->records[0]['state'];
$zip = $objAdd->records[0]['zip'];
$country = $objAdd->records[0]['cou_name'];
$doj = $obj->records[$i]['user_doj'];
$excel->writeRow();
$excel->writeCol($j);
$excel->writeCol($display_name);
$excel->writeCol($first_name);
$excel->writeCol($last_name);
$excel->writeCol($email);
$excel->writeCol($address);
$excel->writeCol($city);
$excel->writeCol($state);
$excel->writeCol($zip);
$excel->writeCol($country);
$excel->writeCol($doj);
$j++;
}
$excel->close();
}
if (strpos($_SERVER['USER'], 'MSIE')) {
// IE cannot download from sessions without a cache
header('Cache-Control: public');
} else {
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: no-cache");
}
$file = "User_Detail.xls";
//chmod ($file, 0755);
header("Pragma: no-cache");
header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
header("Connection: close");
header("Content-Disposition: attachment; filename=" . $file . "\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . (string) filesize("{$file}"));
$fd = fopen($file, "rb");
fpassthru($fd);
} else {
if ($_POST['export'] == 'xml') {
$sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
$obj = new Bin_Query();
if ($obj->executeQuery($sqlselect)) {
header("Content-Type: text/xml");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: xml/force-download");
header("Content-Type: xml/octet-stream");
header("Content-Type: xml/download");
header("Content-Disposition: attachment;filename=user_report.xml");
header("Content-Transfer-Encoding: binary ");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
echo "<userdetails>\n";
$count = count($obj->records);
for ($i = 0; $i < $count; $i++) {
$sqlAdd = "SELECT a.*,b.cou_code,b.cou_name FROM addressbook_table AS a LEFT JOIN country_table AS b ON b.cou_code=a.country WHERE a.user_id='" . $obj->records[$i]['user_id'] . "'";
$objAdd = new Bin_Query();
$objAdd->executeQuery($sqlAdd);
echo "<userid>" . $obj->records[$i]['user_id'] . "</userid>\n";
echo "<displayname>" . $obj->records[$i]['user_display_name'] . "</displayname>\n";
echo "<firstname>" . $obj->records[$i]['user_fname'] . "</firstname>\n";
echo "<lastname>" . $obj->records[$i]['user_lname'] . "</lastname>\n";
echo "<email>" . $obj->records[$i]['user_email'] . "</email>\n";
echo "<address>" . $objAdd->records[0]['address'] . "</address>\n";
echo "<city>" . $objAdd->records[0]['city'] . "</city>\n";
echo "<state>" . $objAdd->records[0]['state'] . "</state>\n";
echo "<zipcode>" . $objAdd->records[0]['zip'] . "</zipcode>\n";
echo "<country>" . $objAdd->records[0]['cou_name'] . "</country>\n";
echo "<userdoj>" . $obj->records[$i]['user_doj'] . "</userdoj>\n";
//.........这里部分代码省略.........
示例9: OrderDataExport
/**
* Function converts the order details from the database into an Excel/CSV/TSV/XML format.
*
*
* @return file
*/
function OrderDataExport()
{
if ($_POST['export'] == 'excel') {
include "classes/Lib/excelwriter.inc.php";
$excel = new ExcelWriter("order_Detail.xls");
if ($excel == false) {
echo $excel->error;
}
$myArr = array("SlNo", "Orders Id", "Shipping Name", "Street Address", "Suburb", "City", "State", "Billing Company");
$excel->writeLine($myArr);
$j = 1;
$sql = 'select orders_id,shipping_name,shipping_street_address,shipping_suburb,shipping_city,shipping_state,billing_company from orders_table';
$obj = new Bin_Query();
if ($obj->executeQuery($sql)) {
$cnt = count($obj->records);
for ($i = 0; $i < $cnt; $i++) {
$orders_id = $obj->records[$i]['orders_id'];
$shipping_name = $obj->records[$i]['shipping_name'];
$shipping_street_address = $obj->records[$i]['shipping_street_address'];
$shipping_suburb = $obj->records[$i]['shipping_suburb'];
$shipping_city = $obj->records[$i]['shipping_city'];
$shipping_state = $obj->records[$i]['shipping_state'];
$billing_company = $obj->records[$i]['billing_company'];
//$doj = $obj->records[$i]['user_doj'];
$excel->writeRow();
$excel->writeCol($j);
$excel->writeCol($orders_id);
$excel->writeCol($shipping_name);
$excel->writeCol($shipping_street_address);
$excel->writeCol($shipping_suburb);
$excel->writeCol($shipping_city);
$excel->writeCol($shipping_state);
$excel->writeCol($billing_company);
//$excel->writeCol($doj);
$j++;
}
$excel->close();
}
if (strpos($_SERVER['USER'], 'MSIE')) {
// IE cannot download from sessions without a cache
header('Cache-Control: public');
} else {
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: no-cache");
}
$file = "order_Detail.xls";
//chmod ($file, 0755);
header("Pragma: no-cache");
header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
header("Connection: close");
header("Content-Disposition: attachment; filename=" . $file . "\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . (string) filesize("{$file}"));
$fd = fopen($file, "rb");
fpassthru($fd);
} else {
if ($_POST['export'] == 'xml') {
$sqlselect = "select orders_id,shipping_name,shipping_street_address,shipping_suburb,shipping_city,shipping_state,billing_company from orders_table";
$obj = new Bin_Query();
if ($obj->executeQuery($sqlselect)) {
header("Content-Type: text/xml");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: xml/force-download");
header("Content-Type: xml/octet-stream");
header("Content-Type: xml/download");
header("Content-Disposition: attachment;filename=order_details.xml");
header("Content-Transfer-Encoding: binary ");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<orderdetails>\n";
$count = count($obj->records);
for ($i = 0; $i < $count; $i++) {
echo "<orderid>" . $obj->records[$i]['orders_id'] . "</orderid>\n";
echo "<shipping_name>" . $obj->records[$i]['shipping_name'] . "</shipping_name>\n";
echo "<shipping_street_address>" . $obj->records[$i]['shipping_street_address'] . "</shipping_street_address>\n";
echo "<shipping_suburb>" . $obj->records[$i]['shipping_suburb'] . "</shipping_suburb>\n";
echo "<shipping_city>" . $obj->records[$i]['shipping_city'] . "</shipping_city>\n";
echo "<shipping_state>" . $obj->records[$i]['shipping_state'] . "</shipping_state>\n";
}
echo "</orderdetails>\n";
exit;
}
} else {
if ($_POST['export'] == 'csv') {
$csv_terminated = "\n";
$csv_separator = ",";
$csv_enclosed = '"';
$csv_escaped = "\\";
$sqlselect = "select orders_id,shipping_name,shipping_street_address,shipping_suburb,shipping_city,shipping_state,billing_company from orders_table";
$obj = new Bin_Query();
if ($obj->executeQuery($sqlselect)) {
$schema_insert = '';
$schema_insert .= $csv_enclosed . Orderid . $csv_enclosed . $csv_separator;
//.........这里部分代码省略.........
示例10: productReviewReport
/**
* Function generates a product review report in the file format.
* @param string $sql
*
* @return file
*/
function productReviewReport($sql)
{
if ($_POST['export'] == 'excel') {
include "classes/Lib/excelwriter.inc.php";
$excel = new ExcelWriter("Product_Review.xls");
if ($excel == false) {
echo $excel->error;
}
$myArr = array("Id", "User Name", "Title", "Review Summary", "Review", "Review Date");
$excel->writeLine($myArr);
$obj = new Bin_Query();
if ($obj->executeQuery($sql)) {
$cnt = count($obj->records);
for ($i = 0; $i < $cnt; $i++) {
$product_id = $obj->records[$i]['product_id'];
$display_name = $obj->records[$i]['user_display_name'];
$title = $obj->records[$i]['title'];
$reviewsummary = $obj->records[$i]['review_txt'];
$review = $obj->records[$i]['review_caption'];
$reviewdate = $obj->records[$i]['review_date'];
$excel->writeRow();
$excel->writeCol($product_id);
$excel->writeCol($display_name);
$excel->writeCol($title);
$excel->writeCol($reviewsummary);
$excel->writeCol($review);
$excel->writeCol($reviewdate);
}
$excel->close();
}
if (strpos($_SERVER['USER'], 'MSIE')) {
// IE cannot download from sessions without a cache
header('Cache-Control: public');
} else {
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: no-cache");
}
$file = "Product_Review.xls";
//chmod ($file, 0755);
header("Pragma: no-cache");
header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
header("Connection: close");
header("Content-Disposition: attachment; filename=" . $file . "\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . (string) filesize("{$file}"));
$fd = fopen($file, "rb");
fpassthru($fd);
} else {
if ($_POST['export'] == 'xml') {
//$sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
$obj = new Bin_Query();
if ($obj->executeQuery($sql)) {
header("Content-Type: text/xml");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: xml/force-download");
header("Content-Type: xml/octet-stream");
header("Content-Type: xml/download");
header("Content-Disposition: attachment;filename=product_review_report.xml");
header("Content-Transfer-Encoding: binary ");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
echo "<productreviewdetails>\n";
$cnt = count($obj->records);
for ($i = 0; $i < $cnt; $i++) {
/*echo ("<user id=\"". $obj->records[$i]['user_id'] ."\">\n");
echo ("<firstname=\"". $obj->records[$i]['user_fname'] ."\">\n");
echo ("<lastname=\"". $obj->records[$i]['user_lname'] ."\">\n");
echo ("<displayname=\"". $obj->records[$i]['user_display_name'] ."\">\n");
echo ("<email=\"". $obj->records[$i]['user_email'] ."\">\n");
echo ("<userdoj=\"". $obj->records[$i]['user_doj'] ."\">\n");*/
echo "<productid>" . $obj->records[$i]['product_id'] . "<\\productid>\n";
echo "<username>" . $obj->records[$i]['user_display_name'] . "<\\username>\n";
echo "<title>" . $obj->records[$i]['title'] . "<\title>\n";
echo "<reviewsummary>" . $obj->records[$i]['review_txt'] . "<\reviewsummary>\n";
echo "<review>" . $obj->records[$i]['review_caption'] . "<\review>\n";
echo "<reviewdate>" . $obj->records[$i]['review_date'] . "<\reviewdate>\n";
}
echo "</productreviewdetails>\n";
}
} else {
if ($_POST['export'] == 'csv') {
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: " . strlen($out));
header("Content-type: text/x-csv");
header("Content-Disposition: attachment; filename=product_review_report.csv");
$csv_terminated = "\n";
$csv_separator = ",";
$csv_enclosed = '"';
$csv_escaped = "\\";
//$sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
$obj = new Bin_Query();
if ($obj->executeQuery($sql)) {
$schema_insert = $csv_enclosed . Id . $csv_enclosed . $csv_separator;
//.........这里部分代码省略.........
示例11: builtXLS
public function builtXLS()
{
$this->load->model('report/product');
$url = '';
if (isset($this->request->get['filter_date_start'])) {
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
}
if (isset($this->request->get['filter_date_end'])) {
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
}
if (isset($this->request->get['filter_payment_method'])) {
$url .= '&filter_payment_method=' . $this->request->get['filter_payment_method'];
}
if (isset($this->request->get['filter_shipping_method'])) {
$url .= '&filter_shipping_method=' . $this->request->get['filter_shipping_method'];
}
if (isset($this->request->get['filter_payment_code'])) {
$url .= '&filter_payment_code=' . $this->request->get['filter_payment_code'];
}
if (isset($this->request->get['filter_type_date'])) {
$url .= '&filter_type_date=' . $this->request->get['filter_type_date'];
}
if (isset($this->request->get['filter_order_status_id'])) {
$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
}
require_once DIR_SYSTEM . "library/excel/excelwriter.inc.php";
if (is_file(DIR_APPLICATION . 'controller/report/reports/product_purchased.xls')) {
unlink(DIR_APPLICATION . 'controller/report/reports/product_purchased.xls');
}
$name_file = DIR_APPLICATION . 'controller/report/reports/product_purchased.xls';
if (isset($this->request->get['filter_date_start'])) {
$filter_date_start = $this->request->get['filter_date_start'];
} else {
$filter_date_start = '';
}
if (isset($this->request->get['filter_date_end'])) {
$filter_date_end = $this->request->get['filter_date_end'];
} else {
$filter_date_end = '';
}
if (isset($this->request->get['filter_payment_code'])) {
$filter_payment_code = $this->request->get['filter_payment_code'];
} else {
$filter_payment_code = '';
}
if (isset($this->request->get['filter_shipping_method'])) {
$filter_shipping_method = $this->request->get['filter_shipping_method'];
} else {
$filter_shipping_method = '';
}
if (isset($this->request->get['filter_payment_method'])) {
$filter_payment_method = $this->request->get['filter_payment_method'];
} else {
$filter_payment_method = '';
}
if (isset($this->request->get['filter_type_date'])) {
$filter_type_date = $this->request->get['filter_type_date'];
} else {
$filter_type_date = '';
}
if (isset($this->request->get['filter_order_status_id'])) {
$filter_order_status_id = $this->request->get['filter_order_status_id'];
} else {
$filter_order_status_id = 0;
}
$filter_data = array('filter_date_start' => $filter_date_start, 'filter_date_end' => $filter_date_end, 'filter_payment_code' => $filter_payment_code, 'filter_payment_method' => $filter_payment_method, 'filter_shipping_method' => $filter_shipping_method, 'filter_order_status_id' => $filter_order_status_id, 'filter_type_date' => $filter_type_date);
$results = $this->model_report_product->getPurchased($filter_data);
$excel = new ExcelWriter($name_file);
if (count($results) > 0) {
$myArr = array('Nome do produto', 'Modelo', 'Quantidade', 'Preço de Custo', 'Total');
$excel->writeLine($myArr, 'title');
foreach ($results as $result) {
$myArr = array($result['name'], $result['model'], $result['quantity'], $this->currency->format($result['cost_price'], $this->config->get('config_currency')), $this->currency->format($result['total'], $this->config->get('config_currency')));
$excel->writeLine($myArr, 'rows');
}
$excel->close();
$this->response->redirect(HTTPS_SERVER . 'controller/report/reports/product_purchased.xls');
} else {
$this->response->redirect($this->url->link('report/product_purchased', 'warning=Nenhum registro foi encontrado&token=' . $this->session->data['token'] . $url, 'SSL'));
}
}
示例12: write_xls
function write_xls($sql)
{
$sql = str_replace('\\', '', $sql);
$excel = new ExcelWriter('excel_report/' . date('m_d_Y_s') . '_feedback_report.xls');
$file_name = date('m_d_Y_s') . '_feedback_report.xls';
if ($excel == false) {
echo $excel->error;
}
$result1 = mysql_query($sql) or die(mysql_error());
$arr1 = mysql_fetch_array($result1);
if (mysql_num_rows($result1) != 0) {
$myArr = array("Branch", branch_name($arr1['b_id']), "", "Semester", sem_name($arr1['sem_id']));
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$myArr = array("Batch", batch_name($arr1['batch_id']), "", "Division", division_name($arr1['division_id']), "", "Feedback No", $arr1['feedback_no']);
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$myArr = array("Faculty Name:", faculty_name($arr1['f_id']), "", "Subject:", subject_name($arr1['sub_id']));
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
/*$myArr=array("Remark(s)");//"Ans1","Ans2","Ans3","Ans4","Ans5","Ans6","Ans7","Ans8","Ans9"
$excel->writeLine($myArr);
$myArr=array("","","","","","");
$excel->writeLine($myArr);*/
$myArr = array("Ans1", "Ans2", "Ans3", "Ans4", "Ans5", "Ans6", "Ans7", "Ans8", "Ans9", "Remark");
$excel->writeLine($myArr);
$result = mysql_query($sql) or die(mysql_error());
$total_ids = "0";
$r_id = 1;
while ($arr = mysql_fetch_array($result)) {
/*if($arr['remark']!=NULL)
{
$myArr=array(strtolower($arr['remark']));
$excel->writeLine($myArr);
$r_id++;
}*/
$myArr = array($arr['ans1'], $arr['ans2'], $arr['ans3'], $arr['ans4'], $arr['ans5'], $arr['ans6'], $arr['ans7'], $arr['ans8'], $arr['ans9'], $arr['remark']);
$excel->writeLine($myArr);
$r_id++;
}
$myArr = array("", "", "", "", "", "");
$excel->writeLine($myArr);
$excel->close();
return $file_name;
} else {
echo '<p align=center>No Record Found!.</p>';
}
}
示例13: builtXLS
//.........这里部分代码省略.........
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_email'])) {
$url .= '&filter_email=' . urlencode(html_entity_decode($this->request->get['filter_email'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_customer_group_id'])) {
$url .= '&filter_customer_group_id=' . $this->request->get['filter_customer_group_id'];
}
if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['filter_birthday'])) {
$url .= '&filter_birthday=' . $this->request->get['filter_birthday'];
}
if (isset($this->request->get['filter_ip'])) {
$url .= '&filter_ip=' . $this->request->get['filter_ip'];
}
if (isset($this->request->get['filter_date_added'])) {
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['pdv'])) {
$url .= '&pdv=' . $this->request->get['pdv'];
}
require_once DIR_SYSTEM . "library/excel/excelwriter.inc.php";
$name_file = DIR_APPLICATION . 'controller/sale/customer_report/customer_report.xls';
if (isset($this->request->get['filter_name'])) {
$filter_name = $this->request->get['filter_name'];
} else {
$filter_name = null;
}
if (isset($this->request->get['filter_email'])) {
$filter_email = $this->request->get['filter_email'];
} else {
$filter_email = null;
}
if (isset($this->request->get['filter_customer_group_id'])) {
$filter_customer_group_id = $this->request->get['filter_customer_group_id'];
} else {
$filter_customer_group_id = null;
}
if (isset($this->request->get['filter_status'])) {
$filter_status = $this->request->get['filter_status'];
} else {
$filter_status = null;
}
if (isset($this->request->get['filter_birthday'])) {
$filter_birthday = $this->request->get['filter_birthday'];
} else {
$filter_birthday = null;
}
if (isset($this->request->get['filter_ip'])) {
$filter_ip = $this->request->get['filter_ip'];
} else {
$filter_ip = null;
}
if (isset($this->request->get['filter_date_added'])) {
$filter_date_added = $this->request->get['filter_date_added'];
} else {
$filter_date_added = null;
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'name';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
$filter_data = array('filter_name' => $filter_name, 'filter_email' => $filter_email, 'filter_customer_group_id' => $filter_customer_group_id, 'filter_status' => $filter_status, 'filter_birthday' => $filter_birthday, 'filter_date_added' => $filter_date_added, 'filter_ip' => $filter_ip, 'sort' => $sort, 'order' => $order);
$results = $this->model_sale_customer->getCustomers($filter_data);
$excel = new ExcelWriter($name_file);
if (count($results) > 0) {
$myArr = array('Nome', 'Email', 'Sexo', 'Data de Aniversário', 'Data de Cadastro');
$excel->writeLine($myArr, 'title');
foreach ($results as $result) {
if ($result['sex'] == 'F') {
$sex = 'Mulher';
} else {
$sex = 'Homem';
}
$myArr = array($result['firstname'] . ' ' . $result['lastname'], $result['email'], $sex, date('d/m/Y', strtotime($result['birthday'])), date('d/m/Y H:i:s', strtotime($result['date_added'])));
$excel->writeLine($myArr, 'rows');
}
$excel->close();
$this->response->redirect(HTTPS_SERVER . 'controller/sale/customer_report/customer_report.xls');
} else {
$this->response->redirect($this->url->link('sale/customer', 'warning=Nenhum registro foi encontrado&token=' . $this->session->data['token'] . $url, 'SSL'));
}
}
示例14: productDataExport
/**
* Function generates a product details in an excel/xml/csv/tsv format file
*
*
* @return file
*/
function productDataExport()
{
if ($_POST['export'] == 'excel') {
include "classes/Lib/excelwriter.inc.php";
$excel = new ExcelWriter("Product_Detail.xls");
if ($excel == false) {
echo $excel->error;
}
$myArr = array("SlNo", "Title", "Description", "Brand", "Model", "Msrp", "Price", "Shipping Cost", "Intro Date");
$excel->writeLine($myArr);
$j = 1;
$sql = 'select sku,title,description,brand,model,msrp,price,shipping_cost,intro_date from products_table';
$obj = new Bin_Query();
if ($obj->executeQuery($sql)) {
$cnt = count($obj->records);
for ($i = 0; $i < $cnt; $i++) {
$title = $obj->records[$i]['title'];
$description = $obj->records[$i]['description'];
$brand = $obj->records[$i]['brand'];
$model = $obj->records[$i]['model'];
$msrp = $obj->records[$i]['msrp'];
$price = $obj->records[$i]['price'];
$shipping_cost = $obj->records[$i]['shipping_cost'];
$intro_date = $obj->records[$i]['intro_date'];
//$doj = $obj->records[$i]['user_doj'];
$excel->writeRow();
$excel->writeCol($j);
$excel->writeCol($title);
$excel->writeCol($description);
$excel->writeCol($brand);
$excel->writeCol($model);
$excel->writeCol($msrp);
$excel->writeCol($price);
$excel->writeCol($shipping_cost);
$excel->writeCol($intro_date);
//$excel->writeCol($doj);
$j++;
}
$excel->close();
}
if (strpos($_SERVER['USER'], 'MSIE')) {
// IE cannot download from sessions without a cache
header('Cache-Control: public');
} else {
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: no-cache");
}
$file = "Product_Detail.xls";
//chmod ($file, 0755);
header("Pragma: no-cache");
header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
header("Connection: close");
header("Content-Disposition: attachment; filename=" . $file . "\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . (string) filesize("{$file}"));
$fd = fopen($file, "rb");
fpassthru($fd);
/*function xlsBOF()
{
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
function xlsEOF()
{
echo pack("ss", 0x0A, 0x00);
return;
}
function xlsWriteNumber($Row, $Col, $Value)
{
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
function xlsWriteLabel($Row, $Col, $Value )
{
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
//Send header
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=user_report.xls");
header("Content-Transfer-Encoding: binary ");
xlsBOF();
xlsWriteLabel(1,0,"No");
//.........这里部分代码省略.........
示例15: builtXLS
public function builtXLS()
{
$this->load->language('marketing/newsletter');
$this->load->model('marketing/newsletter');
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_email'])) {
$url .= '&filter_email=' . urlencode(html_entity_decode($this->request->get['filter_email'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_date_added_begin'])) {
$url .= '&filter_date_added_begin=' . $this->request->get['filter_date_added_begin'];
}
if (isset($this->request->get['filter_date_added_end'])) {
$url .= '&filter_date_added_end=' . $this->request->get['filter_date_added_end'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
require_once DIR_SYSTEM . "library/excel/excelwriter.inc.php";
$name_file = DIR_APPLICATION . 'controller/marketing/newsletter_report/newsletter_report.xls';
if (isset($this->request->get['filter_name'])) {
$filter_name = $this->request->get['filter_name'];
} else {
$filter_name = null;
}
if (isset($this->request->get['filter_email'])) {
$filter_email = $this->request->get['filter_email'];
} else {
$filter_email = null;
}
if (isset($this->request->get['filter_date_added_begin'])) {
$filter_date_added_begin = $this->request->get['filter_date_added_begin'];
} else {
$filter_date_added_begin = null;
}
if (isset($this->request->get['filter_date_added_end'])) {
$filter_date_added_end = $this->request->get['filter_date_added_end'];
} else {
$filter_date_added_end = null;
}
$filter_data = array('filter_name' => $filter_name, 'filter_email' => $filter_email, 'filter_date_added_begin' => $filter_date_added_begin, 'filter_date_added_end' => $filter_date_added_end);
$results = $this->model_marketing_newsletter->getNewsletters($filter_data);
$excel = new ExcelWriter($name_file);
if (count($results) > 0) {
$myArr = array('Nome', 'Email', 'IP', 'Data de Cadastro');
$excel->writeLine($myArr, 'title');
foreach ($results as $result) {
$myArr = array($result['name'], $result['email'], $result['ip'], date('d/m/Y H:i:s', strtotime($result['date_added'])));
$excel->writeLine($myArr, 'rows');
}
$excel->close();
$this->response->redirect(HTTPS_SERVER . 'controller/marketing/newsletter_report/newsletter_report.xls');
} else {
$this->response->redirect($this->url->link('marketing/newsletter', 'warning=Nenhum registro foi encontrado&token=' . $this->session->data['token'] . $url, 'SSL'));
}
}