PDA

View Full Version : پشتیبانی از فارس در اکسل



rash44
پنج شنبه 04 تیر 1388, 15:24 عصر
سلام
من از این کلاس برای تولید فایل اکسل استفاده می کنم



<?php
#### Roshan's very simple code to export data to excel
#### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
#### if you find any problem contact me at http://roshanbh.com.np
#### fell free to visit my blog http://php-ajax-guru.blogspot.com
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->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: text/html; charset=utf-8");
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";


}
}
?>


به جای کاراکترهیا فارسی توی فایل اکسل کاراکتر هیا نامفهوم قرار می گیره
لطفا کد رو اصلاح کنید

yaqubian
پنج شنبه 04 تیر 1388, 18:58 عصر
دوست عزیز
یه جستجو بفرمایید قبلا یه تاپیک ایجاد شده.
موفق باشید

rash44
جمعه 05 تیر 1388, 09:02 صبح
دوست عزیز
یه جستجو بفرمایید قبلا یه تاپیک ایجاد شده.
موفق باشید

سلام
متاسفانه سرچ کردم چیزی پیدا نکردم