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

.NET Core6.0使用NPOI导入导出Excel

一、使用NPOI导出Excel
//引入NPOI包
在这里插入图片描述

  • HTML
<input type="button" class="layui-btn layui-btn-blue2 layui-btn-sm" id="ExportExcel" onclick="ExportExcel()" value="导出" />
  • JS
    //导出Excelfunction ExportExcel() {window.location.href = "@Url.Action("ExportFile")";}
  • C#
 private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;public HomeController(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment){_hostingEnvironment = hostingEnvironment;}[HttpGet("ExportFile")]//导出文件public async Task<IActionResult> ExportFile(){//获取数据库数据var result = await _AnsweringQuestion.GetTeacherName();string filePath = "";//获取文件路径和名称var wwwroot = _hostingEnvironment.WebRootPath;var filename = "Table.xlsx";filePath = Path.Combine(wwwroot, filename);//创建一个工作簿和工作表NPOI.XSSF.UserModel.XSSFWorkbook book = new NPOI.XSSF.UserModel.XSSFWorkbook();var sheet = book.CreateSheet();//创建表头行var headerRow = sheet.CreateRow(0);headerRow.CreateCell(0).SetCellValue("姓名");headerRow.CreateCell(1).SetCellValue("科目");headerRow.CreateCell(2).SetCellValue("说明");//创建数据行var data = result.DataList;for (int i = 0; i < data.Count(); i++){var dataRow = sheet.CreateRow(i + 1);dataRow.CreateCell(0).SetCellValue(data[i].TeacherName);dataRow.CreateCell(1).SetCellValue(data[i].TeachSubject); dataRow.CreateCell(2).SetCellValue(data[i].TeacherDesc);}//将Execel 文件写入磁盘using (var f = System.IO.File.OpenWrite(filePath)){book.Write(f);}//将Excel 文件作为下载返回给客户端var bytes = System.IO.File.ReadAllBytes(filePath);return File(bytes, "application/octet-stream", $"{System.DateTime.Now.ToString("yyyyMMdd")}.xlsx");}

