PHP code example of lovefc / xlsxtocsv

1. Go to this page and download the library: Download lovefc/xlsxtocsv library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lovefc / xlsxtocsv example snippets




ig = ['path' => 'D:/xlsx', 'output' => 'D:/csv'];

$obj = new lovefc\XlsxToCsv($config);

$obj->run();


php run.php

// 只提取手机号
$callback = function ($row, $sheetName) {
    $str = implode(',', $row);
	$pattern = '/1[0-9]\d{9}/';
	preg_match($pattern,$str,$arr);	
	$phone = $arr[0] ?? 0;
	if($phone == 0){
		return false;
	}	
    return $phone;
};

$config = ['path' => '/www/1.xlsx', 'outputFile' => '/www/1.csv', 'callBack'=>$callback ];

$obj = new lovefc\XlsxToCsv($config);

$obj->run();