当前位置: 首页 > news >正文

.NET CORE Api 上传excel解析并生成错误excel下载

写在前面的话:

        【对外承接app API开发、网站建设、系统开发,有偿提供帮助,联系方式于文章最下方 】

因业务调整,不再需要生成错误无excel下载,所以先保存代码,回头再重新编辑

#region Excel校验部分if (files == null) throw Oops.Oh("文件不存在");string path = @"upload\{yyyy}\{MM}\{dd}";var reg = new Regex(@"(\{.+?})");var match = reg.Matches(path);match.ToList().ForEach(a =>{var str = DateTime.Now.ToString(a.ToString().Substring(1, a.Length - 2)); // 每天一个目录path = path.Replace(a.ToString(), str);});var sizeKb = (long)(files.Length / 1024.0); // 大小KBif (sizeKb > 1048576)throw Oops.Oh("文件超过允许大小");// 后缀var suffix = Path.GetExtension(files.FileName).ToLower();if (string.IsNullOrWhiteSpace(suffix)){var contentTypeProvider = FS.GetFileExtensionContentTypeProvider();suffix = contentTypeProvider.Mappings.FirstOrDefault(u => u.Value == files.ContentType).Key;}if (string.IsNullOrWhiteSpace(suffix))throw Oops.Oh("文件后缀错误");var finalName = Guid.NewGuid() + suffix;//组合路径并创建文件夹var filePath = Path.Combine(App.WebHostEnvironment.ContentRootPath, path);if (!Directory.Exists(filePath))Directory.CreateDirectory(filePath);//上传文件var realFile = Path.Combine(filePath, finalName);using (var stream = System.IO.File.Create(realFile)){await files.CopyToAsync(stream);}//判断文件格式(通过后缀名及文件头编码判断)byte[] bytes = new byte[4];FileStream fileStream = new FileStream(realFile, FileMode.Open, FileAccess.Read);string temstr = "";if (Convert.ToInt32(fileStream.Length) > 0){fileStream.Read(bytes, 0, 4);fileStream.Close();for (int i = 0; i < bytes.Length; i++){temstr += Convert.ToString(bytes[i], 16);}}var fileHeads = temstr.ToUpper();List<FileTypeModel> fileType = new List<FileTypeModel>();fileType.Add(new FileTypeModel { FileNameStr = "xlsx", FileHeadStr = "504B34" });fileType.Add(new FileTypeModel { FileNameStr = "xls", FileHeadStr = "D0CF11E0" });if (!fileType.Any(p => p.FileHeadStr.Contains(fileHeads)) || string.IsNullOrWhiteSpace(fileHeads)){//删除刚刚上传的文件Directory.Delete(realFile, true);throw Oops.Oh("文件类型错误");}#endregion#region//realFile//接下来就可以开始解析了IWorkbook _wb_xls = null;string fileEx = System.IO.Path.GetExtension(Path.GetFileName(realFile));FileStream _file = new FileStream(realFile, FileMode.Open, FileAccess.Read);if (realFile.IndexOf(".xlsx") > 0)_wb_xls = new XSSFWorkbook(_file);else if (realFile.IndexOf(".xls") > 0)_wb_xls = new HSSFWorkbook(_file);//保存成功信息List<DriverImportList> importList = new List<DriverImportList>();List<DriverImportList> errorList = new List<DriverImportList>();//开始读取excel中数据并作数据校验try{for (int i = 3; i < _wb_xls.GetSheet("DriverData").PhysicalNumberOfRows + 1; i++){var isDataCorrect = true;var cellList = _wb_xls.GetSheet("DriverData").GetRow(i);#region 解析司机个人信息PersonalInformationModel driverModel = new PersonalInformationModel();if (!string.IsNullOrEmpty(cellList.GetCell(1) + ""))driverModel.FirstName = cellList.GetCell(1) + "";//if (!string.IsNullOrEmpty(cellList.GetCell(2) + ""))//    driverModel.MiddleName = cellList.GetCell(2) + "";if (!string.IsNullOrEmpty(cellList.GetCell(3) + ""))driverModel.LastName = cellList.GetCell(3) + "";if (!string.IsNullOrEmpty(cellList.GetCell(4) + "")){driverModel.PhonetNo = cellList.GetCell(4) + "";}else{isDataCorrect = false;driverModel.PhonetNo = "Error!Not Null";}if (!string.IsNullOrEmpty(cellList.GetCell(5) + ""))driverModel.EMail = cellList.GetCell(5) + "";if (!string.IsNullOrEmpty(cellList.GetCell(6) + "")){driverModel.SocialInsurance = cellList.GetCell(6) + "";}else{isDataCorrect = false;driverModel.SocialInsurance = "Error!Not Null";}if (!string.IsNullOrEmpty(cellList.GetCell(7) + "")){driverModel.License = cellList.GetCell(7) + "";}else{isDataCorrect = false;driverModel.License = "Error!Not Null";}if (!string.IsNullOrEmpty(cellList.GetCell(8) + "")){driverModel.LicenseFirstIssueDate = cellList.GetCell(8) + "";}else if (!(cellList.GetCell(8) is DateTime)){isDataCorrect = false;driverModel.LicenseFirstIssueDate = "Error!Must Time Type";}else{isDataCorrect = false;driverModel.LicenseFirstIssueDate = "Error!Not Null";}if (!string.IsNullOrEmpty(cellList.GetCell(9) + "")){driverModel.LicenseFromDate = cellList.GetCell(9) + "";}else if (!(cellList.GetCell(9) is DateTime)){isDataCorrect = false;driverModel.LicenseFromDate = "Error!Must Time Type";}else{isDataCorrect = false;driverModel.LicenseFromDate = "Error!Not Null";}if (!string.IsNullOrEmpty(cellList.GetCell(10) + "")){driverModel.LicenseToDate = cellList.GetCell(10) + "";}else if (!(cellList.GetCell(10) is DateTime)){isDataCorrect = false;driverModel.LicenseToDate = "Error!Must Time Type";}else{isDataCorrect = false;driverModel.LicenseToDate = "Error!Not Null";}#endregion#region 解析司机车辆信息VehicleInformationModel carModel = new VehicleInformationModel();//车辆型号if (!string.IsNullOrEmpty(cellList.GetCell(12) + "")){carModel.CarModelType = cellList.GetCell(12) + "";}else{isDataCorrect = false;carModel.CarModelType = "Error!Not Null";}//车身颜色if (!string.IsNullOrEmpty(cellList.GetCell(13) + "")){carModel.ExteriorColor = cellList.GetCell(13) + "";}else{isDataCorrect = false;carModel.ExteriorColor = "Error!Not Null";}//座位数if (!string.IsNullOrEmpty(cellList.GetCell(14) + "")){carModel.Seats = cellList.GetCell(14) + "";}else{isDataCorrect = false;carModel.Seats = "Error!Not Null";}//出厂日期if (!string.IsNullOrEmpty(cellList.GetCell(15) + "")){carModel.ProductionDate = cellList.GetCell(15) + "";}else{isDataCorrect = false;carModel.ProductionDate = "Error!Not Null";}//车牌号if (!string.IsNullOrEmpty(cellList.GetCell(16) + "")){carModel.LicensePlate = cellList.GetCell(16) + "";}else{isDataCorrect = false;carModel.LicensePlate = "Error!Not Null";}//保险开始日期if (!string.IsNullOrEmpty(cellList.GetCell(17) + "")){carModel.InsuranceFromDate = cellList.GetCell(17) + "";}else{isDataCorrect = false;carModel.InsuranceFromDate = "Error!Not Null";}//保险结束日期if (!string.IsNullOrEmpty(cellList.GetCell(18) + "")){carModel.InsuranceToDate = cellList.GetCell(18) + "";}else{isDataCorrect = false;carModel.InsuranceToDate = "Error!Not Null";}#endregion#region 解析司机其他信息OtherInformation otherModel = new OtherInformation();//台班费if (!string.IsNullOrEmpty(cellList.GetCell(20) + "")){otherModel.Percentage_Or_Amount = cellList.GetCell(20) + "";//台班费收费周期if (!string.IsNullOrEmpty(cellList.GetCell(22) + "")){otherModel.ChargeCycle = cellList.GetCell(22) + "";}else{isDataCorrect = false;otherModel.ChargeCycle = "Error!Not Null";}}//订单抽成if (!string.IsNullOrEmpty(cellList.GetCell(21) + "")){otherModel.Percentage = cellList.GetCell(21) + "";}else{isDataCorrect = false;otherModel.Percentage = "Error!Not Null";}//账户状态if (!string.IsNullOrEmpty(cellList.GetCell(23) + "")){otherModel.IsEnabled = cellList.GetCell(23) + "";}else{isDataCorrect = false;otherModel.IsEnabled = "Error!Not Null";}#endregion//如果该条数据数据校验全通过,则添加到list中准备入库if (isDataCorrect){DriverImportList db_import = new DriverImportList();db_import.PersonalInformationModel = driverModel;db_import.VehicleInformationModel = carModel;db_import.OtherInformation = otherModel;importList.Add(db_import);}else{DriverImportList errorModel = new DriverImportList();errorModel.PersonalInformationModel = driverModel;errorModel.VehicleInformationModel = carModel;errorModel.OtherInformation = otherModel;errorList.Add(errorModel);}}}catch (Exception ex){throw Oops.Oh("解析失败,请在下载的模板文件上进行编辑并上传");}#endregion//表头信息var headers = new List<ExcelHeader>{//司机信息new ExcelHeader{ Adress="B2", Value="PersonalInformation\r\n(司机信息)" },new ExcelHeader{ Adress="B3",Width=15,Value="First_Name"},new ExcelHeader{ Adress="C3",Width=15,Value="Last_Name"},new ExcelHeader{ Adress="D3",Width=15,Value="Phonet_No"},new ExcelHeader{ Adress="E3",Width=15,Value="E_Mail"},new ExcelHeader{ Adress="F3",Width=30,Value="Social_Insurance\r\n(社会保险)"},new ExcelHeader{ Adress="G3",Width=15,Value="License\r\n(驾照)"},new ExcelHeader{ Adress="H3",Width=40,Value="License_First_Issue_Date\r\n(驾照首次领证日期)"},new ExcelHeader{ Adress="I3",Width=35,Value="License_From_Date\r\n(驾照起始日期)"},new ExcelHeader{ Adress="J3",Width=35,Value="License_To_Date\r\n(驾照结束日期)"},//车辆信息new ExcelHeader{ Adress="L2", Value="VehicleInformation\r\n(车辆信息)"},new ExcelHeader{ Adress="L3",Width=25,Value="Car_Model_Type\r\n(车辆型号)"},new ExcelHeader{ Adress="M3",Width=25,Value="Exterior_Color\r\n(车辆颜色)"},new ExcelHeader{ Adress="N3",Width=25,Value="Seats\r\n(座椅数量)"},new ExcelHeader{ Adress="O3",Width=25,Value="Production_Date\r\n(出厂日期)"},new ExcelHeader{ Adress="P3",Width=25,Value="License_Plate\r\n(车牌号)"},new ExcelHeader{ Adress="Q3",Width=25,Value="Insurance_From_Date\r\n(保险起始日期)"},new ExcelHeader{ Adress="R3",Width=25,Value="Insurance_To_Date\r\n(保险结束日期)"},//其他信息new ExcelHeader{ Adress="T2", Value="OtherInformation\r\n(其他信息)"},new ExcelHeader{ Adress="T3",Width=30,Value="Percentage_Or_Amount\r\n\r\n(台班费)"},new ExcelHeader{ Adress="U3",Width=30,Value="Percentage\r\n(订单抽成)"},new ExcelHeader{ Adress="V3",Width=30,Value="ChargeCycle\r\n(台班费收费周期)"},new ExcelHeader{ Adress="W3",Width=30,Value="IsEnabled\r\n(账户状态)"},};string localPath = AppDomain.CurrentDomain.BaseDirectory + System.DateTime.Now.ToString("yyyyMMdd");var filepath = Path.Combine(localPath, $"{DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")}.xlsx");FileInfo file = new FileInfo(filepath);if (file.Exists){file.Delete();file = new FileInfo(filepath);}//创建文件夹if (!Directory.Exists(localPath))Directory.CreateDirectory(localPath);ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;ExcelPackage package = new ExcelPackage(file);//创建sheetExcelWorksheet worksheet = package.Workbook.Worksheets.Add("DriverData");//生成表头for (int i = 0; i < headers.Count; i++){worksheet.Cells[headers[i].Adress].Value = headers[i].Value;//合并单元格worksheet.Cells[2, 2, 2, 12].Merge = true;worksheet.Cells[2, 14, 2, 23].Merge = true;worksheet.Cells[2, 24, 2, 26].Merge = true;worksheet.Cells[headers[i].Adress].Style.Font.Size = 12; //字体大小worksheet.Cells[headers[i].Adress].Style.Font.Bold = true; //设置粗体worksheet.Cells[headers[i].Adress].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; //水平居中对齐worksheet.Cells[headers[i].Adress].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; //垂直居中对齐if (headers[i].Width > 0)worksheet.Column(ColumnIndex(headers[i].Adress)).Width = headers[i].Width;//给第三行设置行高worksheet.Row(3).Height = 35;//设置表格边框线(设置单元格所有边框)#region 表头设置边框线worksheet.Cells["B2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["C2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["D2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["E2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["F2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["G2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["H2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["I2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["J2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["L2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["M2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["N2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["O2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["P2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["Q2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["R2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["S2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["T2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["V2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["W2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["X2"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["B3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["C3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["D3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["E3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["F3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["G3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["H3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["I3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["J3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["L3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["M3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["N3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["O3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["P3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["Q3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["R3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["S3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["T3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["V3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["W3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));worksheet.Cells["X3"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));//worksheet.Cells[1, 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;//单独设置单元格底部边框样式和颜色(上下左右均可分开设置)//worksheet.Cells[1, 1].Style.Border.Bottom.Color.SetColor(Color.FromArgb(191, 191, 191));#endregion}//循环填充内容if (errorList != null){//设置背景色Color colFromHex = System.Drawing.ColorTranslator.FromHtml("#7fcbfe");for (int i = 0; i < errorList.Count; i++){if (errorList[i].PersonalInformationModel != null){//姓worksheet.Cells["B" + (4 + i)].Value = errorList[i].PersonalInformationModel.FirstName;worksheet.Cells["B" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.FirstName != null && errorList[i].PersonalInformationModel.FirstName.IndexOf("Error!") > -1){worksheet.Cells["B" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["B" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//名worksheet.Cells["C" + (4 + i)].Value = errorList[i].PersonalInformationModel.LastName;worksheet.Cells["C" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.LastName != null && errorList[i].PersonalInformationModel.LastName.IndexOf("Error!") > -1){worksheet.Cells["C" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["C" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//电话号码worksheet.Cells["D" + (4 + i)].Value = errorList[i].PersonalInformationModel.PhonetNo;worksheet.Cells["D" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.PhonetNo != null && errorList[i].PersonalInformationModel.PhonetNo.IndexOf("Error!") > -1){worksheet.Cells["D" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["D" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//邮箱worksheet.Cells["E" + (4 + i)].Value = errorList[i].PersonalInformationModel.EMail;worksheet.Cells["E" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.EMail != null && errorList[i].PersonalInformationModel.EMail.IndexOf("Error!") > -1){worksheet.Cells["E" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["E" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//社会保障号worksheet.Cells["F" + (4 + i)].Value = errorList[i].PersonalInformationModel.SocialInsurance;worksheet.Cells["F" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.SocialInsurance != null && errorList[i].PersonalInformationModel.SocialInsurance.IndexOf("Error!") > -1){worksheet.Cells["F" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["F" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//驾照号码worksheet.Cells["G" + (4 + i)].Value = errorList[i].PersonalInformationModel.License;worksheet.Cells["G" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.License != null && errorList[i].PersonalInformationModel.License.IndexOf("Error!") > -1){worksheet.Cells["G" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["G" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//初次领证日期worksheet.Cells["H" + (4 + i)].Value = errorList[i].PersonalInformationModel.LicenseFirstIssueDate;worksheet.Cells["H" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.LicenseFirstIssueDate != null && errorList[i].PersonalInformationModel.LicenseFirstIssueDate.IndexOf("Error!") > -1){worksheet.Cells["H" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["H" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//驾照起始日期worksheet.Cells["I" + (4 + i)].Value = errorList[i].PersonalInformationModel.LicenseFromDate;worksheet.Cells["I" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.LicenseFromDate != null && errorList[i].PersonalInformationModel.LicenseFromDate.IndexOf("Error!") > -1){worksheet.Cells["I" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["I" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//驾照结束日期worksheet.Cells["J" + (4 + i)].Value = errorList[i].PersonalInformationModel.LicenseToDate;worksheet.Cells["J" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].PersonalInformationModel.LicenseToDate != null && errorList[i].PersonalInformationModel.LicenseToDate.IndexOf("Error!") > -1){worksheet.Cells["J" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["J" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}}if (errorList[i].VehicleInformationModel != null){//车辆型号worksheet.Cells["M" + (4 + i)].Value = errorList[i].VehicleInformationModel.CarModelType;worksheet.Cells["M" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].VehicleInformationModel.CarModelType != null && errorList[i].VehicleInformationModel.CarModelType.IndexOf("Error!") > -1){worksheet.Cells["M" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["M" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//车身颜色worksheet.Cells["N" + (4 + i)].Value = errorList[i].VehicleInformationModel.ExteriorColor;worksheet.Cells["N" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].VehicleInformationModel.ExteriorColor != null && errorList[i].VehicleInformationModel.ExteriorColor.IndexOf("Error!") > -1){worksheet.Cells["N" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["N" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//座位数worksheet.Cells["O" + (4 + i)].Value = errorList[i].VehicleInformationModel.Seats;worksheet.Cells["O" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].VehicleInformationModel.Seats != null && errorList[i].VehicleInformationModel.Seats.IndexOf("Error!") > -1){worksheet.Cells["O" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["O" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//出厂日期worksheet.Cells["P" + (4 + i)].Value = errorList[i].VehicleInformationModel.ProductionDate;worksheet.Cells["P" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].VehicleInformationModel.ProductionDate != null && errorList[i].VehicleInformationModel.ProductionDate.IndexOf("Error!") > -1){worksheet.Cells["P" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["P" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//车牌号worksheet.Cells["Q" + (4 + i)].Value = errorList[i].VehicleInformationModel.LicensePlate;worksheet.Cells["Q" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].VehicleInformationModel.LicensePlate != null && errorList[i].VehicleInformationModel.LicensePlate.IndexOf("Error!") > -1){worksheet.Cells["Q" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["Q" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//保险起始日期worksheet.Cells["R" + (4 + i)].Value = errorList[i].VehicleInformationModel.InsuranceFromDate;worksheet.Cells["R" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].VehicleInformationModel.InsuranceFromDate != null && errorList[i].VehicleInformationModel.InsuranceFromDate.IndexOf("Error!") > -1){worksheet.Cells["R" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["R" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//保险结束日期worksheet.Cells["S" + (4 + i)].Value = errorList[i].VehicleInformationModel.InsuranceToDate;worksheet.Cells["S" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].VehicleInformationModel.InsuranceToDate != null && errorList[i].VehicleInformationModel.InsuranceToDate.IndexOf("Error!") > -1){worksheet.Cells["S" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["S" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}}if (errorList[i].OtherInformation != null){//台班费worksheet.Cells["X" + (4 + i)].Value = errorList[i].OtherInformation.Percentage_Or_Amount;worksheet.Cells["X" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].OtherInformation.Percentage_Or_Amount.IndexOf("Error!") > -1){worksheet.Cells["X" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["X" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//订单抽成worksheet.Cells["X" + (4 + i)].Value = errorList[i].OtherInformation.Percentage;worksheet.Cells["X" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].OtherInformation.Percentage.IndexOf("Error!") > -1){worksheet.Cells["X" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["X" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//台班费收费周期worksheet.Cells["X" + (4 + i)].Value = errorList[i].OtherInformation.ChargeCycle;worksheet.Cells["X" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].OtherInformation.ChargeCycle.IndexOf("Error!") > -1){worksheet.Cells["X" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["X" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}//账户状态worksheet.Cells["X" + (4 + i)].Value = errorList[i].OtherInformation.IsEnabled;worksheet.Cells["X" + (4 + i)].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(0, 0, 0));if (errorList[i].OtherInformation.IsEnabled.IndexOf("Error!") > -1){worksheet.Cells["X" + (4 + i)].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;worksheet.Cells["X" + (4 + i)].Style.Fill.BackgroundColor.SetColor(colFromHex);}}}}package.Save();//转成流之后下载using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read)){byte[] byteArray = new byte[fs.Length];fs.Read(byteArray, 0, byteArray.Length);//删除昨日生成的excel文件夹System.IO.File.Delete(AppDomain.CurrentDomain.BaseDirectory + System.DateTime.Now.AddDays(-1).ToString("yyyyMMdd"));return new FileContentResult(byteArray, "application/octet-stream"){FileDownloadName = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}错误记录.xlsx"};}/// <summary>
/// 根据单元格地址计算出单元格所在列的索引
/// </summary>
/// <param name="reference">单元格地址,示例A1,AB2</param>
/// <returns></returns>
private static int ColumnIndex(string reference)
{int ci = 0;reference = reference.ToUpper();for (int ix = 0; ix < reference.Length && reference[ix] >= 'A'; ix++)ci = (ci * 26) + ((int)reference[ix] - 64);return ci;
}

model部分


public class DriverImportList
{public PersonalInformationModel PersonalInformationModel { get; set; }public VehicleInformationModel VehicleInformationModel { get; set; }public OtherInformation OtherInformation { get; set; }
}/// <summary>
/// excel上传、司机个人信息
/// </summary>
public class PersonalInformationModel
{/// <summary>/// 姓/// </summary>public string FirstName { get; set; }/// <summary>/// 名/// </summary>public string LastName { get; set; }/// <summary>/// 电话号码/// </summary>public string PhonetNo { get; set; }/// <summary>/// 邮箱/// </summary>public string EMail { get; set; }/// <summary>/// 社会保障号/// </summary>public string SocialInsurance { get; set; }/// <summary>/// 驾照/// </summary>public string License { get; set; }/// <summary>/// 初次领证日期/// </summary>public string LicenseFirstIssueDate { get; set; }/// <summary>/// 驾照有效期起始时间/// </summary>public string LicenseFromDate { get; set; }/// <summary>/// 驾照有效期结束时间/// </summary>public string LicenseToDate { get; set; }
}/// <summary>
/// excel上传、车辆相关信息
/// </summary>
public class VehicleInformationModel
{/// <summary>/// 车辆型号/// </summary>public string CarModelType { get; set; }/// <summary>/// 车身颜色/// </summary>public string ExteriorColor { get; set; }/// <summary>/// 座椅数量/// </summary>public string Seats { get; set; }/// <summary>/// 出厂日期/// </summary>public string ProductionDate { get; set; }/// <summary>/// 车牌号/// </summary>public string LicensePlate { get; set; }/// <summary>/// 保险开始日期/// </summary>public string InsuranceFromDate { get; set; }/// <summary>/// 保险结束日期/// </summary>public string InsuranceToDate { get; set; }
}/// <summary>
/// excel上传、其他杂项信息
/// </summary>
public class OtherInformation
{ /// <summary>/// 台班费/// </summary>public string Percentage_Or_Amount { get; set; }/// <summary>/// 台班费收费周期/// </summary>public string ChargeCycle { get; set; }/// <summary>/// 订单抽成/// </summary>public string Percentage { get; set; }/// <summary>/// 账户状态/// </summary>public string IsEnabled { get; set; } 
}public class ExcelHeader
{/// <summary>/// 单元格地址A1,B2等/// </summary>public string Adress { get; set; }/// <summary>/// 单元格值/// </summary>public string Value { get; set; }/// <summary>/// 单元格合并区域,示例A1:B2,为空表示不合并/// </summary>public string MergeArea { get; set; }/// <summary>/// 列宽度,合并列不需要指定宽度,示例:/// | A |/// |B|C|/// 表头A是单元格B和单元格C合并而来,不需要指定宽度,只指定B和C宽度即可/// </summary>public int Width { get; set; }
}

参考文档

1、Asp.NET Core 导出数据到 Excel 文件 - 码农教程

2、.net5下使用EPPlus导出Excel(复杂表头)_.net 导出excel 多表头_数据的流的博客-CSDN博客

3、Excel操作库--EPPLUS常用操作命令汇总(1)_韦_恩的博客-CSDN博客
 

联系方式:

                 wechat&QQ&Tel:13501715983(如查不到请加QQ:631931078或352167311)

                 个人邮箱:13212644043@163.com

OK,暂且这样~

相关文章:

.NET CORE Api 上传excel解析并生成错误excel下载

写在前面的话&#xff1a; 【对外承接app API开发、网站建设、系统开发&#xff0c;有偿提供帮助&#xff0c;联系方式于文章最下方 】 因业务调整&#xff0c;不再需要生成错误无excel下载&#xff0c;所以先保存代码&#xff0c;回头再重新编辑 #region Excel校验部分if (f…...

数据结构,二叉树,前中后序遍历

二叉树的种类 最优二叉树 最优二叉树画法 排序取最小两个值和&#xff0c;得到新值加入排序重复1&#xff0c;2 前序、中序和后序遍历是树形数据结构&#xff08;如二叉树&#xff09;中常用的遍历方式&#xff0c;用于按照特定顺序遍历树的节点。这些遍历方式在不同应用中有不…...

项目实战笔记2:硬技能(上)

序&#xff1a; 本节串讲了项目管理硬技能&#xff0c;有些术语可以结合书或者网上资料来理解。没有想书上讲的那样一一列举。 做计划 首先强调为什么做计划&#xff1f; 计划就是各个角色协同工作的基准&#xff08;后面做风险监控、进度的监控&#xff09;&#xff0c;贯穿于…...

神经网络基础-神经网络补充概念-59-padding

概念 在深度学习中&#xff0c;“padding”&#xff08;填充&#xff09;通常是指在卷积神经网络&#xff08;Convolutional Neural Networks&#xff0c;CNNs&#xff09;等神经网络层中&#xff0c;在输入数据的周围添加额外的元素&#xff08;通常是零&#xff09;&#xf…...

【开源免费】ChatGPT-Java版SDK重磅更新收获2.3k,支持插件模式、实现ChatGpt联网操作。

everybody 七夕来了还单着么&#xff1f; 一、简介 ChatGPT Java版SDK开源地址&#xff1a;https://github.com/Grt1228/chatgpt-java&#xff0c;目前收获将近2200个star&#x1f31f;。 最新版&#xff1a;1.1.1-beta0 <dependency><groupId>com.unfbx</g…...

情报与GPT技术大幅降低鱼叉攻击成本

