holdengong / easyoffice Goto Github PK
View Code? Open in Web Editor NEWa library to easy manipulate excel,word for .net core...一句调用代码即可实现常规的导入导出Excel,生成Word。
a library to easy manipulate excel,word for .net core...一句调用代码即可实现常规的导入导出Excel,生成Word。
你好,
我创建了一个Computer类,在Computer类中有一个List属性的Memory类,然后在Memory类下面又有一个List属性的Manufacture类。我创建了一个Word模板,怎样依次遍历各List属性Memory中的项?以及它的子项Manufacture中的项?
非常感谢!
能否增加word excel转html的支持
大佬 请教一个问题:
var word = await _wordExportService.CreateFromTemplateAsync(templateurl, model);
这段代码提示 提示打开模板文件失败 怎么解决
导出DateTime?
类型的日期格式为 8/13/2019 12:00:00 AM
使用Excel中的日期格式转换,无法转换成其他日期格式。使用 YEAR(K4)
公式求值时,提示为`#VALUE!```。
能增加边框样式和自动列宽吗?谢谢
这个方法
public static IEnumerable FastConvert(this IEnumerable rows)
当传入的rows是不同数据时,转换出来的数据变成了一样。比如传入3条不一样的数据,转换出来的list,里面的T数据都是一样的。
断点跟踪的时候可以确定rows不一样的数据
大部分Dto都是写在一个standard项目中而不是core项目中,所以建议将标注类 接口等公共的放到standard的nuget包里去
如题,如何导出一个excel里包含多个sheet?
添加图片之前需要SetText空字符串将原来的{替换掉,否则在图片前面会有一个"{"
我是在NPOIWordExtensions类的74行加了一行
xwpfRun.SetText("");
在windows上可以正确到处excel,但是在编译部署到linux上就无法导出了。打印出来。_excelExportService.ExportAsync 在这步就报错了. 环境是 .net core 2.2+centos 7.6;
return File
) var bytes = await _excelExportService.ExportAsync(new ExportOption<ExcelCarTemplateDTO>()
{
Data = list,
DataRowStartIndex = 1, //数据行起始索引,默认1
ExportType = ExportType.XLSX, 默认导出Excel类型,默认xlsx
HeaderRowIndex = 0, //表头行索引,默认0
SheetName = "sheet1" //页签名称,默认sheet1
});
var memoryStream = new MemoryStream();
await memoryStream.WriteAsync(bytes);
memoryStream.Position = 0;
return File(memoryStream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"test.xlsx",
true);
public class WordCarTemplateDTO
{
//默认占位符为{PropertyName}
public string OwnerName { get; set; }
[Placeholder("{Car_Type Car Type}")] //重写占位符
public string CarType { get; set; }
//使用Picture或IEnumerable<Picture>类型可以将占位符替换为图片
public IEnumerable<Picture> CarPictures { get; set; }
public Picture CarLicense { get; set; }
}
public static void ExportWord()
{
string templateUrl = @"d:\template.docx";
WordCarTemplateDTO car = new WordCarTemplateDTO()
{
OwnerName = "刘德华",
CarType = "豪华型宾利",
CarPictures = new List<Picture>() {
new Picture()
{
PictureUrl = "https://g.csdnimg.cn/static/user-reg-year/1x/5.png", //图片绝对地址,如果设置了PictureData此项不生效
FileName = "图片1",//文件名称
Height = 10,//图片高度单位厘米默认8
Width = 3,//图片宽度单位厘米默认14
PictureData = null,//图片流数据,优先取这里的数据,没有则取url
PictureType = PictureTypeEnum.PNG //图片类型,默认jpeg
},
new Picture(){
PictureUrl = "http://a0.att.hudong.com/78/52/01200000123847134434529793168.jpg"
}
},
CarLicense = new Picture { PictureUrl = "http://pic271.nipic.com/file/20200225/2725869_163940862198_2.jpg" }
};
WordExportService _wordExportService = new WordExportService(new WordExportProvider());
var word = _wordExportService.CreateFromTemplateAsync(templateUrl, car).Result;
File.WriteAllBytes(@"d:\file.docx", word.WordBytes);
}
模板及导出结果如下,我是在控制台应用下导的:
template.docx
file.docx
既然使用了ServiceCollection,完全可以使用自带的,或者是再抽象一层;或者是再加一个工程,给使用autofac的作为扩展
导入文件时,现在是读取文件绝对路径,希望后面可以根据文件流读取文件数据。
这个库非常棒 但是我们有很多framework的项目,可以添加framework4.5+版本的支持吗?因为目前老项目不可能这么快迁移到core的。
导出excel 能否支持动态表头
导出excel可以新增 导出图片吗? 很需要这个功能 谢谢!
对于给定的dto,假设只存在属性A,ColName指定为“列A”,并标注验证特性。然后给定excel,标题行中只有一列“列B”,此时获取的ExcelDataCol中的PropertyName就会为null,后面再校验时属性A的验证就被忽略了。请问是特意这样设计的吗?
补充:针对其他类型的校验,属性不能匹配列获取值导致无法校验,是可以理解的。但是个人觉得Required必填校验不太应该被忽略。
需要调用两次方法来实现嘛?
我觉的提问者应该是上图中的意思(图中命名是随意写的),单元测试里好像没有这种使用场景:在同一个表格表单中,上部分是固定的,下部分是一个列表。
我也遇到了这种需求。
Originally posted by @lc1055 in #4 (comment)
找不到所在的命名空间
libwkhtmltox.dll,libwkhtmltox.so 按照要求放到根目录下了,怎么还是报【Unable to load DLL 'libwkhtmltox' or one of its dependencies: 找不到指定的模块。】的错误啊?
不错的轮子,可惜没有 Java 版
我在做导入excel文件数据到数据库的功能,当我写代码var importData = validDatas.Convert().ToList(),xxx中createtime是DateTime类型字段,excel中没有提供createtime列的数值时,这行代码会报错,当我把DateTime改成DateTime?时,importData中的实体createtime字段值一直是null
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.