0
오라클 쿼리를 실행하는 응용 프로그램을 작성하고 Excel 형식으로 데이터를 내 보냅니다. 내가 직면하고있는 문제는 Excel 파일의 Tran_code 열이 00
입니다. 내 코드가 실행되고 Excel을 생성, 그것은 하나의 0 대신 인쇄 할 때 배열의 셀 값을 설정 00PHP를 사용하여 Excel에서 열 속성 설정
:
$_SESSION['report_values'][$sno][19]= "'00"; //Setting cell value in an array
Excel로 헤더와 값을 설정하면 파일
include_once("class.export_excel.php");
$excel_obj->setHeadersAndValues($_SESSION['report_header'],$_SESSION['report_values']); //
$excel_obj->GenerateExcelFile();
class.export_excel.php
<?php
class ExportExcel
{
//variable of the class
var $titles=array();
var $all_values=array();
var $filename;
//functions of the class
function ExportExcel($f_name) //constructor
{
$this->filename=$f_name;
}
function setHeadersAndValues($hdrs,$all_vals) //set headers and query
{
//$this->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$this->titles=$hdrs;
$this->all_values=$all_vals;
}
function GenerateExcelFile() //function to generate excel file
{
foreach ($this->titles as $title_val)
{
$header .= $title_val."\t";
}
for($i=0;$i<sizeof($this->all_values);$i++)
{
$line = '';
foreach($this->all_values[$i] as $value)
{
if ((!isset($value)) OR ($value == ""))
{
$value = "\t";
} //end of if
else
{
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
} //end of else
$line .= $value;
} //end of foreach
$data .= trim($line)."\n";
}//end of the while
$data = str_replace("\r", "", $data);
if ($data == "")
{
$data = "\n(0) Records Found!\n";
}
//echo $data;
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$this->filename");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
}
}
?>
작동하지 않습니다! – user3202144
특정 오류/경고 ??? 아니면 파일을 열었을 때 여전히 '0'으로 채닝하고 있다고 말하는 것입니까? 그리고 어떤 데이터 유형을 사용 했습니까? – prodigitalson
오류가 발생하지 않습니다. 파일이 생성되지 않습니다. – user3202144