😎1、修复导出Excel引用公式错误的问题 2、扩展“毫秒转天时分秒”方法,支持简化显示 3、升级依赖
This commit is contained in:
parent
2a314e5b07
commit
bebe5069ff
@ -44,7 +44,7 @@
|
||||
<PackageReference Include="MiniWord" Version="0.9.2" />
|
||||
<PackageReference Include="MQTTnet.Server" Version="5.0.1.1416" />
|
||||
<PackageReference Include="MySqlBackup.NET.MySqlConnector" Version="2.3.9" />
|
||||
<PackageReference Include="NewLife.Redis" Version="6.1.2025.401" />
|
||||
<PackageReference Include="NewLife.Redis" Version="6.1.2025.411" />
|
||||
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="4.0.0" />
|
||||
<PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.2.0" />
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
|
||||
@ -106,9 +106,10 @@ public class DateTimeUtil
|
||||
/// <summary>
|
||||
/// 毫秒转天时分秒
|
||||
/// </summary>
|
||||
/// <param name="ms"></param>
|
||||
/// <param name="ms">TotalMilliseconds</param>
|
||||
/// <param name="isSimplify">是否简化显示</param>
|
||||
/// <returns></returns>
|
||||
public static string FormatTime(long ms)
|
||||
public static string FormatTime(long ms, bool isSimplify = false)
|
||||
{
|
||||
int ss = 1000;
|
||||
int mi = ss * 60;
|
||||
@ -128,7 +129,23 @@ public class DateTimeUtil
|
||||
//string sMilliSecond = milliSecond < 10 ? "0" + milliSecond : "" + milliSecond;//毫秒
|
||||
//sMilliSecond = milliSecond < 100 ? "0" + sMilliSecond : "" + sMilliSecond;
|
||||
|
||||
return $"{sDay} 天 {sHour} 小时 {sMinute} 分 {sSecond} 秒";
|
||||
if (!isSimplify)
|
||||
return $"{sDay} 天 {sHour} 小时 {sMinute} 分 {sSecond} 秒";
|
||||
else
|
||||
{
|
||||
string result = string.Empty;
|
||||
if (day > 0)
|
||||
result = $"{sDay}天";
|
||||
if (hour > 0)
|
||||
result = $"{result}{sHour}小时";
|
||||
if (minute > 0)
|
||||
result = $"{result}{sMinute}分";
|
||||
if (!result.IsNullOrEmpty())
|
||||
result = $"{result}{sSecond}秒";
|
||||
else
|
||||
result = $"{sSecond}秒";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -124,7 +124,7 @@ public class ExcelHelper
|
||||
if (dataList != null)
|
||||
{
|
||||
// 添加下拉列表
|
||||
AddListValidation(columnIndex, dataList);
|
||||
AddListValidation(dropdownSheet, columnIndex, dataList);
|
||||
dropdownSheet.Cells[1, columnIndex, dataList.Count, columnIndex].LoadFromCollection(dataList);
|
||||
}
|
||||
}
|
||||
@ -133,10 +133,10 @@ public class ExcelHelper
|
||||
package.Stream.Position = 0;
|
||||
return new XlsxFileResult(stream: package.Stream, fileDownloadName: $"{filename}-{DateTime.Now:yyyy-MM-dd_HHmmss}");
|
||||
|
||||
void AddListValidation(int columnIndex, List<string> dataList)
|
||||
void AddListValidation(ExcelWorksheet dropdownSheet, int columnIndex, List<string> dataList)
|
||||
{
|
||||
var validation = worksheet.DataValidations.AddListValidation(worksheet.Cells[2, columnIndex, 999999, columnIndex].Address);
|
||||
validation!.Formula.ExcelFormula = "=下拉数据!" + worksheet.Cells[1, columnIndex, dataList.Count, columnIndex].Address;
|
||||
var validation = worksheet.DataValidations.AddListValidation(worksheet.Cells[2, columnIndex, ExcelPackage.MaxRows, columnIndex].Address);
|
||||
validation!.Formula.ExcelFormula = "=" + dropdownSheet.Cells[1, columnIndex, dataList.Count, columnIndex].FullAddressAbsolute;
|
||||
validation.ShowErrorMessage = true;
|
||||
validation.ErrorTitle = "无效输入";
|
||||
validation.Error = "请从列表中选择一个有效的选项";
|
||||
|
||||
@ -77,8 +77,8 @@
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-flag-icons": "^0.0.3",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vxe-pc-ui": "^4.5.21",
|
||||
"vxe-table": "^4.13.1",
|
||||
"vxe-pc-ui": "^4.5.22",
|
||||
"vxe-table": "^4.13.2",
|
||||
"vxe-table-plugin-element": "^4.0.4",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
||||
"xe-utils": "^3.7.4",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user