Giter Club home page Giter Club logo

Comments (6)

kilianweisl avatar kilianweisl commented on August 24, 2024 1

@Progi1984 Sure! Thanks for the fast reply.

Suppose I have the following code:

  public function createTable()
  {
    $pptx = new PhpPresentation();
    $slide = $pptx->getActiveSlide();

    $shape = $slide->createTableShape(3);
    $shape->setWidth(Converter::convertEmuToPx($pptx->getLayout()->getCX()) - 20);
    $shape->setOffsetX(10);
    $shape->setOffsetY(10);

    for($rowCount = 0; $rowCount < 3; $rowCount++) {
      $row = $shape->createRow();
      for($cellCount = 0; $cellCount < 3; $cellCount++) {
        $cell = $row->nextCell();
        $cell->createTextRun('Cell ' . $cellCount)
          ->getFont()
          ->setSize(20);
      }
    }

    $writer = IOFactory::createWriter($pptx, 'PowerPoint2007');
    $writer->save('./table.pptx');
  }

The output .pptx file is:

Screenshot 2024-08-19 at 17 29 58

Now the problem is, I don't know how many rows my table has and I need to add a caption below it like so:

Screenshot 2024-08-19 at 17 31 43

How can I get the final height of the table (after adding all rows) in order to place a text object afterwards?

This might also include splitting the table and printing them on multiple slides, as mentioned in #72.

from phppresentation.

Progi1984 avatar Progi1984 commented on August 24, 2024

@kilianweisl Hi have you got a sample file as expected result for analysis ?
Thanks

from phppresentation.

Progi1984 avatar Progi1984 commented on August 24, 2024

@kilianweisl Could you send me a sample docx file with expected result ? I want to analyze the file. Thanks

from phppresentation.

kilianweisl avatar kilianweisl commented on August 24, 2024

Do you mean the pptx file? It's just a bunch of rows and a text underneath it.

table.pptx

from phppresentation.

Progi1984 avatar Progi1984 commented on August 24, 2024

Oh. I didn't understand it. I think you must all calculate : font size, margin, border size, etc...

from phppresentation.

kilianweisl avatar kilianweisl commented on August 24, 2024

While that'd be somehow possible with simple tables, I don't think that it is possible when you e.g. have the following case, where an arbitrary column contains text that forces a line break.

Or is there a way to access the height of a cell/row/RichTextShape after putting text into it?

Screenshot 2024-08-19 at 18 09 30

from phppresentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.