Giter VIP home page Giter VIP logo

Comments (8)

xin-lai avatar xin-lai commented on May 15, 2024

把你的代码贴上来看看

from magicodes.ie.

pjy612 avatar pjy612 commented on May 15, 2024
[ExcelExporter]
        class LongToStr
        {
            [ExporterHeader("Long",format:"@")]
            public long Long { get; set; }
            [ExporterHeader("String")]
            public String Str => Long.ToString();
        }

List<LongToStr> list = new List<LongToStr>();
            for (long i = 9223372036854775797L; i > 9223372036854775787L; i--)
            {
                list.Add(new LongToStr(){Long = i});
            }
            ExcelExporter exporter = new ExcelExporter();
            exporter.Export("test.xlsx", list);

image

我希望能让数字显示成字符串 = =。有什么方法吗?

from magicodes.ie.

xin-lai avatar xin-lai commented on May 15, 2024

#,##0

from magicodes.ie.

xin-lai avatar xin-lai commented on May 15, 2024

[ExporterHeader(DisplayName = "长数值", Format = "#,##0")]

from magicodes.ie.

pjy612 avatar pjy612 commented on May 15, 2024

[ExporterHeader(DisplayName = "长数值", Format = "#,##0")]

###0
#0
#
0

我刚都试了,然后 失真了。。。
image

Long String
9223372036854780000 9223372036854775797
9223372036854780000 9223372036854775796
9223372036854780000 9223372036854775795

from magicodes.ie.

pjy612 avatar pjy612 commented on May 15, 2024

如果暂不支持的话 将来能不能在 Attr 里面加个 type 什么的 让字段当字符串 处理

from magicodes.ie.

xin-lai avatar xin-lai commented on May 15, 2024

等我有空测试一下。
可以考虑。

from magicodes.ie.

xin-lai avatar xin-lai commented on May 15, 2024

设置为“#”是OK的,但是如果数值过长的话,在写入的时候已经存在数据丢失,因此无论你如何设置格式,都是不对的。哪怕再将其转为文本类型。
基于以上情形,建议如下:

  • 将DTO长数值列设置为string类型
  • 然后使用Select将你的原始List做一个转换再进行导出

后续可以考虑通过特性处理,或者提供数据筛选器。

from magicodes.ie.

Related Issues (20)

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.