Reputation: 1943
My DataTable has the information from a Data base table and I'm able to dump the DataTable value into Excel using EPPlus lib.
Now, I want to format the column name in the Excel by setting range(lets say A1 to Z1) of cells to certain orientation (45 degree) and give some color to it
I'm using VS2010 for my development.
How can I do this?
Upvotes: 1
Views: 5704
Reputation: 460340
Use the TextRotation
property:
worksheet.Cells["A1:Z1"].Style.TextRotation = 45;
How to give color to it?
var range = worksheet.Cells["A1:Z1"];
var fill = range.Style.Fill;
fill.PatternType = ExcelFillStyle.LightGray;
fill.PatternColor.SetColor(Color.Beige);
fill.BackgroundColor.SetColor(Color.White);
How can I do: Format-> "AutoFit Column width" using code?
worksheet.Cells["A1:Z1"].AutoFitColumns();
Upvotes: 4