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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:47:27+00:00 2026-06-18T20:47:27+00:00

I have the following class hierarchy: interface IReportGenerator { public function setTitle ($title); public

  • 0

I have the following class hierarchy:

interface IReportGenerator {

    public function setTitle ($title);

    public function setColumns ($columns);

    public function setPrintArea ($start, $stop);

    public function setPageOrientation ($value);

    public function createReport ($data);

    public function saveReport ($name, $path = null);

    public function saveReportAs ($name, $path = null, $type = null);
}

abstract class AbstractReportGenerator implements IReportGenerator {
    public function __construct() {
        $this->report = new PHPExcel();
    }

    public function setTitle ($title, $now = false) {
        // store

        return $this;
    }

    public function setColumns ($columns) {
        // store

        return $this;
    }


    public function setPaperSize ($value, $now = false) {
        // store

        return $this;
    }

    public function setPageOrientation ($value, $now = false) {
        // store

        return $this;
    }

    public function setPrintArea ($start, $stop, $now = false) {
        // store

        return $this;
    }

    public function saveReport ($name, $path = NULL) {
        return $this->saveReportAs($name,$path,self::EXCEL_2007);
    }

    public function saveReportAs ($name, $path = NULL, $type = NULL) {
        // save report

        return $this;
    }

    public function createReport ($data) {
        $this->doHeader();

        $this->doTitle();

        $this->doColumnHeaders();

        $this->doData($data);

        $this->doFooter();

        $this->doFormatting();

        $this->doMargins();

        $this->doPrintOptions();
    }

    abstract protected function doHeader();

    abstract protected function doTitle();

    abstract protected function doColumnHeaders();

    abstract protected function doData($data);

    abstract protected function doFooter();

    abstract protected function doFormatting();

    abstract protected function doMargins();

    abstract protected function doPrintOptions();
}

class ReportGeneratorSimple extends AbstractReportGenerator {
    public function __construct() {
        parent::__construct();
    }

    protected function doHeader () {
        // do nothing
    }

    protected function doTitle () {
        echo 'title A';
    }

    protected function doColumnHeaders () {
        echo 'column A';
    }

    protected function doData ($data) {
        echo 'data A';
    }

    protected function doFooter () {
        // do nothing
    }

    protected function doFormatting () {
        echo 'format A';
    }

    protected function doMargins () {
        // do nothing
    }

    protected function doPrintOptions () {
        // do nothing
    }
}

class ReportGeneratorFormatted extends ReportGeneratorSimple {
    public function __construct() {
        parent::__construct();
    }

    protected function doHeader () {
        parent::doHeader();
    }

    protected function doFooter () {
        parent::doFooter();
    }

    protected function doFormatting () {
        parent::doFormatting();

        echo 'format B';
    }
}

When I do:

$report = new ReportGeneratorFormatted();
$report->setTitle('title');
$report->setColumns($columns);
$report->createReport($data);
$report->saveReport('file.xlsx');

The output i get is (in no particular order):

'data A'
'format A'

Any idea why ‘title A’, ‘columns A’, and ‘format B’ are not printing? The saveReport() and saveReportAs() methods are working as well.

  • 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-18T20:47:28+00:00Added an answer on June 18, 2026 at 8:47 pm

    @zerkins – You are correct, the code I supplied runs as expected. The results I supplied came from the production code, not the sample.

    Given that the sample worked correctly, it was as simple as tracking down the difference in the production code. It turned out to be a missing call to “parent” in one of the child classes.

    Thanks!

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

Sidebar

Related Questions

We have the following class hierarchy: public interface IManager { object GetObject(int); } public
I have the following Java object hierarchy: public interface Function { public void calculate(long
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following class hierarchy: public class RealPeople { } public class Users
Let's say I have the following class hierarchy (base interface included): IAction -> (abstract)
I have the following hierarchy of classes: public interface Message public interface V2Message extends
In out program, we have the following class hierarchy: public class PagePanelBase: UserControl public
I have something like following: public interface A { .... } public abstract class
I have the following class hierarchy [BsonKnownTypes(typeof(MoveCommand))] public abstract class Command : ICommand {
I have the following classes: // -- model hierarchy public interface IJob { }

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.