.Net 5.0导出Execl的两种方式
项目中经常会用到表格的导入导出
今天来简绍一下我所了解的两种方式
1.拼接成表格的简单方式直接导出,服务器上不用安装其他程序 可以直接导出
public async Task<FileResult> AuditLogExport(QueryAppAuditLogExportInput input)
{var content = list.Select(item => new
{
OperatorUserName = item.OperatorUserName,
OperatorIp = item.OperatorIp,
ManipulatedUserName = item.ManipulatedUserName,
//ManipulatedIp = item.ManipulatedIp,
SendCode = item.SendCode.IsNullOrEmpty() ? "-" : item.SendCode,
//SendIP = item.SendIP.IsNullOrEmpty() ? "-" : item.SendIP,
ReceiveCode = item.ReceiveCode.IsNullOrEmpty() ? "-" : item.ReceiveCode,
ReceiveIP = item.ReceiveIP.IsNullOrEmpty() ? "-" : item.ReceiveIP,
RequestContent = item.RequestContent.IsNullOrEmpty() ? "-" : item.RequestContent,
ReponseContent = item.ReponseContent,
IsActionResult = item.ActionResult ? "成功" : "失败",
LogTypeStr = item.LogTypeStr,
LogLevelStr = item.LogLevelStr,
ElapsedMilliseconds = item.ElapsedMilliseconds,
ExceptionContent = item.ExceptionContent.IsNullOrEmpty() ? "-" : item.ExceptionContent,
CreationTime = item.CreationTimeStr,
}).ToList(); //命名导出表格的StringBuilder变量
StringBuilder fileContent = new StringBuilder(string.Empty, 3000);
fileContent.Append("<table border=\"1\" width=\"100%\">"); //第一行列名
fileContent.Append("<tr height=\"50\" align=\"center\">");
fileContent.Append("<th style='background-color:#22DDDD'>序号</th>");
fileContent.Append("<th style='background-color:#22DDDD'>操作人用户名</th>");
fileContent.Append("<th style='background-color:#22DDDD'>操作人IP</th>");
//fileContent.Append("<th style='background-color:#22DDDD'>被操作人用户名</th>");
fileContent.Append("<th style='background-color:#22DDDD'>发送方编码</th>");
fileContent.Append("<th style='background-color:#22DDDD'>接收方编码</th>");
fileContent.Append("<th style='background-color:#22DDDD'>接收方IP</th>");
fileContent.Append("<th style='background-color:#22DDDD'>请求参数</th>");
fileContent.Append("<th style='background-color:#22DDDD'>响应内容</th>");
fileContent.Append("<th style='background-color:#22DDDD'>处理结果</th>");
fileContent.Append("<th style='background-color:#22DDDD'>日志类型</th>");
fileContent.Append("<th style='background-color:#22DDDD'>日志级别</th>");
fileContent.Append("<th style='background-color:#22DDDD'>业务耗时(ms)</th>");
fileContent.Append("<th style='background-color:#22DDDD'>异常内容)</th>");
fileContent.Append("<th style='background-color:#22DDDD'>日志时间</th>");
fileContent.Append("</tr>"); int i = 0;
//内容循环
foreach (var m in content)
{
i++;
fileContent.Append("<tr height=\"50\" align=\"center\">");
fileContent.Append($"<td>{i}</td>");
fileContent.Append($"<td>{m.OperatorUserName}</td>");
fileContent.Append($"<td>{m.OperatorIp}</td>");
//fileContent.Append($"<td>{m.ManipulatedUserName}</td>");
fileContent.Append($"<td>{m.SendCode}</td>");
fileContent.Append($"<td>{m.ReceiveCode}</td>");
fileContent.Append($"<td>{m.ReceiveIP}</td>");
fileContent.Append($"<td>{m.RequestContent}</td>");
fileContent.Append($"<td>{m.ReponseContent}</td>");
fileContent.Append($"<td>{m.IsActionResult}</td>");
fileContent.Append($"<td>{m.LogTypeStr}</td>");
fileContent.Append($"<td>{m.LogLevelStr}</td>");
fileContent.Append($"<td>{m.ElapsedMilliseconds}</td>");
fileContent.Append($"<td>{m.ExceptionContent}</td>");
fileContent.Append($"<td>{m.CreationTime}</td>");
fileContent.Append("</tr>");
} fileContent.Append("</table>"); byte[] fileContents = Encoding.UTF8.GetBytes(fileContent.ToString());
string name = $"xxx-{DateTime.Now:yyyyMMddHHmmssfff}.xlsx";
return File(fileContents, "application/ms-excel", name); }
2.使用 第三方类库的方式 进行导出,服务器上需要安装 Execl 才能支持
using OfficeOpenXml;
public async Task<IActionResult> GetResourceReport()
{
var list = await _standingBookAppService.GetAllResourceTypes(); var content = list.Select(item => new
{
Title = item.Title,
Code = item.Code,
Remark = item.Remark }).ToList(); //定义表头
var heads = new List<string>() { "资源名称", "资源编码", "备注信息" }; var excelFilePath = ExportExcelExtensions.ExportExcel(content, heads, _hostingEnvironment.ContentRootPath, "资源类型报表");
return File(
new FileStream(excelFilePath, FileMode.Open),
"application/octet-stream",
$"资源类型报表 {DateTime.Now:yyyy-MM-dd HHmmss}.xlsx"
);
}
public class ExportExcelExtensions
{
/// <summary>
/// 生成Excel
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="dataList">数据源</param>
/// <param name="headers">表头</param>
/// <param name="rootPath">根目录</param>
/// <param name="name">文档窗口名称</param>
/// <returns></returns>
public static string ExportExcel<T>(List<T> dataList, List<string> headers, string rootPath, string name)
{
var tmp = Path.Combine(rootPath, "wwwroot", "ImportExport");
var sWebRootFolder = StringExtensions.GetRuntimeDirectory(tmp); if (!Directory.Exists(sWebRootFolder))
{
Directory.CreateDirectory(sWebRootFolder);
} var sFileName = $@"tempExcel_{DateTime.Now:yyyyMMddHHmmss}";
var path = Path.Combine(sWebRootFolder, sFileName);
var file = new FileInfo(path);
if (file.Exists)
{
file.Delete();
file = new FileInfo(path);
} using var package = new ExcelPackage(file);
//创建sheet
var worksheet = package.Workbook.Worksheets.Add(name);
worksheet.Cells.LoadFromCollection(dataList, true);
//表头字段
for (int i = 0; i < headers.Count; i++)
{
worksheet.Cells[1, i + 1].Value = headers[i];
// // 对字体的设置
worksheet.Cells[1, i + 1].Style.Font.Bold = true;
worksheet.Cells[1, i + 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
worksheet.Cells[1, i + 1].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
worksheet.Cells[1, i + 1].Style.Font.Size = 14;
worksheet.Cells[1, i + 1].Style.Font.Color.SetColor(Color.FromArgb(0, 0, 128)); // 单元格背景色的设置
worksheet.Cells[1, i + 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[1, i + 1].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(146, 208, 80)); // 单独设置单元格底部边框样式和颜色(上下左右均可分开设置)
worksheet.Cells[1, i + 1].Style.Border.BorderAround(ExcelBorderStyle.Thin); worksheet.Cells[1, i + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
worksheet.Cells[1, i + 1].Style.Border.Right.Style = ExcelBorderStyle.Thin; // 自当使用文字大小
worksheet.Cells[1, i + 1].AutoFitColumns(); worksheet.Row(i + 1).Height = 25;//设置行高
worksheet.Row(i + 1).CustomHeight = true;//自动调整行高
worksheet.Column(i + 1).Width = 30;//设置列宽 } for (int i = 0; i < dataList.Count; i++)
{
worksheet.Row(i + 1).Height = 25; // 设置每行高度
} worksheet.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;//水平居中
worksheet.Cells.Style.VerticalAlignment = ExcelVerticalAlignment.Center;//垂直居中
// worksheet.Cells.Style.ShrinkToFit = true;//单元格自动适应大小
worksheet.Cells.Style.WrapText = true;//自动换行
package.Save(); return path;
} /// <summary>
/// 创建excel模板
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="headers"></param>
/// <param name="rootPath"></param>
/// <param name="name"></param>
/// <returns></returns>
public static string CreatExcelTemplate(List<string> headers, string rootPath, string name)
{
var tmp = Path.Combine(rootPath, "wwwroot", "ImportExport");
var sWebRootFolder = StringExtensions.GetRuntimeDirectory(tmp); if (!Directory.Exists(sWebRootFolder))
{
Directory.CreateDirectory(sWebRootFolder);
} var sFileName = $@"tempExcel_{DateTime.Now:yyyyMMddHHmmss}";
var path = Path.Combine(sWebRootFolder, sFileName);
var file = new FileInfo(path);
if (file.Exists)
{
file.Delete();
file = new FileInfo(path);
} using var package = new ExcelPackage(file);
//创建sheet
var worksheet = package.Workbook.Worksheets.Add(name);
//表头字段
for (int i = 0; i < headers.Count; i++)
{
worksheet.Cells[1, i + 1].Value = headers[i];
// // 对字体的设置
worksheet.Cells[1, i + 1].Style.Font.Bold = true;
worksheet.Cells[1, i + 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
worksheet.Cells[1, i + 1].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
worksheet.Cells[1, i + 1].Style.Font.Size = 14;
worksheet.Cells[1, i + 1].Style.Font.Color.SetColor(Color.FromArgb(0, 0, 128)); // 单元格背景色的设置
worksheet.Cells[1, i + 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[1, i + 1].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(146, 208, 80)); // 单独设置单元格底部边框样式和颜色(上下左右均可分开设置)
worksheet.Cells[1, i + 1].Style.Border.BorderAround(ExcelBorderStyle.Thin); worksheet.Cells[1, i + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
worksheet.Cells[1, i + 1].Style.Border.Right.Style = ExcelBorderStyle.Thin; // 自当使用文字大小
worksheet.Cells[1, i + 1].AutoFitColumns(); worksheet.Row(i + 1).Height = 25;//设置行高
worksheet.Row(i + 1).CustomHeight = true;//自动调整行高
worksheet.Column(i + 1).Width = 30;//设置列宽 } worksheet.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;//水平居中
worksheet.Cells.Style.VerticalAlignment = ExcelVerticalAlignment.Center;//垂直居中
// worksheet.Cells.Style.ShrinkToFit = true;//单元格自动适应大小
worksheet.Cells.Style.WrapText = true;//自动换行
package.Save(); return path;
} public static object Export<T, S>(T source, List<S> dataList, ExportSettingsCellection cellection, string rootPath, string title, bool showTitle = true, bool haveBaseInfo = true)
{
#region 组装部分
var tmp = Path.Combine(rootPath, "wwwroot");
var sWebRootFolder = StringExtensions.GetRuntimeDirectory(tmp); if (!Directory.Exists(sWebRootFolder))
{
Directory.CreateDirectory(sWebRootFolder);
}
var sFileName = $@"tempExcel_{DateTime.Now:yyyyMMddHHmmss}";
var path = Path.Combine(sWebRootFolder, sFileName);
var file = new FileInfo(path);
if (file.Exists)
{
file.Delete();
file = new FileInfo(path);
} using var package = new ExcelPackage(file);
//创建sheet
var workSheet = package.Workbook.Worksheets.Add(title);
//workSheet.Cells.LoadFromCollection(dtSource, true);
#endregion
#region 处理逻辑部分
//1.当前行
var curRowIndex = 0;
#region 表头
var maxColumnCount = cellection.ColsShowFildNum * 2 + 5;//预计所有列数
if (showTitle == true)
{
curRowIndex++;
workSheet.Cells[curRowIndex, 1, curRowIndex, maxColumnCount].Merge = true;
workSheet.Cells[curRowIndex, 1].Value = title;
var headerStyle = workSheet.Workbook.Styles.CreateNamedStyle("headerStyle");
headerStyle.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
//headerStyle.Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
headerStyle.Style.VerticalAlignment = ExcelVerticalAlignment.Center; headerStyle.Style.Font.Bold = true;
headerStyle.Style.Font.Size = 20;
workSheet.Cells[curRowIndex, 1].StyleName = "headerStyle";
}
#endregion
#region 第一基础部分
if (haveBaseInfo)
{
//需要分列的行数
var fetchCount = (cellection.headers.Count / cellection.ColsShowFildNum) + (cellection.headers.Count % cellection.ColsShowFildNum);
//排序
cellection.headers = cellection.headers.OrderBy(x => x.Sort).ToList();
//2. 拼接表头 第一行
var forcount = 1;//循环的次数
var titlecellindex = 1;
var fieldcellindex = 1;
curRowIndex++;
foreach (var column in cellection.headers)
{
fieldcellindex = titlecellindex + 1;
//1.field 2.值 1.field 2.值...依次一行
workSheet.Cells[curRowIndex, titlecellindex].Value = column.Title;
Type type = typeof(T);
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (var propertyInfo in propertyInfos)
{
if (column.Field.Equals(propertyInfo.Name))
{
object value = propertyInfo.GetValue(source);
var pType = propertyInfo.PropertyType;
pType = pType.Name == "Nullable`1" ? Nullable.GetUnderlyingType(pType) : pType;
if (column.Title.Equals("图片1"))
{
try
{
Stream stream = WebRequest.Create(value.ToString()).GetResponse().GetResponseStream();
MemoryStream ms = new MemoryStream();
stream.CopyTo(ms);
//System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
//img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] buff = new byte[ms.Length];
ms.Position = 0;
ms.Read(buff, 0, (int)ms.Length);
ms.Close();
// 图片在研究 ExcelShellImage.InsertImage(workSheet, buff, curRowIndex, j, true);
}
catch (Exception ex)
{
continue;
} }
else
{
if (pType == typeof(DateTime))
{
workSheet.Cells[curRowIndex, fieldcellindex].Style.Numberformat.Format = "yyyy-MM-dd hh:mm";
workSheet.Cells[curRowIndex, fieldcellindex].Value = Convert.ToDateTime(value);
}
else if (pType == typeof(int))
{
workSheet.Cells[curRowIndex, fieldcellindex].Style.Numberformat.Format = "#0";
workSheet.Cells[curRowIndex, fieldcellindex].Value = Convert.ToInt32(value);
}
else if (pType == typeof(double) || pType == typeof(decimal))
{
//if (column.Precision != null) workSheet.Cells[curRowIndex, forcount + 1].Style.Numberformat.Format = "#,##0.00";//保留两位小数
workSheet.Cells[curRowIndex, fieldcellindex].Value = Convert.ToDouble(value);
}
else
{
workSheet.Cells[curRowIndex, fieldcellindex].Value = value == null ? "" : value.ToString();
}
//跨列
if (column.CellSpanNum > 0)
{
workSheet.Cells[curRowIndex, fieldcellindex, curRowIndex, column.CellSpanNum + fieldcellindex].Merge = true;
forcount = forcount + (column.CellSpanNum / 2 + column.CellSpanNum % 2);
}
workSheet.Cells[curRowIndex, fieldcellindex].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
workSheet.Cells[curRowIndex, fieldcellindex].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
fieldcellindex = fieldcellindex + column.CellSpanNum; }
break;
} }
#region 设置样式
// 对字体的设置
workSheet.Cells[curRowIndex, titlecellindex].Style.Font.Bold = true;
workSheet.Cells[curRowIndex, titlecellindex].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
workSheet.Cells[curRowIndex, titlecellindex].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
workSheet.Cells[curRowIndex, titlecellindex].Style.Font.Size = column.TitleFontSize;
workSheet.Cells[curRowIndex, fieldcellindex].Style.Font.Size = column.FieldFontSize; // 单元格背景色的设置
//workSheet.Cells[curRowIndex, fieldcellindex].Style.Fill.PatternType = ExcelFillStyle.Solid;
//workSheet.Cells[curRowIndex, fieldcellindex].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(146, 208, 80)); // 单独设置单元格底部边框样式和颜色(上下左右均可分开设置)
workSheet.Cells[curRowIndex, titlecellindex].Style.Border.BorderAround(column.TitleExcelBorderStyle);
workSheet.Cells[curRowIndex, titlecellindex].Style.Border.Bottom.Style = column.TitleExcelBorderStyle;
workSheet.Cells[curRowIndex, titlecellindex].Style.Border.Right.Style = column.TitleExcelBorderStyle; // 自当使用文字大小
workSheet.Cells[curRowIndex, titlecellindex].AutoFitColumns();
workSheet.Row(curRowIndex).Height = column.TitleHeight;//设置行高
workSheet.Row(curRowIndex).CustomHeight = true;//自动调整行高
workSheet.Column(curRowIndex + 1).Width = column.TitleWidth;//设置列宽
#endregion
if (forcount % cellection.ColsShowFildNum == 0)
{
//换行
curRowIndex++;
//从第一列开始
titlecellindex = 1;
fieldcellindex = 0;
}
//if ((forcount / cellection.ColsShowFildNum) >= fetchCount)
//{
// break;
//}
titlecellindex = fieldcellindex + 1;
forcount++;
}
} #endregion #region 第二列表部分
if (haveBaseInfo)
{
//curRowIndex = curRowIndex + 4;
}
else
{
//curRowIndex = curRowIndex + 2;
}
curRowIndex = curRowIndex + 1;
if (dataList.Any() && dataList.Count > 0)
{
//表头字段
for (int i = 0; i < cellection.bodysSettings.Count; i++)
{
workSheet.Cells[curRowIndex, i + 1].Value = cellection.bodysSettings[i].Title;
// 对字体的设置
workSheet.Cells[curRowIndex, i + 1].Style.Font.Bold = true;
workSheet.Cells[curRowIndex, i + 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
workSheet.Cells[curRowIndex, i + 1].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
workSheet.Cells[curRowIndex, i + 1].Style.Font.Size = cellection.bodysSettings[i].TitleFontSize;
// 单独设置单元格底部边框样式和颜色(上下左右均可分开设置)
workSheet.Cells[curRowIndex, i + 1].Style.Border.BorderAround(ExcelBorderStyle.Thin);
workSheet.Cells[curRowIndex, i + 1].Style.Border.Bottom.Style = cellection.bodysSettings[i].TitleExcelBorderStyle;
workSheet.Cells[curRowIndex, i + 1].Style.Border.Right.Style = cellection.bodysSettings[i].TitleExcelBorderStyle;
// 自当使用文字大小
workSheet.Cells[curRowIndex, i + 1].AutoFitColumns();
workSheet.Row(curRowIndex).Height = cellection.bodysSettings[i].TitleHeight;//设置行高
workSheet.Row(curRowIndex).CustomHeight = true;//自动调整行高
workSheet.Column(i + 1).Width = cellection.bodysSettings[i].TitleWidth;//设置列宽
}
curRowIndex++;
//数据
foreach (var item in dataList)
{
var bodyfieldcellindex = 1;
foreach (var column in cellection.bodysSettings)
{
Type type = typeof(S);
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (var propertyInfo in propertyInfos)
{
if (column.Field.Equals(propertyInfo.Name))
{
object value = propertyInfo.GetValue(item);
var pType = propertyInfo.PropertyType;
pType = pType.Name == "Nullable`1" ? Nullable.GetUnderlyingType(pType) : pType;
if (column.Title.Equals("图片"))
{
try
{
Stream stream = WebRequest.Create(value.ToString()).GetResponse().GetResponseStream();
MemoryStream ms = new MemoryStream();
stream.CopyTo(ms);
//System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
//img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] buff = new byte[ms.Length];
ms.Position = 0;
ms.Read(buff, 0, (int)ms.Length);
ms.Close();
// 图片在研究
ExcelShellImage.InsertImage(workSheet, buff, curRowIndex, bodyfieldcellindex, true);
//workSheet.Row(curRowIndex).Height = 200; }
catch (Exception ex)
{
continue;
} }
else
{
if (pType == typeof(DateTime))
{
workSheet.Cells[curRowIndex, bodyfieldcellindex].Style.Numberformat.Format = "yyyy-MM-dd hh:mm";
workSheet.Cells[curRowIndex, bodyfieldcellindex].Value = Convert.ToDateTime(value);
}
else if (pType == typeof(int))
{
workSheet.Cells[curRowIndex, bodyfieldcellindex].Style.Numberformat.Format = "#0";
workSheet.Cells[curRowIndex, bodyfieldcellindex].Value = Convert.ToInt32(value);
}
else if (pType == typeof(double) || pType == typeof(decimal))
{
workSheet.Cells[curRowIndex, bodyfieldcellindex].Value = Convert.ToDouble(value);
}
else
{
workSheet.Cells[curRowIndex, bodyfieldcellindex].Value = value == null ? "" : value.ToString();
}
workSheet.Cells[curRowIndex, bodyfieldcellindex].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
workSheet.Cells[curRowIndex, bodyfieldcellindex].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
workSheet.Row(curRowIndex).Height = 144;//设置行高
workSheet.Row(curRowIndex).CustomHeight = true;//自动调整行高
workSheet.Column(bodyfieldcellindex + 1).Width = 200;//设置列宽
}
bodyfieldcellindex++;
} }
}
curRowIndex++;
}
}
#endregion #endregion
package.Save();
return path;
} } public class ExportSettings
{
/// <summary>
/// 标题
/// </summary>
///
public string Title { get; set; }
/// <summary>
/// 字段
/// </summary>
public string Field { get; set; }
public int TitleHeight { get; set; } = 30;
public int TitleWidth { get; set; } = 30;
/// <summary>
/// 标题边框颜色
/// </summary>
public ExcelBorderStyle TitleExcelBorderStyle { get; set; } = ExcelBorderStyle.Thin;
/// <summary>
/// 标题字体
/// </summary>
public int TitleFontSize { get; set; } = 15; /// <summary>
/// 标题字体
/// </summary>
public int FieldFontSize { get; set; } = 15;
/// <summary>
/// 字段展示排序
/// </summary>
public int Sort { get; set; } = 2; /// <summary>
/// 跨列数值
/// </summary>
public int CellSpanNum { get; set; } = 0; } public class ExportSettingsCellection
{
public List<ExportSettings> headers { get; set; }
public List<ExportSettings> bodysSettings { get; set; }
/// <summary>
/// 横向需显示字段
/// 注明:headers会根据这个配置的数字去划分一行显示几个字段
/// </summary>
public int ColsShowFildNum { get; set; } = 3;
}
.Net 5.0导出Execl的两种方式的更多相关文章
- (转)DLL中导出函数的两种方式(dllexport与.def文件)
DLL中导出函数的两种方式(dllexport与.def文件)http://www.cnblogs.com/enterBeijingThreetimes/archive/2010/08/04/1792 ...
- 【转】DLL中导出函数的两种方式(dllexport与.def文件)
DLL中导出函数的两种方式(dllexport与.def文件) DLL中导出函数的声明有两种方式: 一种方式是:在函数声明中加上__declspec(dllexport):另外一种方式是:采用模块定义 ...
- dll导出函数的两种方式的比较
最初的网页链接已经挂了, 在此贴一个中间的转载链接 https://blog.csdn.net/zhazhiqiang/article/details/51577523 一 概要 vs中导出 dll的 ...
- DLL中导出函数的两种方式(dllexport与.def文件)
DLL中导出函数的声明有两种方式: 一种方式是:在函数声明中加上__declspec(dllexport): 另外一种方式是:采用模块定义(.def)文件声明,(.def)文件为链接器提供了有关被链接 ...
- DLL声明导出函数的两种方式
DLL中导出函数的声明有两种方式:一种为在函数声明中加上__declspec(dllexport):另外一种方式是采用模块定义(.def) 文件声明,.def文件为链接器提供了有关被链接程序的导出.属 ...
- EntityFramework Core 2.0自定义标量函数两种方式
前言 上一节我们讲完原始查询如何防止SQL注入问题同时并提供了几种方式.本节我们继续来讲讲EF Core 2.0中的新特性自定义标量函数. 自定义标量函数两种方式 在EF Core 2.0中我们可以将 ...
- vue项目中导出PDF的两种方式
参考大家导出的方式,基本上是如下两种: 1.使用 html2Canvas + jsPDF 导出PDF, 这种方式什么都好,就是下载的pdf太模糊了.对要求好的pdf这种方式真是不行啊! 2.调用浏览器 ...
- 【吉光片羽】MVC 导出Word的两种方式
1.直接将Html转成Word.MVC自带FileResult很好用.Html中我们也可以嵌入自己的样式. html: <div id="target"> <st ...
- .NET环境下导出Excel表格的两种方式和导入两种类型的Excel表格
一.导出Excel表格的两种方式,其中两种方式指的是导出XML数据类型的Excel(即保存的时候可以只需要修改扩展名为.xls)和真正的Excel这两种. using System; using Sy ...
- 转载:Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式
Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式 出自:http://www.cnblogs.com/top5/archive/2012/08/04/2623464.html 关 ...
随机推荐
- 页面布局 Stack 层叠组件 Stack 与 Align Stack 与 Positioned 实现定位布局
一.Flutter Stack 组件 Stack 表示堆的意思,我们可以用 Stack 或者 Stack 结合 Align 或者 Stack 结合 Positiond 来实现页面的定位布局 属性 说明 ...
- Java设计模式之抽象工厂(02)
对工厂方法进行抽象.当增加新的产品时,不用改动工厂类.而是集成已有的工厂接口或者抽象工厂,创建新的工厂.这就是对扩展开发,对修改封闭. 1 package Pak; 2 3 public abstra ...
- 2022-3-24内部群每日三题-清辉PMP
1.敏捷团队成员认为每日站会并不会增加价值,是因为小组规模太大.在回顾会议上,他们提出将现有的项目团队分解成更小的小组.Scrum主管应该怎么做? A.缩小团队规模,使站会更易于管理. B.在采取行动 ...
- 047_SOQL 基本查询总结
User currentUser = [SELECT Id, Profile.Name,UserRole.Name FROM User WHERE Id = :UserInfo.getUserId() ...
- 网络服务之DHCP与FTP
目录 DHCP 一.DHCP是什么? 二.DHCP的优点 三.DHCP的分配过程 四.DHCP的工作原理 五.DHCP动态获取实验 FTP 一.FTP是什么? 二.FTP的数据连接模式 三.svftp ...
- java面经学习002
2. Java都有哪些map,分别怎么实现的,具体讲 3. 除了LinkedHashMap,你还知道哪些有序map 4. ConcurrentHashMap讲一讲 5. 为什么要有线程池 6. 线程池 ...
- 学习lua-02,引入其他lua文件,调用全局方法
local testlua = require "testlua" --testlua.compertoNum(1, 2, 4, 5, 11, 23, 543, 123, 45, ...
- Flink akka AskTimeoutException问题排查
最近遇到一个很奇怪的问题,Flink任务正常启动正常运行一段时间后就会报错,,错误详情如下 2019-12-11 17:20:57.757 flink [flink-scheduler-1] ERRO ...
- 2D 消隐效果
在触发消隐的物体(比如玩家)挂下面的代码,以及box collider,rigidbody 2d using UnityEngine; public class ColliderFader : Mon ...
- SQL-分组聚合
-- 语法 select * |列名|表达式 -- 5 from 表名 -- 1 where 条件 ...