Skip to content

Column header customization

firegloves edited this page Jul 20, 2022 · 1 revision

Column header customization

If you need to change the column header display name without changing the SQL statement, you can configure the display name by setting the display name configuration.

The display name is only used to populate the column header cell value.

In this following example we want to configure an Excel sheet from this query

SELECT username, fname, lname, comment FROM person 

And expect this result

username First name Last name
demo Demo MEMPOI Comment in column without title

In this example :

  • The selected column 'username' doesn't need a custom configuration
  • The selected column 'fname' needs a custom configuration to display "First name"
  • The selected column 'lname' needs a custom configuration to display "Last name"
  • The selected column 'comment' needs a custom configuration to display an empty text
MempoiColumnConfig firstNameConfig = MempoiColumnConfigBuilder.aMempoiColumnConfig()
        .withColumnName("fname")
        .withColumnDisplayName("First name")
        .build();

MempoiColumnConfig lastNameConfig = MempoiColumnConfigBuilder.aMempoiColumnConfig()
        .withColumnName("lname")
        .withColumnDisplayName("Last name")
        .build();

MempoiColumnConfig commentWithoutHeaderTextConfig = MempoiColumnConfigBuilder.aMempoiColumnConfig()
        .withColumnName("comment")
        .withColumnDisplayName("")
        .build();

MempoiSheet mempoiSheet = MempoiSheetBuilder.aMempoiSheet()
        .withPrepStmt("SELECT username, fname, lname, comment FROM person ")
        .addMempoiColumnConfig(firstNameConfig)
        .addMempoiColumnConfig(lastNameConfig)
        .build();

Thanks to bdzzaid