src/EasyFrameWork/DataTransfer/ExcelReader.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using System.Linq;
using Easy.MetaData;
using System.Reflection;
using Easy.ViewPort.Descriptor;
using Easy.Reflection;
namespace Easy.DataTransfer
{
public class ExcelReader<T> where T : new()
{
private readonly Stream _excelStream;
private WorkbookPart _workBookPart;
private ViewConfigure _viewConfigure;
private PropertyInfo[] _entryProperites;
public ExcelReader(Stream stream)
{
_excelStream = stream;
ErrorMessages = new List<string>();
Converts = new List<IValueTypeConvert>();
}
public ExcelReader(Stream stream, List<IValueTypeConvert> converts)
{
_excelStream = stream;
ErrorMessages = new List<string>();
Converts = converts;
}
public Type EntryType { get { return typeof(T); } }
public List<IValueTypeConvert> Converts { get; set; }
public List<string> ErrorMessages { get; set; }
public virtual T CellConvert(T item, string header, Cell cell)
{
Type type = typeof(T);
string propertyName = header;
string value = ReadCellValue(cell);
if (_viewConfigure != null)
{
var descriptor = _viewConfigure.GetViewPortDescriptors(true).FirstOrDefault(m => m.DisplayName == header);
if (descriptor != null)
{
propertyName = descriptor.Name;
var dropdown = descriptor as DropDownListDescriptor;
if (dropdown != null)
{
foreach (var op in dropdown.OptionItems)
{
if (op.Value == value)
{
value = op.Key;
后面还有 116 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。