0

I am using this code for reading data from any file but if i want to read data from excel sheet then what should i do?

<?php if(isset($_POST['submit'])){ $cir="certificate"; if(!is_dir($cir)){ mkdir($cir); } $image1=$_FILES['cir']['name']; $image=$_FILES['cir']['tmp_name']; $server_path=$cir.'/'.basename($_FILES['cir']['name']); $s=move_uploaded_file($image,$server_path); if($s){ //echo "successfully uploaded."; $file_open=fopen("$cir/$image1","r"); $file_read=fread($file_open,filesize("$cir/$image1")); echo $file_read; //$data = substr(strrchr("$cir/$file_read", ","),5 ); echo $file_read; }else{ echo "problem in uploading."; } } ?> <html> <body> <form name="form" method="post" enctype="multipart/form-data"> <input type="file" name="cir" /><br /> <input type="submit" name="submit" value="submit" /> </form> </body> </html> 

Excel sheet containing various shells like Name-XYZ, s.no-123 etc. I want that xyz should be put on a variable and 123 should be on another variable. What will be code in PHP?

0

2 Answers 2

2

You can use PHPExcel library for same.

Sign up to request clarification or add additional context in comments.

Comments

1

If your site involves reading excel files extensively then go for a library like https://github.com/PHPOffice/PHPExcel . It supports both xls and xlsx types.

2 Comments

actually it doesn't read/write xslx file types. for those types is better PHPExcel
Yes (as I said). For reading purpose mentioned lib is good as PHPExcel is heavier just for reading purpose. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.