我的數據看起來像這樣(點擊查看頁面源代碼之後),如何將PHP數組寫入xls文件?
date \t new_users \t cpm \t earnings \t total_pushes \t avail_users \t application \t
2011-03-31 \t 336933 \t $5.27 \t $10151.2 \t 1925244 \t 1905744 \t Play Movies \t
2011-03-31 \t 205070 \t $5.12 \t $5810.26 \t 1134946 \t 1118354 \t Watch Movies or TV Shows \t
我爆與「\ T」定的數組,然後動態寫入xls文件.Problem這個是所有的內容只是存在在xls文件的第一列中。
我在代碼中缺少什麼,xls文件是否需要數據格式?
\ t不應該是visble,你應該會看到一個[標籤。此外,這不會是有效的XLS,而是一個TSV文件。但是,如果你展示更多的代碼,我們可以提供更多的幫助。 – 2011-12-21 19:11:33
@saratis是對的。檢查你的代碼,看看你是否圍繞'\ t'使用雙引號或單引號。它應該是「雙引號」。 – FakeRainBrigand 2011-12-21 19:24:12
$ glue ='\ t'; $ h = array('date','news','cpm','earnings','pushes','count','app'); $ top = implode(「$ glue」,$ h)。「\ n」; $ d =陣列( \t '0'=>數組( '2011', '3', '5.2', '10151.2', '1925244', '1905744', '播放電影'), \t「1 '=> array('2011','2','35.2','10151.2','1134946','1118354','觀看電影或電視節目') \t ); $ f_c =''; foreach($ d as $ ed){ \t $ cs = null; $ cs = implode(「$ glue」,array_values($ ed)); $ f_conts。= $ s。 「\ n」 個; } $ f_cs = $ top。$ F_C; $ f ='s.xls'; header(「Content-type:application/vnd.ms-excel」); header(「Content-disposition:filename =」。$ f); print_r($ fn) – 2011-12-21 19:51:48