**Resolved** How to conditionalize the Background Color of DataTable Column in NativeExcel
I am using Conditional Class elements in my web and PDF output to change the background color of DataTable Columns. However, the Conditional Class elements don't work in NativeExcel.
I tried to use an =IIF in the Background Color attribute, but that was ignored also.
=IIF('@Request.inpInclEncDetail~'=1,'#E3FFB3','#FFFF9D') ---Didn't apply any background color
Any ideas on how to conditionalize the Background Color attribute of DataTable Columns in NativeExcel?
-
I ended up going low-tech on this and simply copying the columns and applying the Condition to the columns themselves so that Detail has no background color attribute, and Summary has the background color.
0 -
You could have created the condition within the datalayer and referenced the color via that @Data Token
<Report ID="LogiForum.ExcelBGColor">
<Body>
<Button Caption="Export" ID="btnExport">
<Action Type="NativeExcel" ID="actExport">
<Target Type="NativeExcel" ExportDataTableID="dt1" Report="CurrentReport" />
</Action>
</Button>
<DataTable ID="dt1">
<DataLayer Type="Static">
<StaticDataRow Column1="True" Column2="Column2 Data" Column3="Column3 Data" />
<StaticDataRow Column1="False" Column2="Column2 Data" Column3="Column3 Data" />
<StaticDataRow Column1="False" Column2="Column2 Data" Column3="Column3 Data" />
<StaticDataRow Column1="True" Column2="Column2 Data" Column3="Column3 Data" />
<CalculatedColumn Formula="IIF('@Data.Column1~'=='True','#E3FFB3','#FFFF9D')" ID="ccColor" />
</DataLayer>
<DataTableColumn ID="colColumn1" Header="Column1" BackgroundColor="@Data.ccColor~">
<Label ID="lblColumn1" Caption="@Data.Column1~" />
<DataColumnSort DataColumn="Column1" />
<ExcelColumnFormat ExcelColumnWidth="Auto" ExcelAutoFitRow="True" />
</DataTableColumn>
<DataTableColumn ID="colColumn2" Header="Column2" BackgroundColor="@Data.ccColor~">
<Label ID="lblColumn2" Caption="@Data.Column2~" />
<DataColumnSort DataColumn="Column2" />
<ExcelColumnFormat ExcelColumnWidth="Auto" ExcelAutoFitRow="True" />
</DataTableColumn>
<DataTableColumn ID="colColumn3" Header="Column3" BackgroundColor="@Data.ccColor~">
<Label ID="lblColumn3" Caption="@Data.Column3~" />
<DataColumnSort DataColumn="Column3" />
<ExcelColumnFormat ExcelColumnWidth="Auto" ExcelAutoFitRow="True" />
</DataTableColumn>
</DataTable>
</Body>
<ideTestParams />
</Report>0
Please sign in to leave a comment.
Comments
2 comments