0

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?

2
  • This sample of code is supposed to give us information about your problem ? Are you creating this Excel file ? You are using a library ? Where are the data ? Commented Feb 4, 2015 at 11:13
  • the file amounts to 300 lines of codes and also it is a part of my big website so even if i give u the file u pretty much wont be able to get the full idea behind it. here is the page pastie.org/9885726 . Line #80 should be deleted but if i comment it then there are two field that depend on this line. Any workaround? Commented Feb 4, 2015 at 11:22

1 Answer 1

1

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];
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.