I'm working on a script that generates a PHP table containing some values from a MySQL database. The script will be displayed on a TV, so I need to break it if its height is greater than 1280 (I've got this value by completing it with values 'till it fits perfect, then I've used jQuery alert to display its height) and I will use jquery.cycle.all plugin to create a slideshow from the tables.
My solution was to use a PHP variable and increment it on each generated then if I have let's say 13 rows, it echoes </table><table>, but the cells must have an exact width so it may add a new line of text (if I have a longer text) on a cell and the table will have more than 1280px height.
Does anybody have any idea about how I can solve this?
Possible solutions:
Use the css overflow: hidden to prevent content going to the next line and just hide it
Use javascript to iterate over each row, calculate the height of the row and remove rows if the total height exceeds 1280px.
Use PHP to calculate the length of the text in actual px and how many rows would be used, but that is quite complex.
Related
I am generating a pdf (using fpdf) based on user input coming via an html form. The pdf has two columns, the left side has the label of the variable and the right side has the value entered by the user. The problem I am facing is when I have a user input that spans multiple lines. For example, the value of the address can span from 1 line (default address) to up to 4 lines (address input by the user).
Right now I am using multicell to allow user entered address to wrap around the cell, as seen below:
$fpdf->Cell(65,28,"Address:",1,0);
$fpdf->Multicell(125,7,$address,1,'L',false);
For the "Cell", I have set the height as 28, because I know that the neighboring multicell can span a maximum of 4 lines. But since only the "multicell" expands and not the "cell", in the above code, my output looks like this:
fpdf output 1
If I change the height and width values of the "cell" and "multicell" like below:
$fpdf->Cell(65,7,"Address:",1,0);
$fpdf->Multicell(125,7,$address,1,'L',false);
I get an output like this when the address is more than 1 line:
fpdf output 2
Is there any solution to ensure that the bot the cells are always the same height and look more even?
Thank you!
I'm trying to get the calculated height of a row in PHPSpreadsheet but whenever I do something like
$spreadsheet->getActiveSheet()->getRowDimension($row)->getRowHeight();
I always get a -1 value which is correct based on their documentation as that is the default value. I need to get the calculated height in pt though as I need to do some calculations. I have a cell that is set to wrap text, and spans multiple lines. Anyone knows how to get the calculated height of a row?
-1 is the value of auto height. Means the value will calculated automatically. If you need a number of height. I would suggest to calc the height over the value of the cell. You must do following: Find newlines in the content and multiply them with 12.75 pts (standard height). Some informations you can find here to.
I am having an issue with saving a PDF file from PHPExcel and it creating widow/orphans with my data.
I know of the function to create page breaks,
$objPHPExcel->getActiveSheet()->setBreak( 'A10' , PHPExcel_Worksheet::BREAK_ROW );
but I would like to know if there is a function to know the current height of a range of cells.
I have found references to "getRowDimension" in functions like
$objPHPExcel->getActiveSheet()->getRowDimension('10')->setRowHeight(100);
but I cannot find any documentation on that function. Does anyone know if it can calculate the height of the chosen row and/or take a range of rows?
Also, is there a function to calculate the usable space between the header and footer of each page? Or should I calculate that from the page margin?
Thank you,
Nick
$objPHPExcel->getActiveSheet()
->getRowDimension('10')
->getRowHeight();
Will return the row height for the specified row. This is the height in "points", where 1 point is the equivalent of about 1/72 of an inch (or about 0.35mm). A value of 0 indicates a hidden row; while a value of -1 is the default value, which is 12.75pt (about 1/6 of an inch).
The PHPExcel_Shared_Drawing class contains a number of functions for converting between points and other units of measure, such as pointsToPixels() and pixelsToPoints(), and pixelsToEMU() and EMUToPixels() (English Metric Units).
The whole issue of Microsoft's units of measure is really a confusing minefield, but there's a useful blog post here discussing the different units of measure use in MS Office
This is an example of what Id like to do.
http://www.davidmielcarek.com/
I'd like the rows to be fixed length but I might have 2 or 3 images per row.
I attempted this earlier and it didn't really work.
Here is the pseudo code
start loop
get image width
calculate rowWidth
if (rowWidth > maxRowWidth){
start nested loop
grab thumbnails for this row only
resize the thumbnails using the row's aspect ratio so each row is the same width
call the thumbnails
end nested loop
reset some variables for the next row
check if this is the last post
}
end loop
I don't see the issue but when I put it into actual code I couldn't get it working perhaps someone else can code it better or point out my flaw?
I have to Export data to xlsx, where the exported file should be in a pre defined format. Becoz of these i am using "PHPexcel". And i created a template of some format with each row with some specified height.
Actually in each cell i will be writing the data dynamically. so if the text is larger, then the row height in not increased.
So is ther anyway so tat row height is increased to fit the cell text.
To set a row to autofit:
$objPHPExcel->getActiveSheet()->getRowDimension(10)->setAutoSize(true);
And then set the individual cells to allow wrapping
$objPHPExcel->getActiveSheet()->getStyle('A10:D10')->getAlignment()->setWrapText(true);