Comments (7)
通过值映射特性。
比如:
[ValueMapping(text: "yes", true)]
[ValueMapping(text: "no", false)]
你可以试试。bool类型这块没写单元测试,有问题再找我。我有空了会试试。
from magicodes.ie.
可行!
from magicodes.ie.
from magicodes.ie.
@DUWENINK 麻烦提供下Demo,最好以单元测试的形势
from magicodes.ie.
运行环境:netcore 3.1+docker(ununtu 21)
实体类
[ExcelImporter(IsLabelingError = true)]
[ExcelExporter(Name = "PFEP", TableStyle = "Light10", AutoFitAllColumn = true)]
public class PFEPExcelDto
{
/// <summary>
/// 工装代码
/// </summary>
[ImporterHeader(Name = "供应商代码", IsAllowRepeat = false)]
[Required(ErrorMessage = "供应商代码")]
//[MaxLength(30, ErrorMessage = "供应商代码超过30字符限制请修改")]
[ExporterHeader(DisplayName = "供应商代码")]
public string OrganizationCode { get; set; }
/// <summary>
///
/// </summary>
[IEIgnore(IsExportIgnore = false, IsImportIgnore = true)]
[ExporterHeader(DisplayName = "供应商名称")]
//[ImporterHeader(Name = "供应商名称", IsAllowRepeat = false)]
public string OrganizationName { get; set; }
/// <summary>
/// 物料代码
/// </summary>
[ImporterHeader(Name = "物料代码", IsAllowRepeat = true)]
[Required(ErrorMessage = "物料代码不能为空")]
[MaxLength(50, ErrorMessage = "物料代码超过50字符限制请修改")]
[ExporterHeader(DisplayName = "物料代码")]
public string ProductCode { get; set; }
/// <summary>
/// 物料名称
/// </summary>
//[ImporterHeader(Name = "物料名称", IsAllowRepeat = true)]
//[Required(ErrorMessage = "物料名称不能为空")]
//[MaxLength(50, ErrorMessage = "物料名称超过50字符限制请修改")]
[ExporterHeader(DisplayName = "物料名称")]
[IEIgnore(IsExportIgnore = false, IsImportIgnore = true)]
public string ProductName { get; set; }
/// <summary>
/// 标准运输包装量
/// </summary>
[Required(ErrorMessage = "标准运输包装量")]
[ImporterHeader(Name = "标准运输包装量", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "标准运输包装量")]
public int Count { get; set; }
/// <summary>
/// 单托箱数量
/// </summary>
[Required(ErrorMessage = "单托箱数量")]
[ImporterHeader(Name = "单托箱数量", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "单托箱数量")]
public int PeerPalletBoxCount { get; set; }
/// <summary>
///
/// </summary>
[Required(ErrorMessage = "时间窗口组代码")]
[ImporterHeader(Name = "时间窗口组代码", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "时间窗口组代码")]
public string TimeWindowCode { get; set; }
/// <summary>
///
/// </summary>
[IEIgnore(IsExportIgnore = false, IsImportIgnore = true)]
[ExporterHeader(DisplayName = "时间窗口组名称")]
public string TimeWindowName { get; set; }
///// <summary>
/////
///// </summary>
//[ExporterHeader(DisplayName = "时间窗口")]
//[IEIgnore(IsExportIgnore = false, IsImportIgnore = true)]
//public string TimeWindowDetailText =>$"{TimeUtil.GetTimeFormat(TimeWindowDetail.StartHour, TimeWindowDetail.StartMinutes, TimeWindowDetail.StartSeconds)}-{TimeUtil.GetTimeFormat(TimeWindowDetail.EndHour, TimeWindowDetail.EndMinutes, TimeWindowDetail.EndSeconds)}" ;
/// <summary>
///
/// </summary>
[Required(ErrorMessage = "运输方案代码")]
[ImporterHeader(Name = "运输方案代码", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "运输方案代码")]
public string TrafficPlanCode { get; set; }
/// <summary>
/// 发运提前时间
/// </summary>
[ImporterHeader(Name = "发运提前时间(小时)", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "发运提前时间(小时)")]
public double? AheadTime { get; set; }
/// <summary>
///
/// </summary>
[ExporterHeader(DisplayName = "运输方案名称")]
[IEIgnore(IsExportIgnore = false, IsImportIgnore = true)]
public string TrafficPlanName { get; set; }
/// <summary>
///
/// </summary>
[ImporterHeader(Name = "箱代码", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "箱代码")]
public string BoxCode { get; set; }
/// <summary>
///
/// </summary>
[ExporterHeader(DisplayName = "箱名称")]
[IEIgnore(IsExportIgnore = false, IsImportIgnore = true)]
public string BoxName { get; set; }
/// <summary>
///
/// </summary>
[ImporterHeader(Name = "托代码", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "托代码")]
public string PalletCode { get; set; }
/// <summary>
///
/// </summary>
[ExporterHeader(DisplayName = "托名称")]
[IEIgnore(IsExportIgnore = false, IsImportIgnore = true)]
public string PalletName { get; set; }
/// <summary>
///
/// </summary>
[ImporterHeader(Name = "箱重(kg)", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "箱重(kg)")]
public double? Weight { get; set; }
/// <summary>
///
/// </summary>
[ImporterHeader(Name = "备注", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "备注")]
public string ReMark { get; set; }
/// <summary>
///
/// </summary>
[ImporterHeader(Name = "是否免检", IsAllowRepeat = true)]
[ExporterHeader(DisplayName = "是否免检")]
[ValueMapping(text: "是", true)]
[ValueMapping(text: "否", false)]
public bool NeedInspection { get; set; }
//---------------------------------------------------
/// <summary>
/// 箱信息
/// </summary>
[IEIgnore(IsExportIgnore = true,IsImportIgnore =true)]
public virtual MdmContainerDto Box { get; set; }
/// <summary>
/// 拖信息
/// </summary>
[IEIgnore(IsExportIgnore = true, IsImportIgnore = true)]
public virtual MdmContainerDto Pallet { get; set; }
/// <summary>
///
/// </summary>
[IEIgnore(IsExportIgnore = true, IsImportIgnore = true)]
public virtual MdmTimewindowDto TimeWindow { get; set; }
/// <summary>
///
/// </summary>
[IEIgnore(IsExportIgnore = true, IsImportIgnore = true)]
public virtual MdmTrafficplanDto TrafficPlan { get; set; }
}
导出接口
/// <summary>
/// 导出数据
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<FileStreamResult> PFEPExcelExport([FromBody] MdmPFEPFilter input)
{
var exp = input.ToExpression();
var data = await _PFEPService.FindAllAsync(exp);
var list = _mapper.Map<List<PFEPExcelDto>>(data);
return await _excelService.Export("PFEP导出", list);
}
from magicodes.ie.
@DUWENINK 抱歉,是我们文档强调的还不够。值映射目前仅支持导入,也就是导出是不支持的,建议你自行转换,比如通过Select方法处理。
暂不支持的主要原因是,从性能上考虑,需要等我们基于EPPlus的源码重写底层。底层重写工作因精力的问题,暂未开始。
from magicodes.ie.
该问题已在2.4 beta1中解决,欢迎大家后续使用2.4版本通过如下代码实现需求:
[ValueMapping(text: "yes", true)]
[ValueMapping(text: "no", false)]
from magicodes.ie.
Related Issues (20)
- 【建议功能】图片导出可以直接嵌入到单元格,否则数据做筛选排序时候图片不能正确排序
- imagesharp 可以升级到3.0版本吗 HOT 1
- 动态多Sheet导入 HOT 1
- excel固定模版导出使用SixLabors.ImageSharp 3.0版本报错 HOT 1
- 存在有excel文件读取workbook的时候获取不同步的问题 HOT 1
- 我想验证导入的数据,某列验证数据类型decimal,需要怎么搞
- wps 编辑后execl导入报错 The given key 'rId1' was not present in the dictionary HOT 3
- 调用 ExportByTemplate<T>(path, output, tplPath)的时候出错 HOT 4
- 如何对ExporterAttribute特性做全局设置? HOT 1
- 目前不支持交叉表导出吗?
- magicodes.ie.excel.aspnetcore 2.7.4.5在WindowServier 2012R2下运行The type initializer for 'SkiaSharp.SKFontStyle' threw an exception. HOT 6
- 空指针异常
- 导出设置ExporterHeader的宽度没有效果 HOT 1
- Magicodes.IE.Pdf无法读取本地文件(图片) HOT 1
- Linux Dcoker构建 .NET8 按HTML模版导出PDF 报错找不到libjpeg62,同样的环境.NET7打包运行后导出PDF就正常 HOT 2
- 一个项目用Magicodes.IE跟NPOI HOT 3
- windows service部署导出word异常
- 同一个数据源,Linux 下面速度慢30s没有导出,windows下5s就导出来了。
- Magicodes.IE 和npoi冲突
- Pls remove throw new ArgumentException("Tablename has spaces") at ExcelTableCollection.ValidateTableName,xlsx is allowed worksheet name Contains empty
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magicodes.ie.