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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:01:14+00:00 2026-05-24T08:01:14+00:00

I am trying to generate a XLS sheet with multiple sheets, styles, background colors

  • 0

I am trying to generate a XLS sheet with multiple sheets, styles, background colors and so on using PHP.
Right now all data lie in HTML tables. (Sheet1.html, Sheet2.html …)

Is there any library to convert HTML into one xls file?

Thx

  • 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-24T08:01:15+00:00Added an answer on May 24, 2026 at 8:01 am

    Here is a good PHP Class.

    http://phpexcel.codeplex.com/

    This is a general idea on how to do this. I’m assuming your HTML tables are in a 2-dimensional array. If it’s not yet an array, here’s a good link to do this conversion from HTML table to array in PHP.

    $tabledata = array();
    $tabledata[0][0] = "value stored in A1";
    $tabledata[0][2] = "value stored in B1";
    $tabledata[1][0] = "value stored in A2";
    $tabledata[1][3] = "value stored in B2";
    

    With the first index as the row (excel’s row numbers) and the second index as the column (excel’s column letters). The code below is the first sample code from the site and I modified the data part to insert data from a 2-dimensional array.

    <?php
    /** Error reporting */
    error_reporting(E_ALL);
    
    /** Include path **/
    ini_set('include_path', ini_get('include_path').';../Classes/');
    
    /** PHPExcel */
    include 'PHPExcel.php';
    
    /** PHPExcel_Writer_Excel2007 */
    include 'PHPExcel/Writer/Excel2007.php';
    
    // Create new PHPExcel object
    echo date('H:i:s') . " Create new PHPExcel object\n";
    $objPHPExcel = new PHPExcel();
    
    // Set properties
    echo date('H:i:s') . " Set properties\n";
    $objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
    $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
    $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
    $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
    $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
    
    
    // Add some data
    echo date('H:i:s') . " Add some data\n";
    $objPHPExcel->setActiveSheetIndex(0);
    foreach ($html as $row_index => $row_value) {
      foreach ($row_value as $column_index => $cell_value) {
        $objPHPExcel->getActiveSheet()->SetCellValue("'".chr($column_index+65).($row_index+1)."'", $cell_value);
      }
    }
    // $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Hello');
    // $objPHPExcel->getActiveSheet()->SetCellValue('B2', 'world!');
    // $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Hello');
    // $objPHPExcel->getActiveSheet()->SetCellValue('D2', 'world!');
    
    // Rename sheet
    echo date('H:i:s') . " Rename sheet\n";
    $objPHPExcel->getActiveSheet()->setTitle('Simple');
    
    
    // Save Excel 2007 file
    echo date('H:i:s') . " Write to Excel2007 format\n";
    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
    $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
    
    // Echo done
    echo date('H:i:s') . " Done writing file.\r\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate a pdf file from data in a database using JasperReports
im trying to generate a report using CodeIgniter and Datatables.net . Now i'm trying
I'm trying to generate a unique ID in php in order to store user-uploaded
I'm trying to generate code coverage reports with EMMA using tests of which some
I am trying to create a excel file from Mysql using php. I found
I am trying to generate a regular expression match in Java, that accepts all
I'm trying to generate a request token using oauth2 in a Pyramid application for
I need to generate a report in .xls format, while trying to write the
Trying to generate db driven menu which based on parent->child structure. All root menu
I am trying to generate a PDF using iTextSharp. It will consists of a

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.