Skip to main content

**Resolved** How to conditionalize the Background Color of DataTable Column in NativeExcel

Comments

2 comments

  • Johnny Stevens

    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
  • VISUI

    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.