Giter Site home page Giter Site logo

easyoffice's People

Contributors

holdengong avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

loyouyang

easyoffice's Issues

DTO中如果有嵌套类如何解析?

你好,
我创建了一个Computer类,在Computer类中有一个List属性的Memory类,然后在Memory类下面又有一个List属性的Manufacture类。我创建了一个Word模板,怎样依次遍历各List属性Memory中的项?以及它的子项Manufacture中的项?
非常感谢!

打开模板文件失败

大佬 请教一个问题:
var word = await _wordExportService.CreateFromTemplateAsync(templateurl, model);
这段代码提示 提示打开模板文件失败 怎么解决

FastConvert 转换错误

这个方法
public static IEnumerable FastConvert(this IEnumerable rows)
当传入的rows是不同数据时,转换出来的数据变成了一样。比如传入3条不一样的数据,转换出来的list,里面的T数据都是一样的。
断点跟踪的时候可以确定rows不一样的数据

在linux上无法运行。

在windows上可以正确到处excel,但是在编译部署到linux上就无法导出了。打印出来。_excelExportService.ExportAsync 在这步就报错了. 环境是 .net core 2.2+centos 7.6;

建议文档增加一个直接返回File 的实例

导出Excel(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);

导出word时,url图片导不出来,还留了个{

  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

建议移除autofac的依赖

既然使用了ServiceCollection,完全可以使用自带的,或者是再抽象一层;或者是再加一个工程,给使用autofac的作为扩展

行数读取错误,导致row为null错误

image

如图,excel带格式,读出的行数是非实际填写的数据。(实际填写2行+1行表头,但实际读取出是4行)
image

public static ExcelDataRow Convert(IRow row, ExcelHeaderRow headerRow)
此方法没有判断row可能为null的情况,然后就异常了

导入文件路径

导入文件时,现在是读取文件绝对路径,希望后面可以根据文件流读取文件数据。

可以兼容net framework 4.5吗?

这个库非常棒 但是我们有很多framework的项目,可以添加framework4.5+版本的支持吗?因为目前老项目不可能这么快迁移到core的。

Excel导入验证特性对于无法匹配标题行的dto属性无效?

对于给定的dto,假设只存在属性A,ColName指定为“列A”,并标注验证特性。然后给定excel,标题行中只有一列“列B”,此时获取的ExcelDataCol中的PropertyName就会为null,后面再校验时属性A的验证就被忽略了。请问是特意这样设计的吗?
补充:针对其他类型的校验,属性不能匹配列获取值导致无法校验,是可以理解的。但是个人觉得Required必填校验不太应该被忽略。

EasyOffice.Utils.ExcelExtensionMethods.Convert<T>()方法不能转datetime?字段

我在做导入excel文件数据到数据库的功能,当我写代码var importData = validDatas.Convert().ToList(),xxx中createtime是DateTime类型字段,excel中没有提供createtime列的数值时,这行代码会报错,当我把DateTime改成DateTime?时,importData中的实体createtime字段值一直是null

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.