邮件鱼叉攻击&#xff08;spear phishing attack&#xff09;是一种高度定制化的网络诈骗手段&#xff0c;攻击者通常假装是受害人所熟知的公司或组织发送电子邮件&#xff0c;以骗取受害人的个人信息或企业机密。 以往邮件鱼叉攻击需要花费较多的时间去采集情报、深入了解受…...

Swift 周报 第三十五期

文章目录 前言新闻和社区五天市值蒸发 2000 亿美元&#xff0c;苹果公司怎么了&#xff1f;在你的 App 中帮助顾客解决账单问题需要声明原因的 API 列表现已推出 提案通过的提案正在审查的提案 Swift论坛推荐博文话题讨论关于我们 前言 本期是 Swift 编辑组整理周报的第三十五…...

uni-app + SpringBoot +stomp 支持websocket 打包app

文章目录 一、概述&#xff1a;二、配置&#xff1a;1. 后端配置2. uni-app(app端)3. 使用 一、概述&#xff1a; websocket 协议是在http 协议的基础上的升级&#xff0c;通过一次http 请求建立长连接&#xff0c;转而变为TCP 的全双工通信&#xff1b;而http 协议是一问一答…...

LeetCode--HOT100题(35)

目录 题目描述&#xff1a;23. 合并 K 个升序链表&#xff08;困难&#xff09;题目接口解题思路1代码解题思路2代码 PS: 题目描述&#xff1a;23. 合并 K 个升序链表&#xff08;困难&#xff09; 给你一个链表数组&#xff0c;每个链表都已经按升序排列。 请你将所有链表合…...

