Skip to content

Feature Request: Auto Fit Column Width Support / 功能请求:添加自动列宽支持 #7

@Himmelt

Description

@Himmelt

Description

Feature Request: Add Auto Column Width Support / 功能请求:添加自动列宽支持

Description / 描述

ExcelizeCs currently does not support automatic column width adjustment, which makes it difficult to create properly formatted Excel files with readable column widths.

ExcelizeCs目前不支持自动列宽调整功能,这使得创建具有合适列宽的可读Excel文件变得困难。

Expected / 期望

We would like to have support for AdjustToContents functionality, similar to Excel's AutoFit feature that automatically calculates optimal column widths based on content.

我们希望有AdjustToContents功能的支持,类似于Excel的AutoFit功能,能够根据内容自动计算最佳列宽。

In VBA/VBS, this is achieved with:
在VBA/VBS中,这通过以下方式实现:

Sub AutoFitXX()
    Columns("C:D").Select
    Columns("C:D").EntireColumn.AutoFit
End Sub

Use Case / 使用场景

When creating Excel reports with dynamic content, different column types require different optimal widths:

当创建具有动态内容的Excel报告时,不同的列类型需要不同的最佳宽度:

  1. Text columns (like names, descriptions): 15-20 characters / 文本列(如姓名、描述):15-20个字符
  2. Numeric columns (like prices, measurements): 8-12 characters / 数值列(如价格、测量值):8-12个字符
  3. DateTime columns: 18-20 characters / 日期时间列:18-20个字符
  4. Boolean columns: 5-8 characters / 布尔列:5-8个字符

Environment / 环境

  • ExcelizeCs Version: 0.0.4
  • .NET Version: .NET 10.0-windows
  • OS: Windows 11

Impact / 影响

This feature would significantly improve the user experience when generating Excel files programmatically, especially for applications that need to create well-formatted reports.

此功能将显著改善在程序化生成Excel文件时的用户体验,特别是对于需要创建格式良好报告的应用程序。

Additional Notes / 附加说明

Other Excel libraries (like EPPlus, ClosedXML) provide this functionality.

其他Excel库(如EPPlus、ClosedXML)提供了此功能,但效果并不理想,尤其内容包含中文时。


English: Thank you for considering this feature request. Auto column width support would be a valuable addition to ExcelizeCs.

中文:感谢您考虑此功能请求。自动列宽支持将成为ExcelizeCs的一个有价值补充。

Additional context

No response

Validations

  • Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions