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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:12:53+00:00 2026-06-16T04:12:53+00:00

i have export a excel sheet which will collect data from my customer table

  • 0

i have export a excel sheet which will collect data from my customer table (Mysql database) now i want to format it with column color.

here is my code to export excel sheet….

<?php

ob_start();
session_start();
include("include/session.php");
include("common_function.php");
//connect the database

$customer_id=$_GET['pid'];
//Enter the headings of the excel columns
$contents="Sr.,Agent Name,Contact Person,Contact Number,Password,Deal With Customer,References,Time to reach,Package Offered,Mode of Payment,Note,NEAREST CROSS STREET,DATE OF BIRTH\n"; 

//Mysql query to get records from datanbase
//You can customize the query to filter from particular date and month etc...Which will depends your database structure.

$sql = "SELECT id,agent_id,fname1,mobile_no,password,fname,rentfrom,cheque_no,package_id,monthly_monitoring,final_comment,cross_street,dob1 FROM customer WHERE `id`='$customer_id'";

$user_query = mysql_query($sql);

//While loop to fetch the records
while($row = mysql_fetch_array($user_query))
{
$contents.=$row['id'].",";
$contents.=$row['agent_id'].",";
$contents.=$row['fname1'].",";
$contents.=$row['mobile_no'].",";
$contents.=$row['password'].",";
$contents.=$row['fname'].",";
$contents.=$row['rentfrom'].",";
$contents.=$row['cheque_no'].",";
$contents.=$row['package_id'].",";
$contents.=$row['monthly_monitoring'].",";
$contents.=$row['final_comment'].",";
$contents.=$row['cross_street'].",";
$contents.=$row['dob1']."\n";
}

// remove html and php tags etc.
$contents = strip_tags($contents); 

//header to make force download the file

header("Content-Disposition: attachment; filename=Sale_report".date('d-m-Y').".csv");
print $contents;

?>

now i want to color my first row…

  • 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-16T04:12:55+00:00Added an answer on June 16, 2026 at 4:12 am

    Heay Cnik,
    Ayyappan Sekar is right.
    PHPExcel is a library that can be used to generate xls( and many other formats ) file. Its purpose is to generate a file and not sending it on some id.

    What you can do is, first generate a file using PHPExcel library and save it somewhere.
    For sending email to some id, you can use http://php.net/manual/en/function.mail.php‘>mail function. However, its little complex to send emails with attachments using php’s mail function though not very difficult.

    Refer the links given below:
    1] http://www.shotdev.com/php/php-mail/php-send-email-upload-form-attachment-file/
    2] Attach File Through PHP Mail (refer to the answer of asprin)
    3] http://www.texelate.co.uk/blog/send-email-attachment-with-php/

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

Sidebar

Related Questions

I want to export data from mysql tables to excel sheet. I am using
I have excel sheet with data which I want to get Levenshtein Distance between
Can i export a data from a table to an excel sheet, using javascript?
I have an excel sheet with data and want to export it to a
I have a function to export data from excel to Dataset which is as
I have an Excel table with some data that I would like to export
I have been thinking of a way to export data from SQL to Excel.
I have been trying to export the content of mysql database to excel using
I'm trying to export data from my models to an excel spreadsheet. I have
I have to export large amount of data (>100000 documents) from lotus to excel

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.