Browse Source

Export the content of the CaseLogs in "spreadsheet" format, with some tricks to preserve the formatting in Excel.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2804 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 years ago
parent
commit
f3fadcf466
2 changed files with 8 additions and 0 deletions
  1. 7 0
      application/cmdbabstract.class.inc.php
  2. 1 0
      webservices/export.php

+ 7 - 0
application/cmdbabstract.class.inc.php

@@ -1219,6 +1219,13 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 								$aRow[] = '<td>'.date('H:i:s', $iDate).'</td>';								
 								$aRow[] = '<td>'.date('H:i:s', $iDate).'</td>';								
 							}
 							}
 						}
 						}
+						else if($oAttDef instanceof AttributeCaseLog)
+						{
+							$rawValue = $oObj->Get($sAttCodeEx);
+							$outputValue = str_replace("\n", "<br/>", htmlentities($rawValue->__toString(), ENT_QUOTES, 'UTF-8'));
+							// Trick for Excel: treat the content as text even if it begins with an equal sign
+							$aRow[] = '<td x:str>'.$outputValue.'</td>';
+						}
 						else
 						else
 						{
 						{
 							$rawValue = $oObj->Get($sAttCodeEx);
 							$rawValue = $oObj->Get($sAttCodeEx);

+ 1 - 0
webservices/export.php

@@ -237,6 +237,7 @@ if (!empty($sExpression))
 				header("Cache-control:", true);
 				header("Cache-control:", true);
 
 
 				$sFields = implode(',', $aFields);
 				$sFields = implode(',', $aFields);
+				$oP->add_style('table br {mso-data-placement:same-cell;}'); // Trick for Excel: keep line breaks inside the same cell !
 				cmdbAbstractObject::DisplaySetAsHTMLSpreadsheet($oP, $oSet, array('fields' => $sFields, 'fields_advanced' => $bFieldsAdvanced, 'localize_values' => $bLocalize));
 				cmdbAbstractObject::DisplaySetAsHTMLSpreadsheet($oP, $oSet, array('fields' => $sFields, 'fields_advanced' => $bFieldsAdvanced, 'localize_values' => $bLocalize));
 				break;
 				break;