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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:23:48+00:00 2026-06-14T02:23:48+00:00

I would like to write into a csv file using PHPEXCEL in the following

  • 0

I would like to write into a csv file using PHPEXCEL in the following format. The class in bold and a space after every class group.

Format wanted

But i have not been able to find a way to do it.

Here is what I could do.

The format i have

I generate the data from an sql and loop thought it. Here is my code

$sql="SELECT * FROM table ORDER BY typeclass";
$query=mysql_query($sql);

$check='';
$i=1;
while($row=mysql_fetch_assoc($query))
{       
    if($row['class']!=$check)
    {
        $objPHPExcel->getActiveSheet()->setCellValue('A'.$i,$row['Class']);
        $check=$row['class'];
    }

    $objPHPExcel->getActiveSheet()->setCellValue('B' .$i,$row['Name']);
    $objPHPExcel->getActiveSheet()->setCellValue('C' .$i,$row['score']);

    $i++;                   
}

Can anyone help me get the desired output.

  • 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-14T02:23:50+00:00Added an answer on June 14, 2026 at 2:23 am

    How to format a cell bold:

    $styleArray = array('font' => array('bold' => true));
    
    $objPHPExcel->getActiveSheet()->getStyle('A1')->applyFromArray($styleArray);
    

    You can insert a new Row after inserting the class name.

     if($row['class']!=$check)
     {
            $objPHPExcel->getActiveSheet()->setCellValue('A'.$i,$row['Class']);
            $check=$row['class'];
    
            // Merge the cells with the class name
            $objPHPExcel->getActiveSheet()->mergeCells('A'.$i.':B'.$i);
    
            $i++; // Next Row
     }
    

    Then you can put the name and score into column A and B:

    $objPHPExcel->getActiveSheet()->setCellValue('A' .$i,$row['Name']);
    $objPHPExcel->getActiveSheet()->setCellValue('B' .$i,$row['score']);
    

    That should do all the trick. For further questions using PHPEXCEL youre able to contact me via email.

    By the way, poor Simon 🙁

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

Sidebar

Related Questions

I would like to write into a log file from the kernel space. I
I would like to write an abstract base class class func_double_double_t : public unary_function<double,
I would like to write a hql query using a dynamic instantiation with a
How do I dynamically add a PDO statement into array? I would like write
I wrote a macro that imports a CSV file into my spreadsheet, using a
I would like to write a C# method that would transform any title into
I would like to write a query that merges two Access 2000 databases into
I have a csv file encoded in UCS-2 Little Endian which I would like
I have a csv file with dump data of table and I would like
I would like to write a function that creates a plot of a set

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.