Exports: support multi-column queries (e.g. SELECT l, p FROM Person AS p JOIN Location AS l ON p.location_id = l.id) with null values

SVN:trunk[3694]
This commit is contained in:
Romain Quetiez
2015-08-24 08:01:24 +00:00
parent b1887ae431
commit 5277a9eb38
7 changed files with 153 additions and 53 deletions

View File

@@ -225,29 +225,33 @@ class ExcelBulkExport extends TabularBulkExport
$aData = array();
foreach($aAliasByField as $aAttCode)
{
$oObj = $aRow[$aAttCode['alias']];
$sField = '';
switch($aAttCode['attcode'])
if ($oObj)
{
case 'id':
$sField = $aRow[$aAttCode['alias']]->GetKey();
break;
default:
$value = $aRow[$aAttCode['alias']]->Get($aAttCode['attcode']);
if ($value instanceOf ormCaseLog)
switch($aAttCode['attcode'])
{
// Extract the case log as text and remove the "===" which make Excel think that the cell contains a formula the next time you edit it!
$sField = trim(preg_replace('/========== ([^=]+) ============/', '********** $1 ************', $value->GetText()));
}
else if ($value instanceOf DBObjectSet)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($aRow[$aAttCode['alias']]), $aAttCode['attcode']);
$sField = $oAttDef->GetAsCSV($value, '', '', $aRow[$aAttCode['alias']]);
}
else
{
$oAttDef = MetaModel::GetAttributeDef(get_class($aRow[$aAttCode['alias']]), $aAttCode['attcode']);
$sField = $oAttDef->GetEditValue($value, $aRow[$aAttCode['alias']]);
case 'id':
$sField = $oObj->GetKey();
break;
default:
$value = $oObj->Get($aAttCode['attcode']);
if ($value instanceOf ormCaseLog)
{
// Extract the case log as text and remove the "===" which make Excel think that the cell contains a formula the next time you edit it!
$sField = trim(preg_replace('/========== ([^=]+) ============/', '********** $1 ************', $value->GetText()));
}
else if ($value instanceOf DBObjectSet)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($oObj), $aAttCode['attcode']);
$sField = $oAttDef->GetAsCSV($value, '', '', $oObj);
}
else
{
$oAttDef = MetaModel::GetAttributeDef(get_class($oObj), $aAttCode['attcode']);
$sField = $oAttDef->GetEditValue($value, $oObj);
}
}
}
$aData[] = $sField;