本文整理汇总了PHP中Excel::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Excel::filter方法的具体用法?PHP Excel::filter怎么用?PHP Excel::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Excel
的用法示例。
在下文中一共展示了Excel::filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
/* $input = array_except(Input::all(), '_method');
$file_path = $input['excel_file']; */
/* $target_dir = public_path()."\uploads\eod_data\\";
$target_file = $target_dir . basename($_FILES["excel_file"]["name"]); */
//$target_file = 'C:\xampp\htdocs\sharemarket_app\uploads\eod_data\Copy (2) of fo28AUG2015bhav.csv';
$target_file = 'uploads/eod_data/fo28AUG2015bhav - Copy (2).csv';
//$target_file = 'C:\xampp\htdocs\sharemarket_app\uploads\eod_data\fo28AUG2015bhav - Copy.csv';
/* if (move_uploaded_file($_FILES["excel_file"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["excel_file"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
die;
} */
set_time_limit(6000);
$data = array();
\Excel::filter('chunk')->load($target_file)->chunk(250, function ($results) use(&$data) {
$results_array = $results->toArray();
//print_r($results_array);
$i = 1;
foreach ($results_array as $row) {
//print_r($row);die;
$datetime = strtotime($row['expiry_dt']);
$datetime *= 1000;
$data[] = "[{$datetime}, {$row['open']}, {$row['high']}, {$row['low']}, {$row['close']}]";
//print_r($data);die;
}
//print_r($data);die;
});
//print_r($data);
//die;
return View::make('eod.index')->with('data', $data);
}
示例2: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$dir = $_SERVER['DOCUMENT_ROOT'] . "public/toUpload/";
$doc = $this->argument('table') . '.xlsx';
try {
Excel::filter('chunk')->load($dir . $doc)->chunk(250, function ($reader) {
if ($this->argument('table') == 'extracts') {
Extract::insert($this->validate($reader));
} else {
ExcelDaily::insert($this->validate($reader));
}
});
$message = "El archivo " . $doc . " se ha guardado en la base de datos.";
} catch (Exception $e) {
$message = "No se ha guardar " . $doc . ". Intenta subirlo de nuevo.";
}
/*Mail::send('emails.excel', ['msn' => $message], function ($m) use($message){
$m->to('sanruiz1003@gmail.com', 'Creditos Lilipink')->subject('Notificación Lilipink');
});*/
Mail::send('emails.excel', ['msn' => $message], function ($m) use($message) {
$m->to('carterainnova@innova-quality.com.co', 'Creditos Lilipink')->subject('Notificación Lilipink');
});
unlink($dir . $doc);
if (!is_dir($dir)) {
rmdir($dir);
}
}
示例3: fire
public function fire()
{
$dir = $_SERVER['DOCUMENT_ROOT'] . "public/toUpload/";
try {
Excel::filter('chunk')->load($dir . 'data.xlsx')->chunk(250, function ($reader) {
foreach ($reader->toArray() as $data) {
$user = User::where('identification_card', $data['cedula'])->first();
if (!$user) {
$user = User::create(['identification_card' => $data['cedula'], 'name' => $data['nombre'], 'user_name' => str_replace(' ', '.', $data['nombre']), 'email' => $data['email'] ? $data['email'] : 'Sin registro', 'address' => $data['direccion'] ? $data['direccion'] : 'Sin registro', 'residency_city' => $data['ciudad'] ? $data['ciudad'] : 'Sin registro', 'phone' => $data['tel1'] ? $data['tel1'] : 'Sin registro', 'mobile_phone' => $data['tel2'] ? $data['tel2'] : 'Sin registro', 'document_type' => 0, 'roles_id' => 4]);
}
$credit = CreditRequest::where('user_id', intval($user->id))->first();
if (!$credit) {
$c = new CreditRequest();
$c->user_id = intval($user->id);
$c->value = intval($data['limitecredito']);
$c->state = 1;
$c->location = 3;
$c->responsible = 18;
$c->save();
} else {
$credit->value = $data['limitecredito'];
$credit->save();
}
}
});
echo $message = "El archivo se ha guardado en la base de datos.";
} catch (Exception $e) {
echo $message = "No se ha guardar . Intenta subirlo de nuevo.";
}
Mail::send('emails.excel', ['msn' => $message], function ($m) use($message) {
$m->to('sanruiz1003@gmail.com', 'Creditos Lilipink')->subject('Archivos actualizados');
});
array_map('unlink', glob($_SERVER['DOCUMENT_ROOT'] . "/toUpload/*"));
}