Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

long类型的字段无法正常设置为文本 #627

Open
1 of 4 tasks
The-Mojoo opened this issue Jul 12, 2024 · 2 comments
Open
1 of 4 tasks

long类型的字段无法正常设置为文本 #627

The-Mojoo opened this issue Jul 12, 2024 · 2 comments

Comments

@The-Mojoo
Copy link

Excel Type

  • XLSX
  • XLSM
  • CSV
  • OTHER

Upload Excel File

[
b25a7003-8062-4c93-8926-a1a1407697a8.xlsx
](url)

MiniExcel Version

1.33.0

Description

我的数据源有long类型的字段,已经在代码中将excel的列格式设置为文本格式(@),虽然生成的excel看起来是正常显示了的,但实际上点击下就变成了科学计数法,而且列的格式显示的仍然是常规。

image
image

var path = Path.Combine("C:\\Demo\\", $"{Guid.NewGuid()}.xlsx");
var config = new OpenXmlConfiguration
{
    AutoFilter = false,
    DynamicColumns =
    [
        new DynamicExcelColumn("long2") { Format = "@", Width = 25 },
    ]
};
var value = new[] { new { long2 = "1550432695793487872" } };
MiniExcel.SaveAs(path, value, configuration: config);
@shps951023
Copy link
Member

可以判断是否超过值,假如超过在前面加上 '
image

@shps951023 shps951023 reopened this Jul 21, 2024
@shps951023
Copy link
Member

shps951023 commented Jul 21, 2024

更新,SaveAs 应该要增加长数值判断,自动加上 style quotePrefix="1" 并把 text 的值改为去除 '
下个版本实现选项 EnableQuotePrefix 给用户选择
image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants