欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#使用NPOI將List數(shù)據(jù)導(dǎo)出到Excel文檔

 更新時間:2022年02月21日 16:32:16   作者:RunnerDNA  
這篇文章主要為大家詳細(xì)介紹了C#使用NPOI將List數(shù)據(jù)導(dǎo)出到Excel文檔,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

NPOI是一個開源的C#讀寫Excel、WORD等微軟OLE2組件文檔的項目。使用 NPOI 可以在沒有安裝 Office 或者相應(yīng)環(huán)境的機器上對 WORD/EXCEL 文檔進行讀寫。

這里簡單封裝了一個使用NPOI導(dǎo)出Excel的DLL,方便項目使用。步驟如下:

1、NuGet包管理器添加對NPOI和log4net的安裝引用

2、添加Excel屬性信息類ExcelProperty.cs

/// <summary>
/// 用于定義導(dǎo)出的excel屬性
/// </summary>
public class ExcelProperty
? ? {
? ? ? ? public ExcelProperty() { }
?
? ? ? ? /// <summary>
? ? ? ? /// 文件基本屬性
? ? ? ? /// </summary>
? ? ? ? /// <param name="company">公司名稱</param>
? ? ? ? /// <param name="author">作者信息</param>
? ? ? ? /// <param name="ApplicationName">創(chuàng)建程序信息</param>
? ? ? ? /// <param name="Comments">填加xls文件備注</param>
? ? ? ? /// <param name="title">填加xls文件標(biāo)題信息</param>
? ? ? ? /// <param name="Subject">填加文件主題信息</param>
? ? ? ? public ExcelProperty(string company, string author, string applicationName, string comments, string title, string subject)
? ? ? ? {
? ? ? ? ? ? this.Company = company;
? ? ? ? ? ? this.Author = author;
? ? ? ? ? ? this.ApplicationName = applicationName;
? ? ? ? ? ? this.Comments = comments;
? ? ? ? ? ? this.Title = title;
? ? ? ? ? ? this.Subject = subject;
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 公司名稱
? ? ? ? /// </summary>
? ? ? ? private string company = "";
? ? ? ? /// <summary>
? ? ? ? /// 公司名稱
? ? ? ? /// </summary>
? ? ? ? public string Company
? ? ? ? {
? ? ? ? ? ? get { return company; }
? ? ? ? ? ? set { company = value; }
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 作者信息
? ? ? ? /// </summary>
? ? ? ? private string author = "";
? ? ? ? /// <summary>
? ? ? ? /// 作者信息
? ? ? ? /// </summary>
? ? ? ? public string Author
? ? ? ? {
? ? ? ? ? ? get { return author; }
? ? ? ? ? ? set { author = value; }
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 創(chuàng)建程序信息
? ? ? ? /// </summary>
? ? ? ? private string applicationName = "";
? ? ? ? /// <summary>
? ? ? ? /// 創(chuàng)建程序信息
? ? ? ? /// </summary>
? ? ? ? public string ApplicationName
? ? ? ? {
? ? ? ? ? ? get { return applicationName; }
? ? ? ? ? ? set { applicationName = value; }
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? ///填加xls文件備注
? ? ? ? /// </summary>
? ? ? ? private string comments = "";
? ? ? ? /// <summary>
? ? ? ? ///填加xls文件備注
? ? ? ? /// </summary>
? ? ? ? public string Comments
? ? ? ? {
? ? ? ? ? ? get { return comments; }
? ? ? ? ? ? set { comments = value; }
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 填加xls文件標(biāo)題信息
? ? ? ? /// </summary>
? ? ? ? private string title = "";
? ? ? ? /// <summary>
? ? ? ? /// 填加xls文件標(biāo)題信息
? ? ? ? /// </summary>
? ? ? ? public string Title
? ? ? ? {
? ? ? ? ? ? get { return title; }
? ? ? ? ? ? set { title = value; }
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 填加文件主題信息
? ? ? ? /// </summary>
? ? ? ? private string subject = "";
? ? ? ? /// <summary>
? ? ? ? /// 填加文件主題信息
? ? ? ? /// </summary>
? ? ? ? public string Subject
? ? ? ? {
? ? ? ? ? ? get { return subject; }
? ? ? ? ? ? set { subject = value; }
? ? ? ? }
? ? }

3、添加Excel導(dǎo)出類ExcelExportHelper.cs

using log4net;
using NPOI.HPSF;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text;
?
namespace NPOIExcelExportHelper
{
? ? public class ExcelExportHelper
? ? {
? ? ? ? //委托
? ? ? ? public delegate void ExportResult(bool res);
? ? ? ? public event ExportResult ExportResultEvent;
?
? ? ? ? //構(gòu)造函數(shù)
? ? ? ? public ExcelExportHelper() { }
? ? ? ? public ExcelExportHelper(ILog loghelper)
? ? ? ? {
? ? ? ? ? ? this.LogHelper = loghelper;
? ? ? ? }
?
? ? ? ? /// <summary>
? ? ? ? /// 日志
? ? ? ? /// </summary>
? ? ? ? private ILog LogHelper;
? ? ? ? /// <summary>
? ? ? ? /// 要導(dǎo)出的Excel對象
? ? ? ? /// </summary>
? ? ? ? private HSSFWorkbook workbook = null;
? ? ? ? /// <summary>
? ? ? ? /// 要導(dǎo)出的Excel對象屬性
? ? ? ? /// </summary>
? ? ? ? private HSSFWorkbook Workbook
? ? ? ? {
? ? ? ? ? ? get
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (workbook == null)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? workbook = new HSSFWorkbook();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? return workbook;
? ? ? ? ? ? }
? ? ? ? ? ? set { workbook = value; }
? ? ? ? }
?
? ? ? ? /// <summary>
? ? ? ? /// 設(shè)置Excel文件基本屬性
? ? ? ? /// </summary>
? ? ? ? /// <param name="ep">屬性</param>
? ? ? ? public void SetExcelProperty(ExcelProperty ep)
? ? ? ? {
? ? ? ? ? ? DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
? ? ? ? ? ? dsi.Company = ep.Company;//填加xls文件公司信息
? ? ? ? ? ? Workbook.DocumentSummaryInformation = dsi;
?
? ? ? ? ? ? SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
? ? ? ? ? ? si.Author = ep.Author; //填加xls文件作者信息
? ? ? ? ? ? si.ApplicationName = ep.ApplicationName; //填加xls文件創(chuàng)建程序信息
? ? ? ? ? ? si.Comments = ep.Comments; //填加xls文件備注
? ? ? ? ? ? si.Title = ep.Title; //填加xls文件標(biāo)題信息
? ? ? ? ? ? si.Subject = ep.Subject;//填加文件主題信息
? ? ? ? ? ? si.CreateDateTime = DateTime.Now;
? ? ? ? ? ? Workbook.SummaryInformation = si;
? ? ? ? }
?
? ? ? ? /// <summary>
? ? ? ? /// 泛型列表List導(dǎo)出到Excel文件
? ? ? ? /// </summary>
? ? ? ? /// <param name="list">源List表</param>
? ? ? ? /// <param name="strHeaderText">標(biāo)題信息</param>
? ? ? ? /// <param name="strFileName">保存路徑</param>
? ? ? ? /// <param name="titles">列名</param>
? ? ? ? public void ExportToFile<T>(List<T> list, string strHeaderText, string strFileName, string[] titles = null)
? ? ? ? {
? ? ? ? ? ? try
? ? ? ? ? ? {
? ? ? ? ? ? ? ? //轉(zhuǎn)換數(shù)據(jù)源
? ? ? ? ? ? ? ? DataTable dtSource = ListToDataTable(list, titles);
? ? ? ? ? ? ? ? //開始導(dǎo)出
? ? ? ? ? ? ? ? Export(dtSource, strHeaderText, strFileName);
? ? ? ? ? ? ? ? System.GC.Collect();
? ? ? ? ? ? ? ? ExportResultEvent?.Invoke(true);
? ? ? ? ? ? }
? ? ? ? ? ? catch (Exception ex)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (LogHelper != null)
? ? ? ? ? ? ? ? ? ? LogHelper.Error(string.Format("ExportToFile error:{0}", ex));
? ? ? ? ? ? ? ? ExportResultEvent?.Invoke(false);
? ? ? ? ? ? }
? ? ? ? }
?
? ? ? ? /// <summary>
? ? ? ? /// DataTable導(dǎo)出到Excel文件
? ? ? ? /// </summary>
? ? ? ? /// <param name="dtSource">源DataTable</param>
? ? ? ? /// <param name="strHeaderText">標(biāo)題信息</param>
? ? ? ? /// <param name="strFileName">保存路徑</param>
? ? ? ? public void Export(DataTable dtSource, string strHeaderText, string strFileName)
? ? ? ? {
? ? ? ? ? ? using (MemoryStream ms = Export(dtSource, strHeaderText))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? using (FileStream fs = new FileStream(strFileName, FileMode.Create, FileAccess.Write))
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? byte[] data = ms.ToArray();
? ? ? ? ? ? ? ? ? ? fs.Write(data, 0, data.Length);
? ? ? ? ? ? ? ? ? ? fs.Flush();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
?
? ? ? ? /// <summary>
? ? ? ? /// DataTable導(dǎo)出到Excel的MemoryStream
? ? ? ? /// </summary>
? ? ? ? /// <param name="dtSource">源DataTable</param>
? ? ? ? /// <param name="strHeaderText">標(biāo)題信息</param>
? ? ? ? private MemoryStream Export(DataTable dtSource, string strHeaderText)
? ? ? ? {
? ? ? ? ? ? ISheet sheet = Workbook.CreateSheet();
? ? ? ? ? ? ICellStyle dateStyle = Workbook.CreateCellStyle();
? ? ? ? ? ? IDataFormat format = Workbook.CreateDataFormat();
? ? ? ? ? ? dateStyle.DataFormat = format.GetFormat("yyyy-mm-dd");
?
? ? ? ? ? ? //取得列寬
? ? ? ? ? ? int[] arrColWidth = new int[dtSource.Columns.Count];
? ? ? ? ? ? foreach (DataColumn item in dtSource.Columns)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? arrColWidth[item.Ordinal] = Encoding.GetEncoding(936).GetBytes(item.ColumnName.ToString()).Length;
? ? ? ? ? ? }
? ? ? ? ? ? for (int i = 0; i < dtSource.Rows.Count; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int j = 0; j < dtSource.Columns.Count; j++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? int intTemp = Encoding.GetEncoding(936).GetBytes(dtSource.Rows[i][j].ToString()).Length;
? ? ? ? ? ? ? ? ? ? if (intTemp > arrColWidth[j])
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? arrColWidth[j] = intTemp;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? int rowIndex = 0;
? ? ? ? ? ? foreach (DataRow row in dtSource.Rows)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? #region 新建表,填充表頭,填充列頭,樣式
? ? ? ? ? ? ? ? if (rowIndex == 65535 || rowIndex == 0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (rowIndex != 0)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? sheet = Workbook.CreateSheet();
? ? ? ? ? ? ? ? ? ? }
?
? ? ? ? ? ? ? ? ? ? #region 表頭及樣式
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? IRow headerRow = sheet.CreateRow(0);
? ? ? ? ? ? ? ? ? ? ? ? headerRow.HeightInPoints = 25;
? ? ? ? ? ? ? ? ? ? ? ? headerRow.CreateCell(0).SetCellValue(strHeaderText);
?
? ? ? ? ? ? ? ? ? ? ? ? ICellStyle headStyle = Workbook.CreateCellStyle();
? ? ? ? ? ? ? ? ? ? ? ? headStyle.Alignment = HorizontalAlignment.Center;
? ? ? ? ? ? ? ? ? ? ? ? IFont font = Workbook.CreateFont();
? ? ? ? ? ? ? ? ? ? ? ? font.FontHeightInPoints = 20;
? ? ? ? ? ? ? ? ? ? ? ? font.Boldweight = 700;
? ? ? ? ? ? ? ? ? ? ? ? headStyle.SetFont(font);
? ? ? ? ? ? ? ? ? ? ? ? headerRow.GetCell(0).CellStyle = headStyle;
? ? ? ? ? ? ? ? ? ? ? ? //CellRangeAddress四個參數(shù)為:起始行,結(jié)束行,起始列,結(jié)束列
? ? ? ? ? ? ? ? ? ? ? ? sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, dtSource.Columns.Count - 1));
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? #endregion
?
? ? ? ? ? ? ? ? ? ? #region 列頭及樣式
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? IRow headerRow = sheet.CreateRow(1);
? ? ? ? ? ? ? ? ? ? ? ? ICellStyle headStyle = Workbook.CreateCellStyle();
? ? ? ? ? ? ? ? ? ? ? ? headStyle.Alignment = HorizontalAlignment.Center;
? ? ? ? ? ? ? ? ? ? ? ? IFont font = Workbook.CreateFont();
? ? ? ? ? ? ? ? ? ? ? ? font.FontHeightInPoints = 10;
? ? ? ? ? ? ? ? ? ? ? ? font.Boldweight = 700;
? ? ? ? ? ? ? ? ? ? ? ? headStyle.SetFont(font);
? ? ? ? ? ? ? ? ? ? ? ? foreach (DataColumn column in dtSource.Columns)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
? ? ? ? ? ? ? ? ? ? ? ? ? ? headerRow.GetCell(column.Ordinal).CellStyle = headStyle;
? ? ? ? ? ? ? ? ? ? ? ? ? ? //設(shè)置列寬
? ? ? ? ? ? ? ? ? ? ? ? ? ? sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal] + 1) * 256);
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? #endregion
?
? ? ? ? ? ? ? ? ? ? rowIndex = 2;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? #endregion
?
? ? ? ? ? ? ? ? #region 填充內(nèi)容
? ? ? ? ? ? ? ? IRow dataRow = sheet.CreateRow(rowIndex);
? ? ? ? ? ? ? ? foreach (DataColumn column in dtSource.Columns)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ICell newCell = dataRow.CreateCell(column.Ordinal);
? ? ? ? ? ? ? ? ? ? string drValue = row[column].ToString();
? ? ? ? ? ? ? ? ? ? switch (column.DataType.ToString())
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? case "System.String"://字符串類型
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue(drValue);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? case "System.DateTime"://日期類型
? ? ? ? ? ? ? ? ? ? ? ? ? ? DateTime dateV;
? ? ? ? ? ? ? ? ? ? ? ? ? ? DateTime.TryParse(drValue, out dateV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue(dateV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.CellStyle = dateStyle;//格式化顯示
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? case "System.Boolean"://布爾型
? ? ? ? ? ? ? ? ? ? ? ? ? ? bool boolV = false;
? ? ? ? ? ? ? ? ? ? ? ? ? ? bool.TryParse(drValue, out boolV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue(boolV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? case "System.Int16"://整型
? ? ? ? ? ? ? ? ? ? ? ? case "System.Int32":
? ? ? ? ? ? ? ? ? ? ? ? case "System.Int64":
? ? ? ? ? ? ? ? ? ? ? ? case "System.Byte":
? ? ? ? ? ? ? ? ? ? ? ? ? ? int intV = 0;
? ? ? ? ? ? ? ? ? ? ? ? ? ? int.TryParse(drValue, out intV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue(intV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? case "System.Decimal"://浮點型
? ? ? ? ? ? ? ? ? ? ? ? case "System.Double":
? ? ? ? ? ? ? ? ? ? ? ? ? ? double doubV = 0;
? ? ? ? ? ? ? ? ? ? ? ? ? ? double.TryParse(drValue, out doubV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue(doubV);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? case "System.DBNull"://空值處理
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue("");
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue("");
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? #endregion
?
? ? ? ? ? ? ? ? rowIndex++;
? ? ? ? ? ? }
? ? ? ? ? ? using (MemoryStream ms = new MemoryStream())
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Workbook.Write(ms);
? ? ? ? ? ? ? ? ms.Flush();
? ? ? ? ? ? ? ? ms.Position = 0;
? ? ? ? ? ? ? ? return ms;
? ? ? ? ? ? }
? ? ? ? }
?
? ? ? ? /// <summary>
? ? ? ? /// 泛型列表List轉(zhuǎn)換為DataTable
? ? ? ? /// </summary>
? ? ? ? /// <typeparam name="T">泛型實體</typeparam>
? ? ? ? /// <param name="list">要轉(zhuǎn)換的列表</param>
? ? ? ? /// <param name="titles">標(biāo)題</param>
? ? ? ? /// <returns></returns>
? ? ? ? public DataTable ListToDataTable<T>(List<T> list, string[] titles)
? ? ? ? {
? ? ? ? ? ? DataTable dt = new DataTable();
? ? ? ? ? ? Type listType = typeof(T);
? ? ? ? ? ? PropertyInfo[] properties = listType.GetProperties();
? ? ? ? ? ? //標(biāo)題行
? ? ? ? ? ? if (titles != null && properties.Length == titles.Length)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int i = 0; i < properties.Length; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? PropertyInfo property = properties[i];
? ? ? ? ? ? ? ? ? ? dt.Columns.Add(new DataColumn(titles[i], property.PropertyType));
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int i = 0; i < properties.Length; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? PropertyInfo property = properties[i];
? ? ? ? ? ? ? ? ? ? dt.Columns.Add(new DataColumn(property.Name, property.PropertyType));
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? //內(nèi)容行
? ? ? ? ? ? foreach (T item in list)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? DataRow dr = dt.NewRow();
? ? ? ? ? ? ? ? for (int i = 0; i < dt.Columns.Count; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? dr[i] = properties[i].GetValue(item, null);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? dt.Rows.Add(dr);
? ? ? ? ? ? }
? ? ? ? ? ? return dt;
? ? ? ? }
? ? }
}

調(diào)用方法:

1、新建一項目,添加對上述DLL的引用

2、創(chuàng)建TestItem測試類

public class TestItem
? ? {
? ? ? ? public string Name { get; set; }
? ? ? ? public int Id { get; set; }
? ? ? ? public string Date { get; set; }
? ? ? ? public TestItem(string name, int id, string date)
? ? ? ? {
? ? ? ? ? ? Name = name;
? ? ? ? ? ? Id = id;
? ? ? ? ? ? Date = date;
? ? ? ? }
? ? }

3、調(diào)用

private void GetList()
? ? ? ? {
? ? ? ? ? ? List<TestItem> list = new List<TestItem>();
? ? ? ? ? ? for (int i = 0; i < 100000; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? list.Add(new TestItem("姓名" + i, i, "2020-04-21"));
? ? ? ? ? ? }
? ? ? ? ? ? ExcelExportHelper exportHelper = new ExcelExportHelper();
? ? ? ? ? ? exportHelper.ExportResultEvent += ExportHelper_ExportResultEvent;
? ? ? ? ? ? exportHelper.SetExcelProperty(new ExcelProperty("TEST", "DNA", "ExcelExport", "", "統(tǒng)計查詢", "統(tǒng)計信息"));
? ? ? ? ? ? exportHelper.ExportToFile(list, "查詢結(jié)果統(tǒng)計", @"C:\Test.xls", new string[]{ "姓名", "編號", "日期"});
? ? ? ? }
?
? ? ? ? private void ExportHelper_ExportResultEvent(bool res)
? ? ? ? {
? ? ? ? ? ? Console.Write(res);
? ? ? ? }

4、結(jié)果

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#調(diào)用FFplay實現(xiàn)播放視頻功能

    C#調(diào)用FFplay實現(xiàn)播放視頻功能

    這篇文章主要為大家詳細(xì)介紹了C#如何調(diào)用FFplay實現(xiàn)播放視頻功能,文中的示例代碼講解詳細(xì),具有一定的參考價值,有需要的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-10-10
  • 詳細(xì)聊聊C#的并發(fā)機制優(yōu)秀在哪

    詳細(xì)聊聊C#的并發(fā)機制優(yōu)秀在哪

    并發(fā)其實是一個很泛的概念,字面意思就是"同時做多件事",不過方式有所不同,下面這篇文章主要給大家介紹了關(guān)于C#并發(fā)機制的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-02-02
  • C# 泛型的約束

    C# 泛型的約束

    本文將詳細(xì)介紹C# 泛型的約束:引用類型約束;值類型約束;構(gòu)造函數(shù)類型約束;轉(zhuǎn)換類型約束;組合約束的相關(guān)知識。具有很好的參考價值,下面跟著小編一起來看下吧
    2017-02-02
  • C#連接Oracle數(shù)據(jù)庫字符串(引入DLL)的方式

    C#連接Oracle數(shù)據(jù)庫字符串(引入DLL)的方式

    這篇文章主要給大家介紹了關(guān)于C#連接Oracle數(shù)據(jù)庫字符串(引入DLL)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • C#中屬性和成員變量的區(qū)別說明

    C#中屬性和成員變量的區(qū)別說明

    本篇文章主要是對C#中屬性和成員變量的區(qū)別進行了介紹說明。需要的朋友可以過來參考下,希望對大家有所幫助
    2014-01-01
  • 使用設(shè)計模式中的工廠方法模式進行C#編程的示例講解

    使用設(shè)計模式中的工廠方法模式進行C#編程的示例講解

    這篇文章主要介紹了使用設(shè)計模式中的工廠方法模式進行C#編程的示例講解,工廠方法模式可以看作是對簡單工廠模式的進一步擴展,需要的朋友可以參考下
    2016-02-02
  • unity shader實現(xiàn)玻璃折射效果

    unity shader實現(xiàn)玻璃折射效果

    這篇文章主要為大家詳細(xì)介紹了unity shader實現(xiàn)玻璃折射效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • C#中IsNullOrEmpty和IsNullOrWhiteSpace的使用方法及區(qū)別解析

    C#中IsNullOrEmpty和IsNullOrWhiteSpace的使用方法及區(qū)別解析

    今天我們將探討C#中兩個常用的字符串處理方法:IsNullOrEmpty和IsNullOrWhiteSpace,本文中,我們將詳細(xì)解釋這兩個方法的功能和使用場景,并幫助您更好地理解它們之間的區(qū)別,本文結(jié)合實例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2023-07-07
  • Unity3D更改默認(rèn)的腳本編輯器

    Unity3D更改默認(rèn)的腳本編輯器

    這篇文章簡要的說明了如何去修改Unity默認(rèn)的腳本編輯器,大大提升了靈活性和便捷性,文本有詳細(xì)的圖文介紹,能讓你觀看的更加清晰,希望對你有所幫助
    2021-06-06
  • C#實現(xiàn)JSON解析器MojoUnityJson功能(簡單且高效)

    C#實現(xiàn)JSON解析器MojoUnityJson功能(簡單且高效)

    MojoUnityJson 是使用C#實現(xiàn)的JSON解析器 ,算法思路來自于游戲引擎Mojoc的C語言實現(xiàn) Json.h。這篇文章主要介紹了C#實現(xiàn)JSON解析器MojoUnityJson的方法,需要的朋友可以參考下
    2018-01-01

最新評論