Ok, but I've a problem.
I set conditional formatting in function of differents columns, some of this are hidden.
So, in ServerExcelRowInfo event, I haven't this values for colour formatting.
I like pass the css style of each cell for not repeat the function of conditional formatting.
If, it isn't posible.... how can I set the colours in excel when it depends of hidden columns?
I've modified the example. I hide Freight column, and when it's value is superior than 40, I set red colour in ship city. How can I set this colours in excel export?
|
public void ExportToExcel(string GridModel)
{
ExcelExport exp = new ExcelExport();
var DataSource = new NorthwindDataContext().OrdersViews.Take(100).ToList();
GridProperties obj = ConvertGridObject(GridModel);
obj.ServerExcelQueryCellInfo = queryCellInfo;
exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");
}
public void queryCellInfo(object currentCell)
{
IRange range = (IRange)currentCell;
if (range.Column == 3)
{// here 3 is the index of Freight columns
if (int.Parse(range.Value.ToString()) > 40)
range.CellStyle.Color = Color.LightGreen;
}
} |
Sorry, it don't work for me (and for my english _:)
I try explain my problem better:
In my grid, Freight column is hidden, and I set the colour of ShipCity in function of Freight column. I need this colour in excel exportation.
In your last example, you change fright column colour, but I dont wan't show this column, and I need set the colour of Ship City.
In my last attach, I put an example
Thanks
Thanls
|
IEnumerable<OrdersView> currentData = null;
public void ExportToExcel(string GridModel)
{
ExcelExport exp = new ExcelExport();
var DataSource = new NorthwindDataContext().OrdersViews.Take(100).ToList();
currentData = DataSource;
GridProperties obj = ConvertGridObject(GridModel);
obj.ServerExcelQueryCellInfo = queryCellInfo;
exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");
}
public void queryCellInfo(object currentCell)
{
IRange range = (IRange)currentCell;
if (range.Column == 4) //Here it checks for the ShipCity Column where 4 is the index of shipCity column {
foreach (OrdersView currentval in currentData)
{
if (currentval.Freight > 40) //Here it checks the value of Hidden column "Freight(Hidden column)" {
range.CellStyle.Color = Color.LightGreen;
...
}
}
}
}
|