MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

Bug / Feature Request: Support for Column Width (like [ExcelColumnWidth] or programmatic control)

Open far310 opened this issue 9 months ago • 1 comments

Describe the problem

MiniExcel currently does not support setting Excel column widths either via: • Attribute-based annotations (e.g., [ExcelColumnWidth(20)]) • Or programmatically (e.g., sheet.Column(1).Width = 20)

This makes it difficult to generate readable Excel files when exporting via MiniExcel.SaveAs(...), especially for long strings.

Expected behavior

Ideally, MiniExcel should support one of the following: • Declarative support for column width via attribute • A fluent API to set column widths when exporting • Or official recommendation on handling this (besides using templates)

Workaround

Currently, the only workaround is using an Excel template where column widths are preset. This works, but doesn’t scale well for dynamic exports.

Additional context • Version: MiniExcel v1.41.1 (replace with your version) • .NET Version: .NET 6 / .NET 7 • Exported via: MiniExcel.SaveAs(filePath, data);

Thanks for this awesome lightweight Excel library 🙏 Looking forward to seeing if this can be added or recommended officially.

far310 avatar May 16 '25 01:05 far310

There is already an ExcelColumnWidthAttribute that does exactly what you're asking for and appears to be working as intended. Please provide further details if that does not satisfy your request.

michelebastione avatar May 16 '25 07:05 michelebastione