Hi
i am generating excel report using Epplus 4.0 Beat 2 Class library, i am assigning Cell Content through Formula,in order to wrap the cell content i set wraptext property as true, the Cell Content gets wrapped but DefaultRowheight is not altered automatically(not fit into the call propely) so manually we need to set this value, where as if i assign Cell Content through Value ( cell.Value = "" ) then Cell Content is fit into the Specific Cell, text also wrapping properly
Code Sample:
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Sample");
var cell = ws.Cells[1, 1];
cell.Value = "This example program to test the functionality of wrap text as formula or value";
//cell.Formula = @"=" + "\"" + "This example program to test the functionality of wrap text as formula or value" + "\"";
cell.Style.WrapText = true;
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
Byte[] bArray = pck.GetAsByteArray();
string fName = Guid.NewGuid().ToString() + ".xlsx";
string fFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), fName);
System.IO.File.WriteAllBytes(fFile, bArray);
System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo(fFile);
System.Diagnostics.Process.Start(process);
Note: please review the attachment also
Comments: I haven't tried this but because it is a formula Epplus does not know what the result will be until you use the Calculate function. Only then could it possibly determine the correct row height.
i am generating excel report using Epplus 4.0 Beat 2 Class library, i am assigning Cell Content through Formula,in order to wrap the cell content i set wraptext property as true, the Cell Content gets wrapped but DefaultRowheight is not altered automatically(not fit into the call propely) so manually we need to set this value, where as if i assign Cell Content through Value ( cell.Value = "" ) then Cell Content is fit into the Specific Cell, text also wrapping properly
Code Sample:
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Sample");
var cell = ws.Cells[1, 1];
cell.Value = "This example program to test the functionality of wrap text as formula or value";
//cell.Formula = @"=" + "\"" + "This example program to test the functionality of wrap text as formula or value" + "\"";
cell.Style.WrapText = true;
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
Byte[] bArray = pck.GetAsByteArray();
string fName = Guid.NewGuid().ToString() + ".xlsx";
string fFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), fName);
System.IO.File.WriteAllBytes(fFile, bArray);
System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo(fFile);
System.Diagnostics.Process.Start(process);
Note: please review the attachment also
Comments: I haven't tried this but because it is a formula Epplus does not know what the result will be until you use the Calculate function. Only then could it possibly determine the correct row height.