提交当前本机整理版本
This commit is contained in:
@@ -4635,4 +4635,42 @@ namespace Lskj.Control.Model
|
||||
{
|
||||
result = result.Replace(invalidChar, '_');
|
||||
}
|
||||
result = Regex.Replace(result,
|
||||
result = Regex.Replace(result, @"[\x00-\x1F]", "_").Trim('\'');
|
||||
if (string.IsNullOrWhiteSpace(result))
|
||||
{
|
||||
result = "Sheet";
|
||||
}
|
||||
if (result.Length > 31)
|
||||
{
|
||||
result = result.Substring(0, 31);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取可作为临时文件名的Excel名称。
|
||||
/// </summary>
|
||||
/// <param name="fileName">原始文件名。</param>
|
||||
/// <returns>处理后的文件名。</returns>
|
||||
private static string GetSafeExcelFileName(string fileName)
|
||||
{
|
||||
string result = GetSafeWorksheetName(fileName);
|
||||
foreach (char invalidChar in Path.GetInvalidFileNameChars())
|
||||
{
|
||||
result = result.Replace(invalidChar, '_');
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(result))
|
||||
{
|
||||
result = "Sheet";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user