Bug / Feature Request: Support for Column Width (like [ExcelColumnWidth] or programmatic control)
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.
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.