-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Source generator - Number format #43
Comments
Thanks for the feedback! |
That's a great idea ! Where do I sign ? thank you :) |
Oh, another thing I would consider on top of the styling of the columns is to be able to set the size of the columns automatically. What I am doing right now for this scope is do this thing manually : public class Person
{
[ColumnHeaderInfo(17)]
public int Age { get; set; }
[ColumnHeaderInfo(35)]
public DateTime ModifiedAt { get; set; }
}
[WorksheetRow(typeof(Person))]
public partial class PersonRowContext : WorksheetRowContext; The attribute [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class ColumnHeaderInfoAttribute(double size) : Attribute
{
public double Size { get; init; } = size;
} and then later in the code, to use it protected static WorksheetOptions GetWorksheetOptions<T>()
{
var props = typeof(T).GetProperties();
var options = new WorksheetOptions();
for (var i = 0; i < props.Length; i++)
{
var attr = props[i].GetCustomAttributes(typeof(ColumnHeaderInfoAttribute), false);
if (attr is not null && attr.Length > 0)
{
options.Column(i + 1).Width = ((ColumnHeaderInfoAttribute)attr[0]).Size;
}
}
return options;
} |
I've created #44 to track support for named styles. Setting column widths automatically, i.e. having the widths automatically adjusted to fit to the cell contents, is not really possible without having a huge performance hit as far as I can see. See #12 for a more thorough explanation. |
The |
First of all, thank you for your super fast library :)
Could you add an option to specify the style of the column when using the source generator ?
This will be useful to customize datetime and number formatting on a column basis. Something like a
ColumnFormattingAttribute
class which takes aStandardNumberFormat
for simplicity.Thank you.
The text was updated successfully, but these errors were encountered: