using System.Reflection; using DS.Module.Core; using DS.Module.Core.Extensions; using DS.Module.ExcelModule.Model; using DS.Module.SqlSugar; using DS.WMS.Core.Code.Interface; using DS.WMS.Core.System.Entity; using DS.WMS.Core.System.Interface; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; using Org.BouncyCastle.Ocsp; using SqlSugar; using SqlSugar.IOC; using Xunit; namespace Ds.WMS.Test; public class ExcelTest { private readonly IServiceProvider _serviceProvider; private readonly SqlSugarScope db; private readonly ISaasDbService saasService; //private readonly IExcelService _ExcelService; public ExcelTest(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = (SqlSugarScope)_serviceProvider.GetRequiredService(); saasService = _serviceProvider.GetRequiredService(); //_ExcelService = _serviceProvider.GetRequiredService(); } /// /// 获取Json打印信息 /// [Fact] public void GetExportExcleInfo() { List set = new List(); set.Add(new UserColumnSet { DataIndex = "stlCode", Title = "结算方式代码", }); set.Add(new UserColumnSet { DataIndex = "stlName", Title = "结算方式", }); string JsonDataStr = "[{\"id\":\"1767428411736854528\",\"stlCode\":\"1\",\"stlName\":\"支票\",\"enName\":\"Check\",\"financeSoftCode\":\"01\",\"status\":0,\"note\":\"\",\"createTime\":\"2024-03-12 13:52:25\"},{\"id\":\"1767428557304369152\",\"stlCode\":\"2\",\"stlName\":\"汇款\",\"enName\":\"Remittance\",\"financeSoftCode\":\"02\",\"status\":0,\"note\":\"\",\"createTime\":\"2024-03-12 13:53:00\"}]"; var values = new List>(); var data = JArray.Parse(JsonDataStr); for (int i = 0; i < data.Count; i++) { var temp = data[i]; var info = new Dictionary(); for (int n = 0; n < set.Count; n++) { var columnSet = set[n]; var key = columnSet.DataIndex; info.Add(columnSet.Title, temp[key]); } values.Add(info); } Console.WriteLine(values); Assert.True(true); } }