PHP code example of mostafazs / php-excel2any

1. Go to this page and download the library: Download mostafazs/php-excel2any 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/ */

    

mostafazs / php-excel2any example snippets



xcel2any\excel2any;
use excel2any\RealRead;
use excel2any\Formats\FormatCSV;
use excel2any\Saver\SaveCSV;
$filename = __DIR__."/Products.xlsx";//Excel file name
$config = [
    "startRow"=>1,//Excel file start row
    "endRow"=>37,//Excel file end row
    "inputFileType"=>"Xlsx",//dont change
    "inputFileName"=>$filename,//Excel file name
    "sheetname"=>"Sheet1",//Default sheet name
    "range_start"=>"A",//Column start from
    "range_end"=>"AM",//Column end to
];

$excel = new excel2any();
//Read excel file
$excel_read = new RealRead($config);
$readed = $excel_read->Read();
//Select Format Output Format..and pass read data
$csvFormat = new FormatCSV();
$csvdata = $csvFormat->Format($readed);
//Save Saver Class
$savecsv = new SaveCSV();
//Save File..pass $savecsv , $csvdata and input file name
$result = $excel->convert()->save($savecsv,$csvdata,$config['inputFileName']);
if($result){
    echo "CSV File created";
}
json
""mostafazs/php-excel2any": "1.*"
}