Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7160337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:22:57+00:00 2026-05-28T13:22:57+00:00

For example I’m using such a code: <?php require_once(D:\server/www/cls/PHPExcel.php); require_once(D:\server/www/cls/PHPExcel/IOFactory.php); $objPHPExcel = new PHPExcel();

  • 0

For example I’m using such a code:

<?php

    require_once("D:\server/www/cls/PHPExcel.php");
    require_once("D:\server/www/cls/PHPExcel/IOFactory.php");

    $objPHPExcel = new PHPExcel();

    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', 'HeaderB');    
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C2', 'HeaderC');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('D2', 'HeaderD');    
    ob_end_clean();

    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition: attachment;filename="report.xlsx"');

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    ob_end_clean();

    $objWriter->save('php://output');
?>

It downloads report.xlsx file and doesn’t display it in a browser. How do I make it?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:22:58+00:00Added an answer on May 28, 2026 at 1:22 pm

    Remove this line…

    header('Content-Disposition: attachment;filename="report.xlsx"');
    

    The user must have something in their browser capable of viewing the Excel file too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example class code: <?php class example { public function forExample() { return true; }
Example using Namespace in PHP... use \MyLibrary\Registry; use \MyLibrary\User; use \MyLibrary\Request; namespace MyLibrary\Base {
Example int *ptr; *ptr = 1000; can I catch memory access violation exception using
Example code: # -*- coding: utf-8 -*- from functools import wraps class MyClass(object): def
Example: <div id=sampleimage> ***Stream or Serialize JPEG Image from Server Here w/o Sending another
Example: <div style=font-size:15px;>first matched here</div> I want to have PHP find the information in
Example: <select id=myselect> <option value=A>First</option> <option value=B>Second</option> <option value=C selected=selected>Third</option> <option value=D>Fourth</option> </select> Using
Example: Foo make_foo(int a1, int a2){ Foo f(a1,a2); return f; } Having seen such
Example: Is the following code valid against the JSON Spec ? { precision: "zip"
Example: I navigate to http://www.stackoverflow.com with my web browser control there's a link to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.