BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
private GridProperties ConvertGridObject(string gridProperty)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
IEnumerable div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable));
GridProperties gridProp = new GridProperties();
foreach (KeyValuePair<string, object> ds in div)
{
var property = gridProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
if (property != null)
{
Type type = property.PropertyType;
string serialize = serializer.Serialize(ds.Value);
object value = serializer.Deserialize(serialize, type);
property.SetValue(gridProp, value, null);
}
}
AutoFormat auto = new AutoFormat();
auto.FontFamily = "Arial";
auto.ContentBorderColor = Color.Brown;
auto.ContentFontSize = 10;
auto.GCaptionBorderColor = Color.Cornsilk;
auto.GContentFontColor = Color.DarkBlue;
auto.HeaderFontSize = 12;
auto.HeaderBorderColor = Color.Red;
auto.ContentBgColor = Color.Wheat;
auto.GHeaderBgColor = Color.Crimson;
auto.AltRowBgColor = Color.LightCyan;
gridProp.AutoFormat = auto;
return gridProp;
}
public void ExportToExcel(string GridModel)
{
ExcelExport exp = new ExcelExport();
var DataSource = new NorthwindDataContext().OrdersViews.Take(30).ToList();
GridProperties obj = ConvertGridObject(GridModel);
exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "none");
}
|