์๋
ํ์ธ์ ์ฌ๋ฌ๋ถ, ๋ด๋ณด๋ธ CSV ํ์ผ์ ๋ฐ์์ง๋ง ๋ชจ๋ ์
๋ฐ์ดํฐ์ ๋ฐ์ดํ๊ฐ ์์ต๋๋ค. CSV๋ก ๋ด๋ณด๋ผ ๋ ๋ฐ์ดํ๋ฅผ ์ ๊ฑฐํ๋ ๋ฐ ๋์์ ์ค ์ ์์ต๋๊น? ์ฌ๊ธฐ ์:
"20150521","62549","2492","","16.52","1.98","0","0","0","","922330816001","","","P ","","2492"
"20150521","71343","2493","","8.26","0.99","0","0","0","","922330816001","","","P ","","2493"
๋๋ ์ด๊ฒ์ ์ํ๋ค..
20150521,62549,2492,,16.52,1.98,0,0,0,,922330816001,,,P,,2492
20150521,71343,2493,,8.26,0.99,0,0,0,,922330816001,,,P,,2493
๊ฐ์ฌํฉ๋๋ค
๋ด ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
//generating .csv
$csv = Excel::create($conciliacion->nombre, function($excel){
$excel->sheet('Lista', function($sheet) {
$empresa = Empresa::find(1);
$conciliacion = Session::get('conciliacion');
Session::forget('conciliacion');
$fecha_conciliacion = $conciliacion->fecha;
$i = 1;
$ordenes = Orden::whereBetween('fecha_emision', array($fecha_conciliacion.' 00:00', $fecha_conciliacion.' 23:59'))->get();
var_dump($ordenes);
foreach($ordenes as $o){
$sheet->row($i, array(
(int)date("Ymd", strtotime($o->fecha_emision)),
(int)date("His", strtotime($o->fecha_emision)),
(int)$o->numero_orden,
(int)$o->tipo_tarjeta,
(float)number_format(($o->subtotal_12+$o->subtotal_0), 2),
(float)number_format($o->iva, 2),
(float)'0.00',
(float)number_format($o->intereses/100, 2),
(float)number_format($o->total_intereses/100, 2),
(int)$o->numero_autorizacion,
(int)$empresa->ruc,
(int)$o->tipo_credito,
(int)$o->meses_credito,
'P',
'',
(int)$o->numero_orden,
));
$i++;
}
});
})->export('csv');
๊ตฌ์ฑ์์ enclosure
์ค์ ์ ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค. https://github.com/Maatwebsite/Laravel-Excel/blob/master/src/config/excel.php#L129
ํ๋ฅญํฉ๋๋ค. Laravel์์ ๊ตฌ์ฑ ํ์ผ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ../vendor/maatwebsite/excel/src/config/csv.php ๊ฐ์ฌํฉ๋๋ค.
๊ตฌ์ฑ์ ๋ํ ์ถ๊ฐ ๋ฌธ์๊ฐ ํ์ํฉ๋๋ค. ์ด์จ๋ ๋ค์ ํ ๋ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
Laravel 4๋ผ๋ฉด ๊ทธ๋ ์ต๋๋ค. ๋ด๊ฐ ์ค ์๋ ๊ตฌ์ฑ์ ์ฒ๋ฆฌํ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ด ์๋ Laravel 5์ ๋ํ ๊ฒ์ ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๊ตฌ์ฑ์์
enclosure
์ค์ ์ ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค. https://github.com/Maatwebsite/Laravel-Excel/blob/master/src/config/excel.php#L129