Skip to content

Commit

Permalink
增加使用逗号的 array
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonic853 committed Jan 3, 2025
1 parent bff5913 commit 17752bf
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Excel2JsonEX/JsonExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,25 @@ private Dictionary<string, object> convertRowToDict(DataTable sheet, DataRow row
if (options.CellJson)
{
var cellText = value.ToString()?.Trim();
if (!string.IsNullOrEmpty(cellText) && (cellText.StartsWith('[') || cellText.StartsWith('{')))
if (!string.IsNullOrEmpty(cellText))
{
try
if (cellText.StartsWith('[') || cellText.StartsWith('{'))
{
var cellJsonObj = JsonConvert.DeserializeObject(cellText);
if (cellJsonObj != null)
value = cellJsonObj;
try
{
var cellJsonObj = JsonConvert.DeserializeObject(cellText);
if (cellJsonObj != null)
value = cellJsonObj;
}
catch (Exception exp)
{
Console.WriteLine(exp.Message);
}
}
catch (Exception exp)
else if (cellText.StartsWith(',') || cellText.StartsWith(','))
{
Console.WriteLine(exp.Message);
var cellArray = cellText.Split([',', ','], StringSplitOptions.RemoveEmptyEntries);
value = cellArray;
}
}
}
Expand Down

0 comments on commit 17752bf

Please sign in to comment.