I'm currently using EPPlus in pretty complicated project and I found some small problems that made my life a little more painful:
1. Autofit works poorly. Column widths are too wide for their contents. Double clicking on column header in Excel is able to decrease width of column even by 30%.
Because of 1, I tried another things, and new problems appeared:
2. ExcelFont is unable to give back System.Drawing.Font object. Why can I create ExcelFont from Font, but I can't get Font from ExcelFont? I could do it manually, but it's pretty ugly workaround and certainly does not give a full information about Font:
```
int fontStyle = 0;
if (cell.Style.Font.Bold == true)
{
fontStyle = 1;
}
else if (cell.Style.Font.Italic == true)
{
fontStyle = 2;
}
else if (cell.Style.Font.UnderLine == true)
{
fontStyle = 4;
}
else if (cell.Style.Font.Strike == true)
{
fontStyle = 8;
}
Font font = new Font(cell.Style.Font.Name, cell.Style.Font.Size, (FontStyle)fontStyle);
double pixelWidth = TextRenderer.MeasureText(cell.Text, font).Width;
```
As you can see I tried to get real width in pixels to make my own autofit. And then:
3. It's impossible to set column width in pixels. You can set width in characters, but most fonts are not proportional, so it's pretty useless if we do not want to hardcode all the sheet. Therefore I was unable to create my own AutoFit. Feel free to use my code if it will provide better working AutoFit.
Another issues:
4. Storing calculated formulas is weird. After I invoke Calculate() I want to have my result stored under Value. So after I use Calculate() i set cell.Formula = null, because it's not formula anymore and I want it to be autofitted. But after I save my workbook - nothing is calculated, all calculated values are null. I had to do something like this to keep the result:
```
public void ReformatFormulasToValues()
{
foreach (var cell in Sheet.Cells.Where(cell => !string.IsNullOrEmpty(cell.Formula)))
{
cell.Calculate();
double value = (double)cell.Value;
cell.Formula = null;
cell.Value = value;
}
}
```
5. Inserting row shifts everything down, but conditional formatting stays in place. Formulas and values behave normally, but conditional formatting stays where it is. It would be nice if it would shift it's place too.
6. Possibility of storing ExcelStyle objects would be SO nice. Right now it's impossible to inherit ExcelStyle to make my own template I had to create functions to do this:
```
public static void SetStyleDefault(ExcelStyle style)
{
style.Font.Name = "Arial";
style.Font.Size = 9;
style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
style.VerticalAlignment = ExcelVerticalAlignment.Center;
style.Border.Top.Style = ExcelBorderStyle.Thin;
style.Border.Bottom.Style = ExcelBorderStyle.Thin;
style.Border.Right.Style = ExcelBorderStyle.Thin;
style.Border.Left.Style = ExcelBorderStyle.Thin;
}
//and then:
SetStyleDefault(Worksheet.Cells.Style);
```
That's probably all for now.