Comments (6)
@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](https://private-user-images.githubusercontent.com/33355205/359158325-1b61c0b6-50ee-4b10-8b04-7d77359306ab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0NDgwMjcsIm5iZiI6MTcyNDQ0NzcyNywicGF0aCI6Ii8zMzM1NTIwNS8zNTkxNTgzMjUtMWI2MWMwYjYtNTBlZS00YjEwLThiMDQtN2Q3NzM1OTMwNmFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIzVDIxMTUyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTllYmYxNjRjMWM2ZDQ5N2ExZDg1MjA1NDhlN2QzZmZmMzBjYWVjYjJiNzM0YzhkYzNjMjY3ZWZmMjhhYzFmYzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.H_bmar3ZLKjuVSZw43j-W2GNuIhsvqRTVy8hKireZRU)
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](https://private-user-images.githubusercontent.com/33355205/359158860-4f9ff185-a1cb-46b4-8f70-3b24275b36f5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0NDgwMjcsIm5iZiI6MTcyNDQ0NzcyNywicGF0aCI6Ii8zMzM1NTIwNS8zNTkxNTg4NjAtNGY5ZmYxODUtYTFjYi00NmI0LThmNzAtM2IyNDI3NWIzNmY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIzVDIxMTUyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgzYmJhYzhlZjQ2ZTVkNzg4MjcyZThhODM5OTVmOGJmZmJkMTA5Yjc1ZDU5Y2YxMzdkNzE4YjQ0NzA4ZTViM2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8S1kesNnGRRks5U8O5OZV_qcsai7YhprBxb5L-zdBXA)
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.
@kilianweisl Hi have you got a sample file as expected result for analysis ?
Thanks
from phppresentation.
@kilianweisl Could you send me a sample docx file with expected result ? I want to analyze the file. Thanks
from phppresentation.
Do you mean the pptx file? It's just a bunch of rows and a text underneath it.
from phppresentation.
Oh. I didn't understand it. I think you must all calculate : font size, margin, border size, etc...
from phppresentation.
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](https://private-user-images.githubusercontent.com/33355205/359169788-131bc857-a8f9-4c28-9697-ae7d375c1439.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0NDgwMjcsIm5iZiI6MTcyNDQ0NzcyNywicGF0aCI6Ii8zMzM1NTIwNS8zNTkxNjk3ODgtMTMxYmM4NTctYThmOS00YzI4LTk2OTctYWU3ZDM3NWMxNDM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIzVDIxMTUyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE2OTkyMjFhMzJlMmZkOTk0NmJiY2RjNDY3MTFiMmY3ZTliM2EwMGNkNDJiNTk0MTRiZmFkNTUxM2EwN2RmZTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Iw-T9awad4SB4uk6N8NqML1y38sCd8-17rYRfkPubpc)
from phppresentation.
Related Issues (20)
- A bug occurs when creating a line chart
- Text missing in PowerPoint, but shows up in Google Slides, LibreOffice Impress
- Error Undefined type 'use\...\'
- The file "" doesn't exist HOT 1
- Problem with instalation: phpoffice/phppresentation 1.0.0 requires phpoffice/phpspreadsheet ^1.9.0 HOT 2
- Data Label Positions not working for Doughnut Chart
- Join two pptx files version 2016 or higher HOT 1
- Support for Slide Sections HOT 2
- I would like an option to not load images. HOT 1
- can not read PPTX HOT 3
- The parameter pValue can't have the value "020B0604030504040204" (Validation: The length is not equals to 10) HOT 2
- Vertical alignment does not work if it is a placeholder HOT 2
- Issues with setLineWidth() HOT 1
- RichText Properties
- Is it possible to generate .pptx file that can be themed/formatted in most PowerPoint Software?
- generating a PPT file using a template with placeholders getting the error "getIndex() on null" HOT 1
- How include slide number
- Could not open for Writing pptx file HOT 1
- how to border left and border bottom in powerpoint2007? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phppresentation.