Skip to content

Create Cli.php #4342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Create Cli.php #4342

wants to merge 2 commits into from

Conversation

vorpentine
Copy link

Added cli output, take or leave it.

This is:

  • [Y] a new feature

Checklist:

  • [?] Changes are covered by unit tests
    • [?] Changes are covered by existing unit tests
    • [?] New unit tests have been added
  • [Y] Code style is respected
  • [Y] Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • [N] CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • [N] Documentation is updated as necessary

Why this change is needed?

Handy for developers

Add cli ouput
@oleibman
Copy link
Collaborator

oleibman commented Feb 6, 2025

Your explanation is very vague. Could you give us a better idea of what you are trying to accomplish?

Aside from that, you will need to clean up the php-cs-fixer, phpcs, and phpstan problems. And add test cases. The only reason your change passes the CI tests is because your new code is never actually exercised. If it had been, you would certainly have run into errors when trying to call the no-longer-existing getCellByColumnAndRow method (a problem which phpstan flags).

For now, I am putting this change in draft status.

@oleibman oleibman marked this pull request as draft February 6, 2025 20:22
@oleibman
Copy link
Collaborator

At a guess, you are trying to do approximately the same thing as Helper\TextGrid::render(). You might want to compare its results with the code you're trying to add with this PR.

@oleibman
Copy link
Collaborator

The following code which requires this PR:

        $writer = new Cli($spreadsheet);
        $outfile = 'writercli.writecli.txt';
        $writer->save($outfile);

is essentially the same as the following existing code, which requires no changes:

        $textGrid = new TextGrid($array);
        $outfile = 'writercli.textgrid.txt';
        file_put_contents($outfile, $textGrid->render());

The existing function could be better documented, and you might want to add some bells and whistles to it, but there is no need for the new class since it duplicates the existing functionality.

So ... closing this ticket. Thank you anyhow for suggesting it.

@oleibman oleibman closed this Mar 12, 2025
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this pull request Mar 23, 2025
Helper/TextGrid was intended to assist with some samples. However, it has emerged recently on two tickets. PR PHPOffice#4342 intended to introduce functionality very similar to TextGrid, and was closed for that reason. Issue PHPOffice#1640 was closed as stale over 4 years ago, despite the fact that TextGrid seems an adequate resolution for it.

Since it seems that there is a use for this function beyond its original intended usage, I added a few parameters to give it some flexibility - the ability to omit row and/or column headers, and the ability to add a divider line between rows.

A description of this function is added to the formal documentation.
@oleibman oleibman mentioned this pull request Mar 23, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants