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 8878571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:44:35+00:00 2026-06-14T19:44:35+00:00

I have an API, which returns CSV Content as response, I wanted to download

  • 0

I have an API, which returns CSV Content as response, I wanted to download at as Excel,
What I tried:

HTML:

<form id="test_form" accept-charset="utf-8" method="POST" action="http://prime.dev/index.php//data/reporting/downloadCSVFile.json"></form>

<a id="downloadcsv" class="min-button-silver">Download to Excel</a>

JavaScript:

jQuery("#downloadcsv").click(function(e){   
    jQuery('#test_form').submit();  
});

PHP

public function downloadCSVFile()
{
    $data = $this->reporting_service->fetchCSV($request); //API request
    header("Content-Type: application/csv");        
    header("Content-Disposition: attachment; filename=test.csv");
    //header("Content-Length: ".$thesize);
    header("Pragma: no-cache");
    header("Expires: 0");
    //Will get the response from API like the below;    
    $data = 'clicks|conversions|ctr|cvr|impressions|invalid_clicks|currency.id
    4220894|127984|.1962348497109191647|.0059484688672145487|2150940063|557193|163';
    
    echo $data;
}

File is downlaoding as test.csv, but opens in Notepad.

  • 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-06-14T19:44:36+00:00Added an answer on June 14, 2026 at 7:44 pm

    If you want a download as Excel you need extra software, something like PEAR_Spreadsheet_Excel,
    because you have to generate extra headers and many other crap!
    But normally if you create a correct CSV-File you can also open it with Excel and it will show all columns seperated like in a normal excel file.

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

Sidebar

Related Questions

I have the win32 API CommandLineToArgvW which returns a LPWSTR* and warns me that
I have the following function in a PHP script, which returns and API call:
I have a PHP RESTful API, which returns JSON objects. I have an Android
I have an API call which returns a double. The double's decimal length can
I have node.js REST api, which returns following object [ { word: word },
In my Web Api project I have a Get method which returns data from
I have parsed an api which returns a unixtimestamp for last updated value. I
I have been building an API which returns XML code. For example, the API
I have a web API which successfully returns an array of blog posts in
I have an ajax call to fetch information from Flickr API which returns JSON

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.