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(); var str = item.ToString();
// 检查是否为 Int // 检查数据类型
if (!int.TryParse(str, out _)) if (!int.TryParse(str, out _))
{
isInt = false; isInt = false;
}
// 检查是否为 Long
if (!long.TryParse(str, out _)) if (!long.TryParse(str, out _))
{
isLong = false; isLong = false;
}
// 检查是否为 Double
if (!double.TryParse(str, out _)) if (!double.TryParse(str, out _))
{
isDouble = false; isDouble = false;
}
// 检查是否为 DateTime
if (!DateTime.TryParse(str, out _)) if (!DateTime.TryParse(str, out _))
{
isDateTime = false; isDateTime = false;
}
// 检查是否为 Bool
if (!bool.TryParse(str, out _)) if (!bool.TryParse(str, out _))
{
isBool = false; isBool = false;
}
} }
if (isInt) return true switch
return "int"; {
else if (isLong) bool _ when isInt => "int",
return "int64"; bool _ when isLong => "int64",
else if (isDouble) bool _ when isDouble => "double",
return "double"; bool _ when isDateTime => "datetime",
else if (isDateTime) bool _ when isBool => "bool",
return "datetime"; _ => "string",
else if (isBool) };
return "bool";
else
return "string";
} }
} }