Fix propInfo.Key missing

This commit is contained in:
Wei Lin 2024-03-06 15:24:01 +08:00
parent 3d63587d9c
commit 6151c3f335
3 changed files with 53 additions and 4 deletions

Binary file not shown.

View File

@ -475,7 +475,8 @@ namespace MiniExcelLibs.OpenXml
rowXml.Replace(key, ""); rowXml.Replace(key, "");
continue; continue;
} }
if (!dic.ContainsKey(propInfo.Key))
continue;
var cellValue = dic[propInfo.Key]; var cellValue = dic[propInfo.Key];
if (cellValue == null) if (cellValue == null)
{ {
@ -985,12 +986,15 @@ namespace MiniExcelLibs.OpenXml
v.InnerText = v.InnerText.Replace($"{{{{{propNames[0]}}}}}", propNames[1]); v.InnerText = v.InnerText.Replace($"{{{{{propNames[0]}}}}}", propNames[1]);
break; break;
} }
if (!xRowInfo.PropsMap.ContainsKey(propNames[1]))
{
v.InnerText = v.InnerText.Replace($"{{{{{propNames[0]}.{propNames[1]}}}}}", "");
continue;
throw new InvalidDataException($"{propNames[0]} doesn't have {propNames[1]} property");
}
// auto check type https://github.com/shps951023/MiniExcel/issues/177 // auto check type https://github.com/shps951023/MiniExcel/issues/177
var prop = xRowInfo.PropsMap[propNames[1]]; var prop = xRowInfo.PropsMap[propNames[1]];
var type = prop.UnderlyingTypePropType; //avoid nullable var type = prop.UnderlyingTypePropType; //avoid nullable
//
if (!xRowInfo.PropsMap.ContainsKey(propNames[1]))
throw new InvalidDataException($"{propNames[0]} doesn't have {propNames[1]} property");
if (isMultiMatch) if (isMultiMatch)
{ {

File diff suppressed because one or more lines are too long