<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LAVA WORLD &#187; 乱码</title>
	<atom:link href="http://www.vpnall.com/tag/%e4%b9%b1%e7%a0%81/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vpnall.com</link>
	<description>又一个森林Q群:52130297(IT聊天群)</description>
	<lastBuildDate>Fri, 03 Sep 2010 06:42:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>php导出excel范例 解决乱码</title>
		<link>http://www.vpnall.com/2009/07/php%e5%af%bc%e5%87%baexcel%e8%8c%83%e4%be%8b-%e8%a7%a3%e5%86%b3%e4%b9%b1%e7%a0%81/</link>
		<comments>http://www.vpnall.com/2009/07/php%e5%af%bc%e5%87%baexcel%e8%8c%83%e4%be%8b-%e8%a7%a3%e5%86%b3%e4%b9%b1%e7%a0%81/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 01:50:47 +0000</pubDate>
		<dc:creator>lava</dc:creator>
				<category><![CDATA[代码]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[乱码]]></category>

		<guid isPermaLink="false">http://www.vpnall.com/?p=313</guid>
		<description><![CDATA[phpexcel貌似强大,不过很复杂.唯有用简单的方法,试了几个代码.能导出excel,但是会出现乱码.最后还是用iconv才解决掉.另外header(&#8220;Content-type:charset=utf-8&#8243;);是无法解决的.

1
2
3
4
5
6
7
8
9
10
11
12
... ]]></description>
			<content:encoded><![CDATA[<p>phpexcel貌似强大,不过很复杂.唯有用简单的方法,试了几个代码.能导出excel,但是会出现乱码.最后还是用iconv才解决掉.另外header(&#8220;Content-type:charset=utf-8&#8243;);是无法解决的.</p>

<div class="wp_codebox"><table><tr id="p3132"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p313code2"><pre class="php" style="font-family:monospace;"><a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Pragma: public&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expires: 0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: application/force-download&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//header(&quot;Content-type:charset=utf-8&quot;);</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: application/download&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;;</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: attachment;filename=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'time1'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'time2'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.xls &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Transfer-Encoding: binary &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
xlsBOF<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xlsWriteLabel<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;文字测试&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xlsWriteNumber<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">123</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xlsEOF<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #000000; font-weight: bold;">function</span> xlsBOF<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/pack"><span style="color: #990000;">pack</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ssssss&quot;</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x809</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x8</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x10</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> xlsEOF<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/pack"><span style="color: #990000;">pack</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ss&quot;</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0A</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> xlsWriteNumber<span style="color: #009900;">&#40;</span><span style="color: #000088;">$Row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Col</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/pack"><span style="color: #990000;">pack</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sssss&quot;</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x203</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">14</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Col</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/pack"><span style="color: #990000;">pack</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> xlsWriteLabel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$Row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Col</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Value</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$Value</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/iconv"><span style="color: #990000;">iconv</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;gb2312&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//由于网页编码是UTF-8,需要用iconv转码.否则乱码</span>
	<span style="color: #000088;">$L</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$Value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/pack"><span style="color: #990000;">pack</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ssssss&quot;</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x204</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$L</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Col</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$L</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$Value</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


	标签：<a href="http://www.vpnall.com/tag/excel/" title="excel" rel="tag">excel</a>, <a href="http://www.vpnall.com/tag/php/" title="php" rel="tag">php</a>, <a href="http://www.vpnall.com/tag/%e4%b9%b1%e7%a0%81/" title="乱码" rel="tag">乱码</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.vpnall.com/2009/03/about-yii-php-framework/" title="高性能的PHP框架：Yii PHP Framework (2009-03-18)">高性能的PHP框架：Yii PHP Framework</a> (5)</li>
	<li><a href="http://www.vpnall.com/2010/01/%e7%94%a8js%e7%9a%84json_decode%e8%a7%a3%e5%86%b3json%e4%b8%ad%e6%96%87%e7%bc%96%e7%a0%81%e9%97%ae%e9%a2%98/" title="用js的json_decode解决JSON中文编码问题 (2010-01-26)">用js的json_decode解决JSON中文编码问题</a> (0)</li>
	<li><a href="http://www.vpnall.com/2009/09/%e5%bc%80%e6%ba%90php%e6%95%b0%e6%8d%ae%e8%a1%a8%e7%94%9f%e6%88%90%e7%b1%bbeyedatagrid/" title="开源PHP数据表生成类EyeDataGrid (2009-09-02)">开源PHP数据表生成类EyeDataGrid</a> (0)</li>
	<li><a href="http://www.vpnall.com/2009/05/%e5%bc%80%e6%ba%90php%e5%9b%be%e8%a1%a8%e7%94%9f%e6%88%90%e5%87%bd%e6%95%b0pchart%e5%ba%94%e7%94%a8%e5%ae%9e%e4%be%8b/" title="开源PHP图表生成函数pChart应用实例 (2009-05-30)">开源PHP图表生成函数pChart应用实例</a> (0)</li>
	<li><a href="http://www.vpnall.com/2009/03/use-php-ajax-crossdomainhttp-get/" title="利用PHP实现AJAX跨域HTTP GET (2009-03-12)">利用PHP实现AJAX跨域HTTP GET</a> (4)</li>
	<li><a href="http://www.vpnall.com/2009/07/%e4%bb%80%e4%b9%88%e7%bc%96%e7%a8%8b%e8%af%ad%e8%a8%80%e5%bc%80%e5%a7%8b%e5%a4%9a%e4%ba%ba%e5%ad%a6%e4%b9%a0/" title="什么编程语言开始多人学习? (2009-07-27)">什么编程语言开始多人学习?</a> (0)</li>
	<li><a href="http://www.vpnall.com/2009/03/nginx_apache_mysql_php_memcached_squid/" title="[转]利用nginx+apache+mysql+php+memcached+squid搭建门户网站 (2009-03-09)">[转]利用nginx+apache+mysql+php+memcached+squid搭建门户网站</a> (0)</li>
	<li><a href="http://www.vpnall.com/2009/08/%e8%bd%acphp%e4%b8%ad%e7%9a%84static%e5%92%8cglobal/" title="[转]php中的static和global (2009-08-26)">[转]php中的static和global</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.vpnall.com/2009/07/php%e5%af%bc%e5%87%baexcel%e8%8c%83%e4%be%8b-%e8%a7%a3%e5%86%b3%e4%b9%b1%e7%a0%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
