I am using the below code for importing the excel sheet and inserting the data into the database and it's working. There is no issue with it.
Now, I have a column name called content. I am uploading the content in it. so below is the example of the content.
Now after importing the data I am getting the output like. so it's removing the strong part and spacing etc.
I am using the rich text editor and I am displaying the data in it.
function listImport($pdo){
if($_FILES["emplist"]["name"] != '')
{
$allowed_extension = array('csv');
$file_array = explode(".", $_FILES["emplist"]["name"]);
$file_extension = end($file_array);
if(in_array($file_extension, $allowed_extension))
{
$file_name = time() . '.' . $file_extension;
move_uploaded_file($_FILES['emplist']['tmp_name'], $file_name);
$file_type = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file_name);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($file_type);
$spreadsheet = $reader->load($file_name);
unlink($file_name);
$data = $spreadsheet->getActiveSheet()->toArray();
$isheader = 0;
foreach($data as $row)
{
if($isheader > 0) {
$insert_data = array(
':name' => $row[0],
':email' => $row[1],
':content' => $row[2]
);
$query = "INSERT INTO `employee`(`name`, `email`, `content`) VALUES (:name,:email,:content)";
$statement = $pdo->prepare($query);
$statement->execute($insert_data);
}
else {
$isheader = 1;
}
} // foreach
$message = '<div class="alert alert-success">Data Imported Successfully</div>';
} //in_array
else
{
$message = '<div class="alert alert-danger">Only .csv file allowed</div>';
}
}
else
{
$message = '<div class="alert alert-danger">Please Select File</div>';
}
echo $message;
}

