I have a new grid with column header text rotated as seen here –
Is there a way to keep the column header text rotated when exporting to Excel and PDF formats ?
I also can’t seem to get the text to align with the bottom of the header cell (any help with this is also appreciated 😉
In my grid I’ve rotated the header text like so –
$virt_txt_style='<p class=”rotate”>’; // used for all vertical columns text
$col = array(); $col[“name”]=”clean_fridge_freezer”; $col[“title”]=”$virt_txt_style Clean Fridg Freezr</p>”; $col=build_rest_of_parms($col); $cols=$col;
$col[“width”] = “175”;
$col[“align”] = “left”;
$col[“editable”] = true;
$col[“search”] = false;
$col[“sortable”] = true;
//$col[“datefmt”] = “dd”;
Currently wrapper that we are using to export pdf / excel will need core lib changes.
What you can do is to follow demos/export/export-custom.php which uses callback functions and data is passed to it. You can use TCPDF or PHPExcel library there and export with custom code.
Abu Ghufran - Dev Team
PHP Grid Framework
I had looked at demos/export/export-custom.php yesterday but there isn’t an example of exporting pdf format in there (only examples for xls and csv format)-
else if ($grid->options[“export”][“format”] == “pdf”)
// your custom pdf generation code goes here …
I started looking at TCPDF at tcpdf.org and am completely lost with getting started.
So … I copied off and started hacking up this demo file – demos/export/export-pdf-html.php
If I dump out the html at the end of my callback function to the browser, the header row (titles) are rotated and styled as I specified.
If I let the callback function return the HTML that I build, the resulting PDF in the browser shows that the header row is styled (text color, font-size, bkgrd color, etc.) but the text is not rotated.
Output example of both here – https://jmp.sh/xPdSuyN
I build the table cells for the first row (using 2 divs) in export-pdf-html.php like so –
$html .= “<td bgcolor=\”TEAL\” ><div class=\”vertical-text\”><div class=\”vertical-text__inner\”><strong>$d</strong></div></div></td>”;
The included CSS looks like this –
transform: translate(0,100%) rotate(-90deg);
transform-origin: 0 0;
/* This element stretches the parent to be square by using the mechanics of vertical margins */
margin: -2.0em 0 100%;
Not sure how best to proceed … just looking for a way for my client to be able to print and download grid output in somewhat of a usable fashion.
How useful was this discussion?
Click on a star to rate it!
Average rating / 5. Vote count:
We are sorry that this post was not useful for you!
Let us improve this post!
Thanks for your feedback!