Merge branch 'ExcelPrompt' of http://8.134.144.137:3000/Ling0925/ExcelHelper into ExcelPrompt

This commit is contained in:
Ling 2025-02-15 10:41:08 +08:00
commit cad060faf8
1 changed files with 20 additions and 21 deletions

View File

@ -115,39 +115,38 @@ public class Excel2Prompt
{
var str = item.ToString();
// 检查是否为 Int
// 检查数据类型
if (!int.TryParse(str, out _))
{
isInt = false;
// 检查是否为 Long
}
if (!long.TryParse(str, out _))
{
isLong = false;
// 检查是否为 Double
}
if (!double.TryParse(str, out _))
{
isDouble = false;
// 检查是否为 DateTime
}
if (!DateTime.TryParse(str, out _))
{
isDateTime = false;
// 检查是否为 Bool
}
if (!bool.TryParse(str, out _))
{
isBool = false;
}
}
if (isInt)
return "int";
else if (isLong)
return "int64";
else if (isDouble)
return "double";
else if (isDateTime)
return "datetime";
else if (isBool)
return "bool";
else
return "string";
return true switch
{
bool _ when isInt => "int",
bool _ when isLong => "int64",
bool _ when isDouble => "double",
bool _ when isDateTime => "datetime",
bool _ when isBool => "bool",
_ => "string",
};
}
}