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

  • Home
  • SEARCH
  • 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 8773669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:21:33+00:00 2026-06-13T18:21:33+00:00

I am trying to add data into excel file which is extracted from wordpress

  • 0

I am trying to add data into excel file which is extracted from wordpress database, Actually I am trying to export data (tags) from database into excel file. And I write down a code, but when I click on generate button. This generates empty file.

Please guys check what I am doing wrong.

Codes are below:

if (check_admin_referer('tag-export')) 
{
    $blogname = str_replace(" ", "", get_option('blogname'));
    $date = date("m-d-Y");
    $xls_file_name = $blogname."-exported-tags-".$date;

    $tags = get_terms( 'post_tag' , 'hide_empty=0' );
    $count = count($tags);

    if ( $count > 0 )
    {
        echo 'name' . "\t" . 'slug' . "\n";

        foreach ( $tags as $tag ) 
        {
            echo $tag->name . "\t" . $tag->slug . "\n";
        }
    }

    ob_clean();
    echo $xls_file;

    header( "Content-Type: application/vnd.ms-excel" );
    header( "Content-disposition: attachment; filename=$xls_file_name.xls" );
    exit();
}

The above codes are not writing data into excel file. please check and let me know.

  • 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-13T18:21:35+00:00Added an answer on June 13, 2026 at 6:21 pm

    Just based on your existing code:

    if (check_admin_referer('tag-export')) 
    {
        $blogname = str_replace(" ", "", get_option('blogname'));
        $date = date("m-d-Y");
        $xls_file_name = $blogname."-exported-tags-".$date;
    
        $tags = get_terms( 'post_tag' , 'hide_empty=0' );
        $count = count($tags);
    
        $xls_file = '';
        if ( $count > 0 )
        {
            $xls_file .= 'name' . "\t" . 'slug' . "\n";
    
            foreach ( $tags as $tag ) 
            {
                $xls_file .= $tag->name . "\t" . $tag->slug . "\n";
            }
        }
    
        ob_clean();
        header( "Content-Type: application/vnd.ms-excel" );
        header( "Content-disposition: attachment; filename=$xls_file_name.xls" );
    
        echo $xls_file;
    
        exit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to insert data from excel sheet into database in java. for
I'm trying to write an Excel add-in that can get data from a web
I'm trying to export data from an Excel spreadsheet into a fairly complex relational
i am trying to add data to mysql from excel. i am getting the
I'm trying to add some simple user data into a database via a webpage
I'm trying to bring data into my app from an external file. everything's working
I am trying to insert/add a data into my Database but it seems that
I have an excel file which I am trying to put into mysql. There
I am trying to add user info into a database from a user input
Can anyone please help. I am trying to convert excel data into xml file

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.