Hello Man
Hello Man

Reputation: 701

Delete row in excel while exporting using php

I have a php file where i export data from database to excel using

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment;Filename=cel.xls");

Now, i want to delete the first row of the file before it is exported. Can anyone help me on this?

Upvotes: 0

Views: 573

Answers (1)

Arun
Arun

Reputation: 760

you can try this sample code

if(isset($_POST['Upload'])) {

    if(move_uploaded_file($_FILES["file"]["tmp_name"], "files/" . $_FILES["file"]["name"])) {
        $file_target="files/" . $_FILES["file"]["name"];
        $data->read($file_target);  
    // $x = 2 indicates second row of the excel sheet //
for($x = 2;$x<=count($data->sheets[0]["cells"]); $x++) { 
    $first_cell = $data->sheets[0]["cells"][$x][1];
    $second_cell = $data->sheets[0]["cells"][$x][2];
    $third_cell = $data->sheets[0]["cells"][$x][3];
    }
  }
}

Upvotes: 1

Related Questions