Skip to content
Snippets Groups Projects
Commit 494404dd authored by bgm's avatar bgm Committed by Aegir user
Browse files

Fixes to Report column widths: set to be minimally the width of the column header

parent 58e0dbdb
No related branches found
No related tags found
No related merge requests found
......@@ -193,7 +193,12 @@ class CRM_CiviExportExcel_Utils_Report extends CRM_Core_Page {
// Re-adjust the column widths
foreach ($cells as $key => $val) {
$w = self::getRecommendedColumnWidth($val, $widths);
// Only verify columns that have a header. The 'cells' variable is larger than necessary.
if (empty($headers[$key])) {
continue;
}
$w = self::getRecommendedColumnWidth($val, $headers[$key], $widths);
// Ignore width that would be too small to be practical.
if ($w < 5) {
......@@ -252,7 +257,7 @@ class CRM_CiviExportExcel_Utils_Report extends CRM_Core_Page {
* Percentile function based on:
* http://php.net/manual/en/function.stats-stat-percentile.php#79752
*/
static public function getRecommendedColumnWidth($column, &$widths) {
static public function getRecommendedColumnWidth($column, $header, &$widths) {
$p = 0.9; // 90% percentile
if (empty($widths[$column])) {
......@@ -279,6 +284,10 @@ class CRM_CiviExportExcel_Utils_Report extends CRM_Core_Page {
}
}
if ($result < mb_strlen($header)) {
$result = mb_strlen($header);
}
// Add a bit of padding.
$result += 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment