CakePHPã®åå¼·ä¼ã§ãè±èªã«è² ããã³ã¼ããã°ãã°ãèªãã§ãããï¼ã¨ãã話ããã£ãã®ã§ãBakeryã®ä¸ãè¦ãã¦è¦ã¤ããã½ã¼ã¹ãåããã¨ããã®ããã£ã¦ã¿ã¾ããã ä»åã¯CSVãã¡ã¤ã«ãfindä¸çºã§èªãã§ãã¾ããã¨ããã¤ãã§ãã å ã¯SiegfriedHirschãããä½æããã¾ããã CSVãã¡ã¤ã«ããã¼ã¿ãã¼ã¹ã£ã½ãããçºã«ãããã¤ãæºåããã¾ãã CakePHPã®åå¼·ä¼ã§ãè±èªã«è² ããã³ã¼ããã°ãã°ãèªãã§ãããï¼ã¨ãã話ããã£ãã®ã§ãBakeryã®ä¸ãè¦ãã¦è¦ã¤ããã½ã¼ã¹ãåããã¨ããã®ããã£ã¦ã¿ã¾ããã ä»åã¯CSVãã¡ã¤ã«ãfindä¸çºã§èªãã§ãã¾ããã¨ããã¤ãã§ãã å ã¯SiegfriedHirschãããä½æããã¾ããã CSVãã¡ã¤ã«ããã¼ã¿ãã¼ã¹ã£ã½ãããçºã«ãããã¤ãæºåããã¾ãã 1./models/datasources/csv_source.phpãè¨ç½®ããã
CSVããã¼ã¿ã½ã¼ã¹ã¨ãã¦æ±ããããã«ãã CsvSource ã¨ãããã©ã°ã¤ã³ãããã¾ãã ã³ã³ããã¼ã©ã¼ã® $uses ã«CSVã使ãã¢ãã«ãè¨å®ããããBake 㧠View ãç¼ãéã«ã¨ã©ã¼ãåºãããã«ãªã£ã¦ãã¾ãã¾ããã CsvSource ã¨ã¯ http://github.com/cakephp/datasources CakePHP ã® github ã« datasources ã¨ãããªãã¸ããªãããã¾ãã CsvSource ãã¯ãããããã¤ãã®ãã¼ã¿ã½ã¼ã¹ãæ±ãããã©ã°ã¤ã³ã«ãªã£ã¦ã¾ãã ç°å¢ Mac Mac OS X 10.5.8ï¼Leopardï¼ MAMP 1.7.2 CakePHP 1.3.0 php 5.2.6 ã¨ã©ã¼ã®ç¶æ³ <?php class Csv extends AppModel{ public $useDbConfig = 'csv'; } CsvSo
CakePHPã§csvã¨ã¯ã¹ãã¼ãããã«ã¯ä¾¿å©ãªcsvãã«ãã¼ãç¨æããã¦ãã¾ãã csvãã«ãã¼ãã³ãã¼ã¢ã³ããã¼ã¹ããã¦ãcsv.phpã¨ãããã¡ã¤ã«åã«ãã¾ãã ãã®å¾ãviews/helpers/é ä¸ã«é ç½®ãã¾ãã ã³ã³ããã¼ã©å´ã¯ä»¥ä¸ã®ããã«è¨è¿°ãã¾ãã ãããã°ã¢ã¼ãã«ãã¦ããã¨ãããã°ãã¨ã¯ã¹ãã¼ããããããããããã°ã¢ã¼ãããªãã«ãã¾ãã function csvexport() { var $helpers = array('Csv'); Configure::write('debug', 0); // ãããã°ãªã $this->layout = false; $this->set('data', $this->User->find('all')); } ãã¥ã¼å´ã¯ãcsvexport.ctpã¨ãããã¡ã¤ã«ãä½æãã以ä¸ã®ããã«è¨è¿°ãã¾ãã addGridã®ç¬¬äºå¼æ°ã§ã
æ±äº¬é½å°æ±åºã§é»ã ã¨ã¦ã§ãã§ãµã¼ãã¹ãéçºãã¦ããæ ªå¼ä¼ç¤¾ã¢ã¹ããããªã®ãã¼ã ãã¼ã¸ã§ãã
â CSVãã«ãã¼ã®ã¤ã³ã¹ãã¼ã« ã¾ããCakePHP1.2ã§ä½¿ããCSVãã«ãã¼ãè½ã¨ãã ãPHP5ã http://bakery.cakephp.org/articles/view/csv-helper-php5 ãPHP4äºæã http://ifunk.net/cakephp/helpers/csv.php.txt ãªã³ã¯å ã¯PHP5ã¨ãPHP4äºæã®2種é¡ããããä»å念ã®ããPHP4äºæã使ã£ã¦ã¿ãã ãã¼ã¸ã表示ãããã³ãã¼ãã¦ãcsv.phpã¨ããååã§ä¿åããã â»Webãµã¼ããPHP5ã®ã¿ã¤ã³ã¹ãã¼ã«ããã¦ããã®ã§ããã°ãèºèºç¡ãPHP5çãé¸ã¶ã¨è¯ãã ã¨ããããã§ãcsv.phpãã¡ã¤ã«ã [/Path/To/CakePHP/App/views/helpers/csv.php] ã«è¨ç½®ããã ããã§CSVãã«ãã¼ã®ã¤ã³ã¹ãã¼ã«ã¯å®äºã â CSVãã«ãã¼äºåæºå ã³ã³ã
CakePHP2対å¿ããã®CSVãã«ãã¼ã¯ãã¡ãã§ãã FastCSV ãããã ã¨ãæååãã§åã£ã¤ãé£ãCSVé¢é£ æåã«è¨ã£ã¦ããã¾ããCSV Helperã¯ã¨ã¦ãæãã使ããããã§ãã âCSV Helper (PHP 5) ã¶ãã¨ããã¥ã¢ã«ãè¦ã¦ããæãéãã®å®è£ ã»åºåã¾ã§30åç¨åº¦ã§ããã ããã§ã¯ããã£ãã使ãæ¹ã説æãã¾ãã ï¼ï¼ã¾ãããapp/views/helpers/ãã«ãcsv.phpããä½æã㦠以ä¸ã®ã½ã¼ã¹ããã®ã¾ã¾ã³ãããã¦ãã ããã <?php class CsvHelper extends AppHelper { var $delimiter = ','; var $enclosure = '"'; var $filename = 'Export.csv'; var $line = array(); var $buffer; function CsvHelp
Excelãªã©ã®è¡¨è¨ç®ã½ããã§å©ç¨ã§ããããCSVãã¡ã¤ã«ã®ã¤ã³ãã¼ãæ©è½ã»ã¨ã¯ã¹ãã¼ãæ©è½ãå®è£ ããã UTF-8ããShift-JISã«å¤æããã¨æååãããã®ã§ãCSVãã¡ã¤ã«ã§ã¨ã¯ã¹ãã¼ãããéã®ã¨ã³ã³ã¼ãã£ã³ã°ãSJIS-winã«ããã ã¤ã³ãã¼ãããéã¯ãSJIS-winããUTF-8ã«å¤æãã¦ããã¼ã¿ãã¼ã¹ã«ä¿åããã UTF-8ã®BOMãåé¤ããã CSVãã¡ã¤ã«ã®è¦åºãè¡ã®é ç®åã¯ããã¼ã¿ãã¼ã¹ã®ãã£ã¼ã«ãã¨å¯¾å¿ãããæ¥æ¬èªã«ããã PHPã®fgetcsv()ã¯ãå¤ã®1æåç®ãæååãããã¨ãããã°ãããã®ã§ãæååãããªãããå¦çãæ½ãã ä¾ï¼ECãµã¤ãã®ååã®ã¤ã³ãã¼ãæ©è½ã»ã¨ã¯ã¹ãã¼ãæ©è½ãå®è£ â app/config/csv.php <?php function getCsvHeader($pattern = null) { $arr = array( 'id'
Posted on | 9 æ 12, 2008 | ããï¼ãã£ã¦ç¨ã®äºã§ã¯ãªãã®ã§ãããæè¿ããä»äºã§ãã£ã¦ããã®ã§è¦ãæ¸ãã®çºã«ã¡ã¢ãã¦ããã¾ãã å©ç¨ãã¦ããç°å¢ã¯cakePHP1.2ã§PHP5ã§ããä»åã¯ä»®ã«ãsitesãã¼ãã«ã«ç»é²ããã¦ãããã¼ã¿ãä¸æ¬ã§CSVã«ãã¦ãã¦ã³ãã¼ãããæ³å®ã§ãµã³ãã«ãã¦ã¿ã¾ãã 1, Csvç¨ãã«ãã¼ã®å°å ¥ /views/helpersã«csv.phpã¨è¨ããã¡ã¤ã«ãä½æãããã¡ãã®ã³ã¼ããã³ãããã¾ãw 2, ã³ã³ããã¼ã©ã¼ã®ä½æ ãããªæãã«ä½æãã¾ãã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}