OL.FrameCore.Infrastructure/Document/NPOIExcel.cs
(开头部分) 13KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using ClosedXML.Excel;
using Microsoft.AspNetCore.Http;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using OL.FrameCore.Infrastructure.Utility;
using System.ComponentModel;
using System.Runtime.Serialization;
namespace OL.FrameCore.Infrastructure.Document
{
public class NPOIExcel
{
//创建工作薄
protected HSSFWorkbook book;
protected List<ISheet> sheetList;
protected int rowIndex = 0;
protected int sheetIndex = -1;
private ExcelData _excelData;
public NPOIExcel()
{
}
public NPOIExcel(ExcelData excelData)
{
_excelData = excelData;
//表头
if (excelData.Titles != null)
{
var titles = _excelData.Titles;
//判断属性是否存在
var type = _excelData.DataSource.GetType().GetGenericArguments()[0];
var listPropertie = type.GetProperties();
for (int i = 0; i < titles.Count; i++)
{
var property = listPropertie.Where(p => p.Name == titles[i].Name).SingleOrDefault();
if (property == null)
throw new Exception("未找到属性:" + titles[i].Name);
}
}
else//根据实体导出表头
{
var titles = new List<TitleModel>();
var type = _excelData.DataSource.GetType().GetGenericArguments()[0];
var listPropertie = type.GetProperties();
for (int i = 0; i < listPropertie.Length; i++)
{
//忽略字段
后面还有 329 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