idea插件grep console最佳实践

首发博客地址 https://blog.zysicyj.top/ 参考博客&#xff1a;https://blog.csdn.net/ayunnuo/article/details/123997304 效果 配置 具体颜色 日志级别前景色背景色Error#FF0000#370000Warn#FFC033#1A0037Info#00FFF3无Debug#808080无 本文由 mdnice 多平台发布...

Android 12 源码分析 —— 应用层 二(SystemUI大体组织和启动过程)

Android 12 源码分析 —— 应用层 二&#xff08;SystemUI大体组织和启动过程&#xff09; 在前一篇文章中&#xff0c;我们介绍了SystemUI怎么使用IDE进行编辑和调试。这是分析SystemUI的最基础&#xff0c;希望读者能尽量掌握。 本篇文章&#xff0c;将会介绍SystemUI的大概…...

【C#】通用类型转换

【C#】通用类型转换 自动类型转换&#xff08;隐式类型转换&#xff09;强制类型转换&#xff08;显式类型转换&#xff09;通过函数进行转换&#xff08;通过方法进行类型转换&#xff09;使用 as 操作符转换通用类型转换方法实现 数据类型转换就是将数据&#xff08;变量、数…...

传统DNS、负载均衡服务发现框架与专业服务发现框架(Eurek、nacos)分析

1、DNS 服务器 DNS 服务器可以在一定程度上用作服务发现的机制&#xff0c;以下是其冲动服务发现的一些利弊 优势 广泛性&#xff1a; DNS是互联网的标准协议之一&#xff0c;已经广泛地被支持和使用。因此&#xff0c;使用DNS作为服务发现的机制可以借助现有的网络基础设施…...

js中数组常用操作函数

js数组经常会用到&#xff0c;当涉及到 JavaScript 数组的函数&#xff0c;有许多常用的函数可用于对数组进行操作和转换。以下是一些常见的数组函数的讲解 splice() splice() 函数用于修改数组&#xff0c;可以删除、插入或替换数组中的元素。 var fruits [apple, banana,…...

Windows、Mac、Linux端口占用解决

Windows、Mac、Linux端口占用解决 简介 在使用计算机网络时&#xff0c;经常会遇到端口被占用的问题。当一个应用程序尝试使用已经被其他程序占用的端口时&#xff0c;会导致端口冲突&#xff0c;使应用程序无法正常运行。本文将介绍在Windows、Mac和Linux操作系统上解决端口…...

企业文件透明加密软件——「天锐绿盾」数据防泄密管理软件系统

PC访问地址&#xff1a; 首页 一、文档透明加密软件 文档透明加密功能&#xff1a;在不影响单位内部员工对电脑任何正常操作的前提下&#xff0c;文档在复制、新建、修改时被系统强制自动加密。文档只能在单位内部电脑上正常使用&#xff0c;在外部电脑上使用是乱码或无法打…...

Postman接口自动化测试实例

一.实例背景 在实际业务中&#xff0c;经常会出现让用户输入用户密码进行验证的场景。而为了安全&#xff0c;一般都会先请求后台服务器获取一个随机数做为盐值&#xff0c;然后将盐值和用户输入的密码通过前端的加密算法生成加密后串传给后台服务器&#xff0c;后台服务器接到…...

软件团队降本增效-构建人员评价体系

在软件团队中&#xff0c;最大成本往往来自于人力。这是因为软件开发是一项高度技术密集和智力密集的工作&#xff0c;需要研发人员具备较高的专业知识和技能。研发人员的工作状态和主动性对产出和质量具有极大的影响。如果研发人员缺乏积极性和投入度&#xff0c;可能会导致项…...

Python实现SSA智能麻雀搜索算法优化随机森林分类模型(RandomForestClassifier算法)项目实战

说明&#xff1a;这是一个机器学习实战项目&#xff08;附带数据代码文档视频讲解&#xff09;&#xff0c;如需数据代码文档视频讲解可以直接到文章最后获取。 1.项目背景 麻雀搜索算法(Sparrow Search Algorithm, SSA)是一种新型的群智能优化算法&#xff0c;在2020年提出&a…...

web JS高德地图标点、点聚合、自定义图标、自定义窗体信息、换肤等功能实现和高复用性组件封装教程

文章目录 前言一、点聚合是什么&#xff1f;二、开发前准备三、API示例1.引入高德地图2.创建地图实例3.添加标点4.删除标点5.删除所有标点&#xff08;覆盖物&#xff09;6.聚合点7.自定义聚合点样式8.清除聚合9.打开窗体信息 四、实战开发需求要求效果图如下&#xff1a;封装思…...

AlpacaFarm: A Simulation Framework for Methods that Learn from Human Feedback

本文是LLM系列文章&#xff0c;针对《》的翻译。 AlpacaFarm:从人类反馈中学习方法的模拟框架 摘要1 引言2 背景与问题描述3 构造AlpacaFarm4 验证AlpacaFarm模拟器5 AlpacaFarm的基准参考方法6 相关工作7 不足和未来方向 摘要 像ChatGPT这样的大型语言模型由于能够很好地遵循…...

【Linux】Linux工具篇(yum、vim、gcc/g++、gdb、Makefile、git)