二、使用NPOI导入Excel

  • HTML
 <input type="button" class="layui-btn layui-btn-blue2 layui-btn-sm" id="Excel" value="导入" />
  • JS
    <script>/*从本地添加excel文件方法*/layui.use('upload', function () {var $ = layui.jquery, upload = layui.upload, form = layui.form;upload.render({elem: '#Excel'//附件上传按钮ID, url: '/Home/ImportFile'//附件上传后台地址, multiple: true, accept: 'file', exts: 'xls|xlsx'//(允许的类别), before: function (obj) {/*上传前执行的部分*/ }, done: function excel(res) {console.log(res);}, allDone: function (res) {console.log(res);}});});//上传事件结束
</script>
  • C#
  • 控制器代码
        //注入依赖private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;public HomeController(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment){_hostingEnvironment = hostingEnvironment;}//控制器/// <summary>/// 导入/// </summary>/// <param name="file"></param>/// <returns></returns>[RequestSizeLimit(524288000)]  //文件大小限制[HttpPost]public async Task<IActionResult> ImportFile(IFormFile file){//把文件保存到文件夹下var path = "wwwroot/" + file.FileName;using (FileStream files = new FileStream(path, FileMode.OpenOrCreate)){file.CopyTo(files);}var wwwroot = _hostingEnvironment.WebRootPath;var fileSrc = wwwroot+"\\"+ file.FileName;List<UserEntity> list = new ExcelHelper<UserEntity>().ImportFromExcel(fileSrc);//取到数据后,接下来写你的业务逻辑就可以了for (int i = 0; i < list.Count; i++){var Name = string.IsNullOrEmpty(list[i].Name.ToString())? "" : list[i].Name.ToString();var Age = string.IsNullOrEmpty(list[i].Age.ToString()) ? "" : list[i].Age.ToString();var Gender = string.IsNullOrEmpty(list[i].Gender.ToString()) ? "" : list[i].Gender.ToString();var Tel = string.IsNullOrEmpty(list[i].Tel.ToString()) ? "" : list[i].Tel.ToString();}return Ok(new { Msg = "导入成功", Code = 200});}
  • 添加ExcelHelper类
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Reflection;namespace NetCore6Demo.Models
{public class ExcelHelper<T> where T : new(){#region Excel导入/// <summary>/// Excel导入/// </summary>/// <param name="filePath"></param>/// <returns></returns>public List<T> ImportFromExcel(string FilePath){List<T> list = new List<T>();HSSFWorkbook hssfWorkbook = null;XSSFWorkbook xssWorkbook = null;ISheet sheet = null;using (FileStream file = new FileStream(FilePath, FileMode.Open, FileAccess.Read)){switch (Path.GetExtension(FilePath)){case ".xls":hssfWorkbook = new HSSFWorkbook(file);sheet = hssfWorkbook.GetSheetAt(0);break;case ".xlsx":xssWorkbook = new XSSFWorkbook(file);sheet = xssWorkbook.GetSheetAt(0);break;default:throw new Exception("不支持的文件格式");}}IRow columnRow = sheet.GetRow(0); //第1行为字段名Dictionary<int, PropertyInfo> mapPropertyInfoDict = new Dictionary<int, PropertyInfo>();for (int j = 0; j < columnRow.LastCellNum; j++){ICell cell = columnRow.GetCell(j);PropertyInfo propertyInfo = MapPropertyInfo(cell.ParseToString());if (propertyInfo != null){mapPropertyInfoDict.Add(j, propertyInfo);}}for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++){IRow row = sheet.GetRow(i);T entity = new T();for (int j = row.FirstCellNum; j < columnRow.LastCellNum; j++){if (mapPropertyInfoDict.ContainsKey(j)){if (row.GetCell(j) != null){PropertyInfo propertyInfo = mapPropertyInfoDict[j];switch (propertyInfo.PropertyType.ToString()){case "System.DateTime":case "System.Nullable`1[System.DateTime]":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString().ParseToDateTime());break;case "System.Boolean":case "System.Nullable`1[System.Boolean]":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString().ParseToBool());break;case "System.Byte":case "System.Nullable`1[System.Byte]":mapPropertyInfoDict[j].SetValue(entity, Byte.Parse(row.GetCell(j).ParseToString()));break;case "System.Int16":case "System.Nullable`1[System.Int16]":mapPropertyInfoDict[j].SetValue(entity, Int16.Parse(row.GetCell(j).ParseToString()));break;case "System.Int32":case "System.Nullable`1[System.Int32]":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString().ParseToInt());break;case "System.Int64":case "System.Nullable`1[System.Int64]":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString().ParseToLong());break;case "System.Double":case "System.Nullable`1[System.Double]":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString().ParseToDouble());break;case "System.Single":case "System.Nullable`1[System.Single]":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString().ParseToDouble());break;case "System.Decimal":case "System.Nullable`1[System.Decimal]":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString().ParseToDecimal());break;default:case "System.String":mapPropertyInfoDict[j].SetValue(entity, row.GetCell(j).ParseToString());break;}}}}list.Add(entity);}hssfWorkbook?.Close();xssWorkbook?.Close();return list;}/// <summary>/// 查找Excel列名对应的实体属性/// </summary>/// <param name="columnName"></param>/// <returns></returns>private PropertyInfo MapPropertyInfo(string columnName){PropertyInfo[] propertyList = GetProperties(typeof(T));PropertyInfo propertyInfo = propertyList.Where(p => p.Name == columnName).FirstOrDefault();if (propertyInfo != null){return propertyInfo;}else{foreach (PropertyInfo tempPropertyInfo in propertyList){DescriptionAttribute[] attributes = (DescriptionAttribute[])tempPropertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);if (attributes.Length > 0){if (attributes[0].Description == columnName){return tempPropertyInfo;}}}}return null;}private static ConcurrentDictionary<string, object> dictCache = new ConcurrentDictionary<string, object>();#region 得到类里面的属性集合/// <summary>/// 得到类里面的属性集合/// </summary>/// <param name="type"></param>/// <param name="columns"></param>/// <returns></returns>public static PropertyInfo[] GetProperties(Type type, string[] columns = null){PropertyInfo[] properties = null;if (dictCache.ContainsKey(type.FullName)){properties = dictCache[type.FullName] as PropertyInfo[];}else{properties = type.GetProperties();dictCache.TryAdd(type.FullName, properties);}if (columns != null && columns.Length > 0){//  按columns顺序返回属性var columnPropertyList = new List<PropertyInfo>();foreach (var column in columns){var columnProperty = properties.Where(p => p.Name == column).FirstOrDefault();if (columnProperty != null){columnPropertyList.Add(columnProperty);}}return columnPropertyList.ToArray();}else{return properties;}}#endregion#endregion}
}
  • 添加Extensions类
 public static partial class Extensions{#region 转换为long/// <summary>/// 将object转换为long,若转换失败,则返回0。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static long ParseToLong(this object obj){try{return long.Parse(obj.ToString());}catch{return 0L;}}/// <summary>/// 将object转换为long,若转换失败,则返回指定值。不抛出异常。  /// </summary>/// <param name="str"></param>/// <param name="defaultValue"></param>/// <returns></returns>public static long ParseToLong(this string str, long defaultValue){try{return long.Parse(str);}catch{return defaultValue;}}#endregion#region 转换为int/// <summary>/// 将object转换为int,若转换失败,则返回0。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static int ParseToInt(this object str){try{return Convert.ToInt32(str);}catch{return 0;}}/// <summary>/// 将object转换为int,若转换失败,则返回指定值。不抛出异常。 /// null返回默认值/// </summary>/// <param name="str"></param>/// <param name="defaultValue"></param>/// <returns></returns>public static int ParseToInt(this object str, int defaultValue){if (str == null){return defaultValue;}try{return Convert.ToInt32(str);}catch{return defaultValue;}}#endregion#region 转换为short/// <summary>/// 将object转换为short,若转换失败,则返回0。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static short ParseToShort(this object obj){try{return short.Parse(obj.ToString());}catch{return 0;}}/// <summary>/// 将object转换为short,若转换失败,则返回指定值。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static short ParseToShort(this object str, short defaultValue){try{return short.Parse(str.ToString());}catch{return defaultValue;}}#endregion#region 转换为demical/// <summary>/// 将object转换为demical,若转换失败,则返回指定值。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static decimal ParseToDecimal(this object str, decimal defaultValue){try{return decimal.Parse(str.ToString());}catch{return defaultValue;}}/// <summary>/// 将object转换为demical,若转换失败,则返回0。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static decimal ParseToDecimal(this object str){try{return decimal.Parse(str.ToString());}catch{return 0;}}#endregion#region 转化为bool/// <summary>/// 将object转换为bool,若转换失败,则返回false。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static bool ParseToBool(this object str){try{return bool.Parse(str.ToString());}catch{return false;}}/// <summary>/// 将object转换为bool,若转换失败,则返回指定值。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static bool ParseToBool(this object str, bool result){try{return bool.Parse(str.ToString());}catch{return result;}}#endregion#region 转换为float/// <summary>/// 将object转换为float,若转换失败,则返回0。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static float ParseToFloat(this object str){try{return float.Parse(str.ToString());}catch{return 0;}}/// <summary>/// 将object转换为float,若转换失败,则返回指定值。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static float ParseToFloat(this object str, float result){try{return float.Parse(str.ToString());}catch{return result;}}#endregion#region 转换为Guid/// <summary>/// 将string转换为Guid,若转换失败,则返回Guid.Empty。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static Guid ParseToGuid(this string str){try{return new Guid(str);}catch{return Guid.Empty;}}#endregion#region 转换为DateTime/// <summary>/// 将string转换为DateTime,若转换失败,则返回日期最小值。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static DateTime ParseToDateTime(this string str){try{if (string.IsNullOrWhiteSpace(str)){return DateTime.MinValue;}if (str.Contains("-") || str.Contains("/")){return DateTime.Parse(str);}else{int length = str.Length;switch (length){case 4:return DateTime.ParseExact(str, "yyyy", System.Globalization.CultureInfo.CurrentCulture);case 6:return DateTime.ParseExact(str, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);case 8:return DateTime.ParseExact(str, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);case 10:return DateTime.ParseExact(str, "yyyyMMddHH", System.Globalization.CultureInfo.CurrentCulture);case 12:return DateTime.ParseExact(str, "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);case 14:return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);default:return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);}}}catch{return DateTime.MinValue;}}/// <summary>/// 将string转换为DateTime,若转换失败,则返回默认值。  /// </summary>/// <param name="str"></param>/// <param name="defaultValue"></param>/// <returns></returns>public static DateTime ParseToDateTime(this string str, DateTime? defaultValue){try{if (string.IsNullOrWhiteSpace(str)){return defaultValue.GetValueOrDefault();}if (str.Contains("-") || str.Contains("/")){return DateTime.Parse(str);}else{int length = str.Length;switch (length){case 4:return DateTime.ParseExact(str, "yyyy", System.Globalization.CultureInfo.CurrentCulture);case 6:return DateTime.ParseExact(str, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);case 8:return DateTime.ParseExact(str, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);case 10:return DateTime.ParseExact(str, "yyyyMMddHH", System.Globalization.CultureInfo.CurrentCulture);case 12:return DateTime.ParseExact(str, "yyyyMMddHHmm", System.Globalization.CultureInfo.CurrentCulture);case 14:return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);default:return DateTime.ParseExact(str, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);}}}catch{return defaultValue.GetValueOrDefault();}}#endregion#region 转换为string/// <summary>/// 将object转换为string,若转换失败,则返回""。不抛出异常。  /// </summary>/// <param name="str"></param>/// <returns></returns>public static string ParseToString(this object obj){try{if (obj == null){return string.Empty;}else{return obj.ToString();}}catch{return string.Empty;}}public static string ParseToStrings<T>(this object obj){try{var list = obj as IEnumerable<T>;if (list != null){return string.Join(",", list);}else{return obj.ToString();}}catch{return string.Empty;}}#endregion#region 转换为double/// <summary>/// 将object转换为double,若转换失败,则返回0。不抛出异常。  /// </summary>/// <param name="obj"></param>/// <returns></returns>public static double ParseToDouble(this object obj){try{return double.Parse(obj.ToString());}catch{return 0;}}/// <summary>/// 将object转换为double,若转换失败,则返回指定值。不抛出异常。  /// </summary>/// <param name="str"></param>/// <param name="defaultValue"></param>/// <returns></returns>public static double ParseToDouble(this object str, double defaultValue){try{return double.Parse(str.ToString());}catch{return defaultValue;}}#endregion}
  • 添加实体类UserEntity,要跟Excel的列名一致
 public class UserEntity{[Description("名称")]public string Name { get; set; }[Description("年龄")]public string Age { get; set; }[Description("性别")]public string Gender { get; set; }[Description("手机号")]public string Tel { get; set; }}
  • Excel模板
    !https://img-blog.csdnimg.cn/5a79394d772c4c9ab0d28972f09f2f67.png)
  • 实现效果
    在这里插入图片描述

相关文章:

.NET Core6.0使用NPOI导入导出Excel

一、使用NPOI导出Excel //引入NPOI包 HTML <input type"button" class"layui-btn layui-btn-blue2 layui-btn-sm" id"ExportExcel" onclick"ExportExcel()" value"导出" />JS //导出Excelfunction ExportExcel() {…...

用API接口获取数据的好处有哪些,电商小白看过来!

API接口获取数据有以下几个好处&#xff1a; 1. 数据的实时性&#xff1a;通过API接口获取数据可以实时获取最新的数据&#xff0c;保证数据的及时性。这对于需要及时更新数据的应用非常重要&#xff0c;比如股票行情、天气预报等。 2. 数据的准确性&#xff1a;通过API接口获…...

使用struct解析通达信本地Lday日线数据

★★★★★博文原创不易&#xff0c;我的博文不需要打赏&#xff0c;也不需要知识付费&#xff0c;可以白嫖学习编程小技巧&#xff0c;喜欢的老铁可以多多帮忙点赞&#xff0c;小红牛在此表示感谢。★★★★★ 在Python中&#xff0c;struct模块提供了二进制数据的打包和解包…...

浅谈早期基于模板匹配的OCR的原理

基于模板匹配的概念是一种早期的字符识别方法&#xff0c;它基于事先准备好的字符模板库来与待识别字符进行比较和匹配。其原理如下&#xff1a; 1. 字符模板库准备&#xff1a;首先&#xff0c;针对每个可能出现的字符&#xff0c;制作一个对应的字符模板。这些模板可以手工创…...

第6章 分布式文件存储

mini商城第6章 分布式文件存储 一、课题 分布式文件存储 二、回顾 1、理解Oauth2.0的功能作模式 2、实现mini商城项目的权限登录 三、目标 1、了解文件存储系统的概念 2、了解常用文件服务器的区别 3、掌握Minio的应用 四、内容 第1章 MinIO简介 官...

Spring(四):Spring Boot 的创建和使用

关于Spring之前说到&#xff0c;Spring只是思想&#xff08;核心是IOC、DI和AOP&#xff09;&#xff0c;而具体的如何实现呢&#xff1f;那就是由Spring Boot 来实现&#xff0c;Spring Boot究竟是个啥呢&#xff1f; 什么是Spring Boot&#xff0c;为什么要学Spring Boot Sp…...

SpringCloud Gateway:status: 503 error: Service Unavailable

使用SpringCloud Gateway路由请求时&#xff0c;出现如下错误 yml配置如下&#xff1a; 可能的一种原因是&#xff1a;yml配置了gateway.discovery.locator.enabledtrue&#xff0c;此时gateway会使用负载均衡模式路由请求&#xff0c;但是SpringCloud Alibaba删除了Ribbon的…...

【产品规划】功能需求说明书概述

文章目录 1、瀑布流方法论简介2、产品需求文档&#xff08;PRD&#xff09;简介3、产品需求文档的基本要素4、编写产品需求文档5、优秀产品需求文档的特点6、与产品需求文档相似的其他文档 1、瀑布流方法论简介 2、产品需求文档&#xff08;PRD&#xff09;简介 3、产品需求文档…...

shell连接ubuntu

当使用aws的私钥连接时,老是弹出输入私钥密码,但是根本没有设置过密码,随便输入后,又提示该私钥无密码... 很早就使用过aws的ubuntu,这个问题也很早就遇到过,但是每次遇到都要各种找找找...索性这次记下来算了 此处用FinalShell连接为例 首先现在Putty连接工具: 点击官方下载 …...

华为将收取蜂窝物联网专利费,或将影响LPWAN市场发展

近日&#xff0c;华为正式公布了其4G和5G手机、Wi-Fi6设备和物联网产品的专利许可费率&#xff0c;其中包含了长距离通信技术蜂窝物联网。作为蜂窝物联网技术的先驱&#xff0c;华为是LTE Category NB (NB-IoT)、LTE Category M和其他4G物联网标准的主要贡献者。 在NB-IoT领域…...

【3Ds Max】图形合并命令的简单使用

示例&#xff08;将文字设置在球体上&#xff09; 1. 首先这里创建一个球体和一个文本 2. 选中球体&#xff0c;在复合对象中点击图形合并按钮 点击“拾取图形”按钮&#xff0c;然后选中文本&#xff0c;此时可以看到球体上已经投射出文本 3. 接下来是一些常用参数的介绍 当…...

Flink的常用算子以及实例

1.map 特性&#xff1a;接收一个数据&#xff0c;经过处理之后&#xff0c;就返回一个数据 1.1. 源码分析 我们来看看map的源码 map需要接收一个MapFunction<T,R>的对象&#xff0c;其中泛型T表示传入的数据类型&#xff0c;R表示经过处理之后输出的数据类型我们继续往…...

网络安全---负载均衡案例

一、首先环境配置 1.上传文件并解压 2.进入目录下 为了方便解释&#xff0c;我们只用两个节点&#xff0c;启动之后&#xff0c;大家可以看到有 3 个容器&#xff08;可想像成有 3 台服务器就成&#xff09;。 二、使用蚁剑去连接 因为两台节点都在相同的位置存在 ant.jsp&…...

解决nginx的负载均衡下上传webshell的问题

目录 环境 问题 访问的ip会变动 执行命令的服务器未知 上传大文件损坏 深入内网 解决方案 环境 ps :现在已经拿下服务器了&#xff0c;要解决的是负载均衡问题, 以下是docker环境&#xff1a; 链接: https://pan.baidu.com/s/1cjMfyFbb50NuUtk6JNfXNQ?pwd1aqw 提…...

vue 关闭prettier警告warn

这个就是我们创建vue cli的时候 把这个给默认上了 关闭这个只需在.eslintrc.js页面里边添加一行代码"prettier/prettier": "off"...

听GPT 讲Prometheus源代码--rules

Prometheus的rules目录主要包含规则引擎和管理规则的文件: engine.go 该文件定义了规则引擎的接口和主要结构,包括Rule,Record,RuleGroup等。它提供了规则的加载、匹配、评估和结果记录的功能。 api.go 定义了用于管理和查询规则的RESTful API,包括获取、添加、删除规则等方法。…...

TIA博途_通过EXCEL快速给PLC程序段添加注释信息的方法示例

通过EXCEL快速给PLC程序段添加注释信息的方法示例 如下图所示,以OB1为例,正常情况下,我们可以在博途中直接输入各个程序段的注释信息, 但是如果程序段较多的话,逐个输入的话效率不高,此时可以参考下面这种通过EXCEL进行快速添加的方法。 如下图所示,选中某个OB或FC、FB块…...

【力扣】496. 下一个更大元素 I <单调栈、模拟>

【力扣】496. 下一个更大元素 I nums1 中数字 x 的 下一个更大元素 是指 x 在 nums2 中对应位置 右侧 的 第一个 比 x 大的元素。给你两个没有重复元素的数组 nums1 和 nums2 &#xff0c;下标从 0 开始计数&#xff0c;其中nums1 是 nums2 的子集。   对于每个 0 < i <…...

Java调用https接口添加证书

使用InstallCert.Java生成证书 /** Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** - Redistri…...

C++入门:函数缺省参数与函数重载

目录 1.函数缺省参数 1.1 缺省参数概念 1.2 缺省参数分类 2.函数重载 2.1 函数重载概念 2.2 C支持函数重载的原理 1.函数缺省参数 1.1 缺省参数概念 缺省参数是声明或定义函数时为函数的参数指定一个缺省值。在调用该函数时&#xff0c;如果没有指定实 参则采用该形参的…...

React 第五十五节 Router 中 useAsyncError的使用详解

前言 useAsyncError 是 React Router v6.4 引入的一个钩子&#xff0c;用于处理异步操作&#xff08;如数据加载&#xff09;中的错误。下面我将详细解释其用途并提供代码示例。 一、useAsyncError 用途 处理异步错误&#xff1a;捕获在 loader 或 action 中发生的异步错误替…...

UDP(Echoserver)

网络命令 Ping 命令 检测网络是否连通 使用方法: ping -c 次数 网址ping -c 3 www.baidu.comnetstat 命令 netstat 是一个用来查看网络状态的重要工具. 语法&#xff1a;netstat [选项] 功能&#xff1a;查看网络状态 常用选项&#xff1a; n 拒绝显示别名&#…...

【机器视觉】单目测距——运动结构恢复

ps&#xff1a;图是随便找的&#xff0c;为了凑个封面 前言 在前面对光流法进行进一步改进&#xff0c;希望将2D光流推广至3D场景流时&#xff0c;发现2D转3D过程中存在尺度歧义问题&#xff0c;需要补全摄像头拍摄图像中缺失的深度信息&#xff0c;否则解空间不收敛&#xf…...

【Go】3、Go语言进阶与依赖管理

前言 本系列文章参考自稀土掘金上的 【字节内部课】公开课&#xff0c;做自我学习总结整理。 Go语言并发编程 Go语言原生支持并发编程&#xff0c;它的核心机制是 Goroutine 协程、Channel 通道&#xff0c;并基于CSP&#xff08;Communicating Sequential Processes&#xff0…...

【单片机期末】单片机系统设计

主要内容&#xff1a;系统状态机&#xff0c;系统时基&#xff0c;系统需求分析&#xff0c;系统构建&#xff0c;系统状态流图 一、题目要求 二、绘制系统状态流图 题目&#xff1a;根据上述描述绘制系统状态流图&#xff0c;注明状态转移条件及方向。 三、利用定时器产生时…...

论文解读:交大港大上海AI Lab开源论文 | 宇树机器人多姿态起立控制强化学习框架(一)

宇树机器人多姿态起立控制强化学习框架论文解析 论文解读&#xff1a;交大&港大&上海AI Lab开源论文 | 宇树机器人多姿态起立控制强化学习框架&#xff08;一&#xff09; 论文解读&#xff1a;交大&港大&上海AI Lab开源论文 | 宇树机器人多姿态起立控制强化…...

Python ROS2【机器人中间件框架】 简介

销量过万TEEIS德国护膝夏天用薄款 优惠券冠生园 百花蜂蜜428g 挤压瓶纯蜂蜜巨奇严选 鞋子除臭剂360ml 多芬身体磨砂膏280g健70%-75%酒精消毒棉片湿巾1418cm 80片/袋3袋大包清洁食品用消毒 优惠券AIMORNY52朵红玫瑰永生香皂花同城配送非鲜花七夕情人节生日礼物送女友 热卖妙洁棉…...

音视频——I2S 协议详解

I2S 协议详解 I2S (Inter-IC Sound) 协议是一种串行总线协议&#xff0c;专门用于在数字音频设备之间传输数字音频数据。它由飞利浦&#xff08;Philips&#xff09;公司开发&#xff0c;以其简单、高效和广泛的兼容性而闻名。 1. 信号线 I2S 协议通常使用三根或四根信号线&a…...

Vite中定义@软链接

在webpack中可以直接通过符号表示src路径&#xff0c;但是vite中默认不可以。 如何实现&#xff1a; vite中提供了resolve.alias&#xff1a;通过别名在指向一个具体的路径 在vite.config.js中 import { join } from pathexport default defineConfig({plugins: [vue()],//…...

如何应对敏捷转型中的团队阻力

应对敏捷转型中的团队阻力需要明确沟通敏捷转型目的、提升团队参与感、提供充分的培训与支持、逐步推进敏捷实践、建立清晰的奖励和反馈机制。其中&#xff0c;明确沟通敏捷转型目的尤为关键&#xff0c;团队成员只有清晰理解转型背后的原因和利益&#xff0c;才能降低对变化的…...