BorderStyles borderStyle =
null;
for (int
i = 1; i <= 4; i++)
{
borderStyle =
new BorderStyles();
borderStyle.PositionType = (PositionType)i;
borderStyle.Color =
System.Drawing.Color.Black;
borderStyle.LineStyle =
LineStyle.Continuous;
borderStyle.Weight = 1.0;
borders.Add(borderStyle);
}
// styles have to set
for export excel
foreach (StyleElement
style in e.Styles){
//For Header
style - background color
if (style.Id
== "headerStyle"){
style.InteriorStyle.Pattern =
InteriorPatternType.Solid;
style.InteriorStyle.Color =
System.Drawing.Color.Gray;
}
//For alternate
row style - background color
if (style.Id
== "alternatingItemStyle" || style.Id ==
"alternatingPriceItemStyle" || style.Id ==
"alternatingPercentItemStyle" || style.Id ==
"alternatingDateItemStyle"){
style.InteriorStyle.Pattern =
InteriorPatternType.Solid;
style.InteriorStyle.Color =
System.Drawing.Color.LightGray;
}
if
(
style.Id.Contains("itemStyle")
|| style.Id == "priceItemStyle" || style.Id
== "percentItemStyle" || style.Id ==
"dateItemStyle") {
style.InteriorStyle.Pattern =
InteriorPatternType.Solid;
style.InteriorStyle.Color =
System.Drawing.Color.White;
}
// for each cell border styles
foreach
(BorderStyles border in borders)
{
style.Borders.Add(border);
}
// Each cell text wrapping
style.AlignmentElement.Attributes.Add("ss:WrapText",
"1");
}
}