Ok great that did work! So I have tried several variation to try and set the columns that have headers to that type but when I do the example below I find it is only setting the top row and not the others below it. Basically, I have column names at the top
of the sheet and then they enter data below it. I only need the columns that have the text header to have this formatting. What is the best way you would recommend me do this? Here is the code I have that is only doing the top row.
public static void CreateFile()
var assembly = Assembly.GetAssembly(typeof(tblPreFERClientMap));
var types = assembly.GetTypes().Where(t => t.Name.StartsWith("tbl"));
using(var book = new XLWorkbook())
foreach (var type in types)
var name = type.Name.Length > 31 ? type.Name.Substring(0, 31) : type.Name;
using(var sheet = book.Worksheets.Add(name))
var props = type.GetProperties();
for (var i = 0; i < props.Count(); i++)
var x = i;
var cell = sheet.Cell(1, x + 1);
sheet.Column(1).Cells().Style.NumberFormat.Format = "@";
What I thought would have works is below but it just errors out due to memory. Just FYI, this is creating about 50 sheets.
sheet.Columns(1,sheet.ColumnsUsed().Count()).Cells().Style.NumberFormat.Format = "@";