# Report Format Types - Visual Excel

Canonical page: https://www.adaptabletools.com/docs/handbook-exporting-reports-format-type-visual-excel

Reports in AdapTable are not WYSIWYG (What You See is What You Get).

It is the Grid's underlying raw data, rather than display values, styles or grouping, which is exported.

- Developers do, however, have some control over the [Formatting of other Reports](https://www.adaptabletools.com/docs/handbook-exporting-formatting-reports/index.md)
- They can set how to format dates and choose between exporting cell *raw* (the default) or *display* values

The one exception to this "data-only" rule is the `VisualExcel` Report Format Type.

This exports Columns that contain styles so that they appear in Excel the same way as they do in AdapTable.

The `VisualExcel` Report Format Type includes the following elements:

- defined in **AG Grid**:
  - Value Getters
  - Cell Formatters
- defined in **AdapTable**:
  - [Formatted Columns](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) (which contain [AdapTable Styles](https://www.adaptabletools.com/docs/handbook-column-formatting-adaptable-style/index.md))
  - [Row Groups](https://www.adaptabletools.com/docs/handbook-grouping-rows/index.md)

## Exporting Styles

AdapTable will export styles that have been created in AG Grid or AdapTable into Excel format.

This means that if there are any [AG Grid Excel Styles](https://www.ag-grid.com/javascript-data-grid/excel-export-styles/) defined, Adaptable will try to render them.

Any [AdapTable Styles](https://www.adaptabletools.com/docs/handbook-column-formatting-adaptable-style/index.md) defined with the Format Column will **always take precedence** over AG Grid styles

- We recommend using AdapTable's versatile [Format Columns](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) instead of AG Grid's standard value formatters
- It offers ingrained styling support for Excel and ensures the Format Column definition is the *sole source of truth*

**Example: VisualExcel Report Format Type**

Using the VisualExcel Report Format Type for a WYSIWYG export

- In this example AdapTable has been set to use the `VisualExcel` Report Format Type (and `Current Layout` report)
- We added a number of features which all get included in the Export:
  - [Column Formats that use AdapTable Styles](https://www.adaptabletools.com/docs/handbook-column-formatting-adaptable-style/index.md)
  - [Gradient Styled Column](https://www.adaptabletools.com/docs/handbook-styled-column-gradient/index.md)
  - [Grand Total Row](https://www.adaptabletools.com/docs/handbook-aggregation-grand-total-row/index.md)

- Switch to `Grouped Layout` - note how the [Column Formats](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) are preserved

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'VisualExcel Report Format',
  initialState: {
    Dashboard: {
      Tabs: [
        {
          Name: 'Demo',
          Toolbars: ['Export', 'Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Export', 'Layout'],
        },
      ],
    },
    Export: {
      CurrentReport: 'Current Layout',
      CurrentFormat: 'VisualExcel',
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-github_stars',
          Rule: '[github_stars] > 10000',
          Scope: {
            ColumnIds: ['github_stars'],
          },
          Style: {
            BackColor: 'var(--ab-color-palette-21)',
          },
        },
        {
          Name: 'formatColumn-name',
          Scope: {
            ColumnIds: ['name'],
          },
          Style: {
            BackColor: 'var(--ab-color-palette-17)',
            ForeColor: 'var(--ab-color-palette-14)',
          },
        },
        {
          Name: 'formatColumn-license',
          Scope: {
            ColumnIds: ['license'],
          },
          Style: {
            FontStyle: 'Italic',
          },
        },
      ],
    },
    StyledColumn: {
      StyledColumns: [
        {
          Name: 'github_watchers Gradient',
          ColumnId: 'github_watchers',
          GradientStyle: {
            RangeValueType: 'Number',
            CellRanges: [{Min: 'Col-Min', Max: 'Col-Max', Color: '#a52a2a'}],
          },
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'github_watchers',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'week_issue_change',
          ],
          TableAggregationColumns: [
            {
              ColumnId: 'github_watchers',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'github_stars',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'week_issue_change',
              AggFunc: 'min',
            },
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
          GrandTotalRow: 'top',
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'github_watchers',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'week_issue_change',
          ],
          RowGroupedColumns: ['language'],
          TableAggregationColumns: [
            {
              ColumnId: 'github_watchers',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'github_stars',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'week_issue_change',
              AggFunc: 'min',
            },
          ],
          Name: 'Grouped Layout',
          AutoSizeColumns: true,
          GrandTotalRow: 'bottom',
        },
      ],
    },
  },
};
```

## Exporting Formats

The `VisualExcel` Report Format **always** exports any Display Formats currently rendered in AdapTable.

- The `exportDataFormat` property in [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md) evaluates whether to export raw value or display value
- But (only) the `VisualExcel` Report Format Type ignores this since it **only** exports display values

## Exporting Excel Dates

When using the `VisualExcel` Report Format Type, Date columns can be explicitly exported as Excel Date cells.

This means that Excel will see the Column as a Date and treat it as such when providing Filters and other functionality

To achieve this, the following are required:
 
- the Column has a [Cell Data Type](https://www.adaptabletools.com/docs/dev-guide-aggrid-cell-data-types/index.md) of `date`
- a custom Date format is provided.  This can be either:
  - set using the (global) `exportDateFormat` property in [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md); or 
  - via the `exportDataFormat` property in [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md) which is set to `formattedValue` for Dates
  

This option also requires the Column to have an active [Format Column](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) using [`DateFormatterOptions`](https://www.adaptabletools.com/docs/reference/dateformatteroptions.md)

## Exporting Styled Columns

The `VisualExcel` Report Format Type will only export the [Gradient Style](https://www.adaptabletools.com/docs/handbook-styled-column-gradient/index.md) Styled Column.

This is because it simply contains a back colour which is easy to send to Excel.

The `VisualExcel` Report Format Type will **not** export [Percent Bar](https://www.adaptabletools.com/docs/handbook-styled-column-percent-bar/index.md) or [Badge](https://www.adaptabletools.com/docs/handbook-styled-column-badge/index.md) or [Sparkline Column](https://www.adaptabletools.com/docs/handbook-styled-column-sparkline/index.md) Styled Columns
