This project has moved. For the latest updates, please go here.
1
Vote

Creating extra row without data in excel using PHPEXCEL in codeigniter

description

I'm creating an excel file using PHPEXCEL library in codeigniter.

Actually i'm taking the data from one excel file and copying the data from loaded file to new file. Finally a new excel is creating with an extra row without data.

But When I open that file and saving without doing any modification (Simply opening the file and Ctrl+S), all the extra row commas are eliminating. This I have found the major error from the file comparision. I need to eliminate the commas at last programtically. http://codebeautify.org/file-diff

Please check the attachments image.
Image
image description here

First Pane in the image is created file and second pane is after saving the file (Manually opened from location)

Please help how to resolve
    $this->load->library('Excel');
    $objPHPExcel_final = new PHPExcel();
    $objPHPExcel_final->setActiveSheetIndex(0);

   // Loading new data file
    $objPHPExcel = PHPExcel_IOFactory::load($uploaded_file_path);
    $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);

    // Loading excel template for header
    $objPHPExcel_exist = PHPExcel_IOFactory::load($existing_file_path);
    $allDataInSheet_exist = $objPHPExcel_exist->getActiveSheet()->toArray(null, true, true, true);

    // Taking headers from exising and Putting Some Data into new Excel file
$objPHPExcel_final->getActiveSheet()->SetCellValue("G" . $i, date("d/m/Y")); // Application Date
                $objPHPExcel_final->getActiveSheet()->SetCellValue("I" . $i, "Individual"); // Cover Type
                $objPHPExcel_final->getActiveSheet()->SetCellValue("J" . $i, "1"); // No.of Lives
                $objPHPExcel_final->getActiveSheet()->SetCellValue("K" . $i, "1"); // Tenure


       $objWriter_final->save('myfile.xls');!

file attachments

comments