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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:22:01+00:00 2026-06-10T16:22:01+00:00

I’m using phpexcel to create some sheets and everything is working fine, but there’s

  • 0

I’m using phpexcel to create some sheets and everything is working fine, but there’s an extra empty sheet being created after all the sheets I create and I don’t know either why it’s happening, or how to stop it. Do you know why is it happening?

To generate my spreadsheet, I have two static arrays storing the sheet indexes and names like this:

//List of Enter Data sheets.
const IRRIGATION_SHEET_INDEX = 0;
const CANOPY_SHEET_INDEX = 1;
const CLUSTER_SHEET_INDEX = 2;
const OBSERVATIONS_SHEET_INDEX = 3;
const WATERPOTENTIAL_SHEET_INDEX = 4;
const FRUITMATURITY_SHEET_INDEX = 5;

//list of hidden sheets created only to fill data validation lists in the bulk_upload_sheet
const BLOCKS_LIST_SHEET_INDEX = 6;
const RANCHES_LIST_SHEET_INDEX = 7;
const SUB_BLOCKS_LIST_SHEET_INDEX = 8;

/**
 * This is a static array to store the indexes and titles of each usable sheet (by usable sheet, it means that these are the sheets the user can see)
 * @var array
 */
public static $usableSheetTitles = array(
        //SELF::BULK_UPLOAD_SHEET_INDEX => 'BulkUploadTemplate',
        SELF::IRRIGATION_SHEET_INDEX => 'Irrigation',
        SELF::CANOPY_SHEET_INDEX => 'Canopy',
        SELF::CLUSTER_SHEET_INDEX => 'Cluster',
        SELF::OBSERVATIONS_SHEET_INDEX => 'Observations',
        SELF::WATERPOTENTIAL_SHEET_INDEX => 'WaterPotential',
        SELF::FRUITMATURITY_SHEET_INDEX => 'FruitMaturity'
);

public static $auxiliarSheets = array (
        SELF::BLOCKS_LIST_SHEET_INDEX => 'BlocksList',
        SELF::RANCHES_LIST_SHEET_INDEX => 'RanchesList',
        SELF::SUB_BLOCKS_LIST_SHEET_INDEX => 'SubBlocksList'
);

Then I call the method createSheets() that reads these arrays and generates the sheets I need:

public static function createSheets($objPHPExcel, $ranches, $subBlocks) {
    count($ranches) <= 1 ? $hasSeveralRanches = false : $hasSeveralRanches = true;
    count($subBlocks) <= 0 ? $hasSubBlocks = false : $hasSubBlocks = true;
    foreach (self::$usableSheetTitles as $sheetIndex => $sheetTitle) {
        $objPHPExcel->createSheet($sheetIndex);
        $objPHPExcel->setActiveSheetIndex($sheetIndex);
        $objPHPExcel->getActiveSheet()->setTitle($sheetTitle);
        self::insertTitleAndLegend($objPHPExcel, $sheetTitle, $hasSeveralRanches, $hasSubBlocks);
    }
    foreach (self::$auxiliarSheets as $sheetIndex => $sheetTitle) {
        $objPHPExcel->createSheet($sheetIndex);
        $objPHPExcel->setActiveSheetIndex($sheetIndex);
        $objPHPExcel->getActiveSheet()->setTitle($sheetTitle);
    }
    return $objPHPExcel;
}

Do you know what could possibly be generating this final empty sheet I have in my xls generated template? Is it a normal behavior or is there something missing in my code that I didn’t see?

  • 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-10T16:22:03+00:00Added an answer on June 10, 2026 at 4:22 pm

    This is normal behaviour. When you instantiate a new PHPExcel object, it automatically creates it with a single worksheet (“Worksheet”) because that is what most users are likely to need. The sheets thet you’re creating are being inserted “in front” of it because you’re specifying their index position which is pushing it “down” the series of worksheets.

    If you don’t need the automatically created worksheet because you’re creating all your own sheets, then use the PHPExcel object’s removeSheetByIndex() method.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

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.