Skip to content

Commit

Permalink
Fix propInfo.Key missing
Browse files Browse the repository at this point in the history
  • Loading branch information
shps951023 committed Mar 6, 2024
1 parent 3d63587 commit 6151c3f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
Binary file added samples/xlsx/TestIssue24020201.xlsx
Binary file not shown.
12 changes: 8 additions & 4 deletions src/MiniExcel/OpenXml/ExcelOpenXmlTemplate.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ private void WriteSheetXml(Stream stream, XmlDocument doc, XmlNode sheetData, bo
rowXml.Replace(key, "");
continue;
}

if (!dic.ContainsKey(propInfo.Key))
continue;
var cellValue = dic[propInfo.Key];
if (cellValue == null)
{
Expand Down Expand Up @@ -985,12 +986,15 @@ private void UpdateDimensionAndGetRowsInfo(Dictionary<string, object> inputMaps,
v.InnerText = v.InnerText.Replace($"{{{{{propNames[0]}}}}}", propNames[1]);
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
var prop = xRowInfo.PropsMap[propNames[1]];
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)
{
Expand Down
Loading

0 comments on commit 6151c3f

Please sign in to comment.