&#x1f680; 作者简介&#xff1a;一名在后端领域学习&#xff0c;并渴望能够学有所成的追梦人。 &#x1f681; 个人主页&#xff1a;不 良 &#x1f525; 系列专栏&#xff1a;&#x1f6f9;Linux &#x1f6f8;C &#x1f4d5; 学习格言&#xff1a;博观而约取&#xff…...

自己实现 SpringMVC 底层机制 系列之-实现任务阶段 5- 完成 Spring 容器对象的自动装配 -@Autowried

&#x1f600;前言 自己实现 SpringMVC 底层机制 系列之-实现任务阶段 5- 完成 Spring 容器对象的自动装配 -Autowried &#x1f3e0;个人主页&#xff1a;尘觉主页 &#x1f9d1;个人简介&#xff1a;大家好&#xff0c;我是尘觉&#xff0c;希望我的文章可以帮助到大家&…...

linux的http服务

Web通信基本概念 基于B/S&#xff08;Browser/Server&#xff09;架构的网页服务 服务端提供网页 浏览器下载并显示网页 Hyper Text Markup Lanuage,超文本标记语言 Hyper Text Transfer Protocol&#xff0c;超文本传输协议 虚拟机A&#xff1a;构建基本的Web服务 [root…...

Restful架构简单了解

Restful Rest全称representational status transfer 表述性状态转移。 原则 资源与URI URI既可以看成是资源的地址&#xff0c;也可以看成是资源的名称。如果某些信息没有使用URI来表示&#xff0c;那它就不能算是一个资源&#xff0c; 只能算是资源的一些信息而已。URI的设计…...

conda常用命令

使用conda可以在电脑上创建很多套相互隔离的Python环境&#xff0c;命令如下&#xff1a; 创建环境 创建一个名为deeplearning的环境&#xff0c;python版本为3.7 conda create --name deeplearning python3.7查看版本 conda --version切换环境 切换到deeplearning环境 c…...

Linux:shell脚本:基础使用(6)《正则表达式-awk工具》

简介 awk是行处理器: 相比较屏幕处理的优点&#xff0c;在处理庞大文件时不会出现内存溢出或是处理缓慢的问题&#xff0c;通常用来格式化文本信息 awk处理过程: 依次对每一行进行处理&#xff0c;然后输出 1&#xff09;awk命令会逐行读取文件的内容进行处理 2&#xff09;a…...

国际阿里云腾讯云:阿里云服务器怎么打包

近年来&#xff0c;跟着云计算的发展&#xff0c;越来越多的人开始运用云服务器来保管自己的运用和网站。其间&#xff0c;阿里云服务器是国内最大的云计算服务供给商之一&#xff0c;能够供给高效安稳的服务器服务。可是&#xff0c;阿里云服务器的打包办法相较于其他云服务器…...

FPGA中锁存器(latch)、触发器(flip-flop)以及寄存器(register)详解

文章目录 1 定义1.1 锁存器&#xff08;latch&#xff09;1.2 触发器&#xff08;flip-flop&#xff09;1.3 寄存器&#xff08;register&#xff09; 2 比较2.1 锁存器&#xff08;Latch&#xff09;危害即产生原因2.2 寄存器和锁存器的区别2.3 锁存器和触发器的区别 3 结构3.…...

【正点原子STM32连载】第十八章 通用定时器PWM输出实验 摘自【正点原子】APM32F407最小系统板使用指南

1&#xff09;实验平台&#xff1a;正点原子stm32f103战舰开发板V4 2&#xff09;平台购买地址&#xff1a;https://detail.tmall.com/item.htm?id609294757420 3&#xff09;全套实验源码手册视频下载地址&#xff1a; http://www.openedv.com/thread-340252-1-1.html# 第十…...

分类预测 | MATLAB实现BWO-TCN-Attention数据分类预测

分类预测 | MATLAB实现BWO-TCN-Attention数据分类预测 目录 分类预测 | MATLAB实现BWO-TCN-Attention数据分类预测分类效果基本描述程序设计参考资料 分类效果 基本描述 1.BWO-TCN-Attention数据分类预测程序&#xff1b; 2.无Attention适用于MATLAB 2022b版及以上版本&#xf…...

6.链路追踪-Zipkin

链路追踪&#xff08;Distributed Tracing&#xff09;是一种用于监视分布式应用程序的技术&#xff0c;通过收集和展示分布式系统中不同组件之间的调用和交互情况&#xff0c;帮助开发人员和运维团队理解系统中的请求流程、性能瓶颈和异常情况。 1.Zipkin Zipkin 是一个开源的…...

基于ACF,AMDF算法的语音编码matlab仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 5.算法完整程序工程 1.算法运行效果图预览 2.算法运行软件版本 matlab2022a 3.部分核心程序 .......................................................................... plotFlag …...

python 基础篇 day 1 初识变量和数据类型

文章目录 变量变量作用——用于存储和表示数据。变量命名规则命名法大驼峰小驼峰下划体n j i a x 通常作为临时变量使用 建议 变量种类全局变量&#xff08;Global Variables&#xff09;局部变量&#xff08;Local Variables&#xff09;静态变量&#xff08;Static Variables…...

Window下部署使用Stable Diffusion AI开源项目绘图

Window下部署使用Stable Diffusion AI开源项目绘图 前言前提条件相关介绍Stable Diffusion AI绘图下载项目环境要求环境下载运行项目打开网址&#xff0c;即可体验文字生成图像&#xff08;txt2img&#xff09;庐山瀑布 参考 本文里面的风景图&#xff0c;均由Stable Diffusion…...

【MySQL】好好学习一下InnoDB中的页

