Export with rotated header text

QuestionsExport with rotated header text
Steven Borruso asked 3 weeks ago

Hi Abu,

I have a new grid with column header text rotated as seen here –

https://jmp.sh/GfIZAQu

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;

function build_rest_of_parms($col)
{
$col[“width”] = “175”;
$col[“align”] = “left”;
$col[“editable”] = true;
$col[“search”] = false;
$col[“sortable”] = true;
//$col[“datefmt”] = “dd”;
return $col;
}

<style>
p.rotate {
writing-mode: vertical-rl;
transform: rotate(180deg);
text-align: left;
}
</style>

Thanks !

Steve

3 Answers
Abu Ghufran Staff answered 3 weeks ago

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
 
Steven Borruso answered 3 weeks ago

Thanks Abu,

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 –

.vertical-text {
display: inline-block;
overflow: hidden;
width: 2.0em;
color: white;
font-size: 20pt;
}
.vertical-text__inner {
display: inline-block;
white-space: nowrap;
line-height: 2.0;
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 */
.vertical-text__inner:after {
content: “”;
display: block;
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.

Thanks,

Steve

 

Steven Borruso answered 3 weeks ago

Found a TCPDF example to start with ( here ) so I guess I’ll hack that up and into my grid code to bypass the PHPGrid PDF processing altogether and see how I make out. Please let me know if you recommend any better examples to start with.

Thanks

 

 

Your Answer

8 + 8 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!