文章目录 一. 前言二. 从宏观层面看页三. 页的基本内容3.1 页的数据结构3.2 用户空间内的数据行结构3.3 页目录 四. 问题集4.1 索引 和 数据页 有什么区别4.2 页的大小是什么决定的4.3 页的大小对哪些情况有影响4.4 一般情况下说的链表有哪几个4.5 如果页的空间满了怎么办4.6 如…...

git开发常用命令

版本回退 soft&#xff1a;git reset --soft HEAD^ 将版本库回退一个版本&#xff0c;且这次提交的所有文件都移动到暂存区 mixed&#xff08;默认&#xff09;&#xff1a;git reset HEAD^ 将版本库回退一个版本&#xff0c;且这次提交的所有文件都移动到工作区&#xff0c;会…...

WEB APIs day5

一、window对象 BOM属于window对象 1.BOM&#xff08;浏览器对象模型&#xff09; bom里面包含着dom,只不过bom我们平时用得比较少&#xff0c;我们经常使用的是dom操作&#xff0c;因为我们页面中的这些标签都是在dom中取的&#xff0c;所以我们操作dom多一点。 window对象…...

html动态爱心代码【一】(附源码)

前言 七夕马上就要到了&#xff0c;为了帮助大家高效表白&#xff0c;下面再给大家带来了实用的HTML浪漫表白代码(附源码)背景音乐&#xff0c;可用于520&#xff0c;情人节&#xff0c;生日&#xff0c;表白等场景&#xff0c;可直接使用。 效果演示 文案修改 var loverNam…...

【仿写tomcat】六、解析xml文件配置端口、线程池核心参数

线程池改造 上一篇文章中我们用了Excutors创建了线程&#xff0c;这里我们将它改造成包含所有线程池核心参数的形式。 package com.tomcatServer.http;import java.util.concurrent.*;/*** 线程池跑龙套** author ez4sterben* date 2023/08/05*/ public class ThreadPool {pr…...

Android Studio 接入OpenCV最简单的例子 : 实现灰度图效果

1. 前言 上文 我们在Windows电脑上实现了人脸功能&#xff0c;接下来我们要把人脸识别的功能移植到Android上。 那么首先第一步&#xff0c;就是要创建一个Native的Android项目&#xff0c;并且配置好OpenGL&#xff0c;并能够调用成功。 这里我们使用的是openCV-4.8.0&#x…...

(1)、扩展SpringCache一站式解决缓存击穿,穿透,雪崩

1、问题描述 我们在使用SpringCache的@Cacheable注解时,发现并没有设置过期时间这个功能。 @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @I...

Rancher使用cert-manager安装报错解决

报错&#xff1a; rancher-rke-01:~/rke/rancher-helm/rancher # helm install rancher rancher-stable/rancher --namespace cattle-system --set hostnamewww.rancher.local Error: INSTALLATION FAILED: Internal error occurred: failed calling webhook "webhook…...

Harvard transformer NLP 模型 openNMT 简介入门

项目网址&#xff1a; OpenNMT - Open-Source Neural Machine Translation logo&#xff1a; 一&#xff0c;从应用的层面先跑通 Harvard transformer GitHub - harvardnlp/annotated-transformer: An annotated implementation of the Transformer paper. ​git clone https…...

【数据结构OJ题】用栈实现队列

原题链接&#xff1a;https://leetcode.cn/problems/implement-queue-using-stacks/ 目录 1. 题目描述 2. 思路分析 3. 代码实现 1. 题目描述 2. 思路分析 用两个栈实现&#xff0c;一个栈进行入队操作&#xff0c;另一个栈进行出队操作。 出队操作&#xff1a; 当出队的栈…...

通达信指标公式15:除权除息数据统计分析

#1.关于除权除息指标的介绍&#xff1a;本指标是小红牛原创指标之一&#xff0c;觉得有必要研究一下这个问题&#xff0c;所以就花时间整理一下这个指标相关内容&#xff0c;大家可以在本源码基础上&#xff0c;进一步优化自己的思路。本指标为通达信幅图指标&#xff0c;可以做…...

day-27 代码随想录算法训练营(19)回溯part03

39.组合总和 分析&#xff1a;同一个数可以选多次&#xff0c;但是不能有重复的答案&#xff1b; 思路&#xff1a;横向遍历&#xff0c;纵向递归&#xff08;不同的是递归的时候不需要跳到下一个位置&#xff0c;因为同一个数可以选多次&#xff09; class Solution { publ…...

CSDN编程题-每日一练(2023-08-22)

CSDN编程题-每日一练(2023-08-22) 一、题目名称:最长递增区间二、题目名称:K树三、题目名称:小Q的价值无向图一、题目名称:最长递增区间 时间限制:1000ms内存限制:256M 题目描述: 给一个无序数组,求最长递增的区间长度。如:[5,2,3,8,1,9] 最长区间 2,3,8 长度为 3。…...

使用 KubeBlocks 为 K8s 提供稳如老狗的数据库服务

原文链接&#xff1a;https://forum.laf.run/d/994 大家好&#xff01;今天这篇文章主要向大家介绍 Sealos 的数据库服务。在 Sealos 上数据库后端服务由 KubeBlocks 提供&#xff0c;为用户的数据库应用保驾护航。无论你是在公有云还是本地环境中使用&#xff0c;Sealos 都能为…...

SFL212B-10-21-15、SFL212B-20-21-40喷嘴挡板伺服阀

SFL212B-05-21-10、SFL212B-10-21-15、SFL212B-20-21-40、SFL212-05-32-10、SFL212-10-32-15、SFL212-20-32-40、SFL212A-05-21-10、SFL212A-10-21-15、SFL212A-20-21-40喷嘴挡板力反馈伺服阀&#xff0c;外置伺服放大器&#xff0c;四通&#xff0c;带阀芯阀套的两级伺服阀&am…...