EN · DE · RU · FR · ES

#824: AddressExport.kt

projectforge-business/src/main/kotlin/org/projectforge/business/address/AddressExport.kt @Service("addressExport") — Excel export service, projectforge-business/src/main/kotlin/org/projectforge/business/address/AddressExport.kt 216 lines · 157 code · 35 comments · 24 blank
Spring service that exports address data into Excel workbooks (.xlsx). Handles column registration, access-controlled filtering, and multi-section merged header rows for mailing, business, postal, and private address blocks.

Architecture

Class Hierarchy

AddressExport is an open class annotated with @Service("addressExport"), designed for extension by plugins. The marketing plugin's AddressCampaignValueExport extends it, overriding registerAdditionalCols(), configureSheet(), and handleAddressCampaign() to add campaign-specific fields.

Column Registration (registerCols)

Registers ~40 columns in order:

  1. Identity: name, firstName, form, title, contactStatus
  2. Organization: organization, division, positionText, communicationLanguage
  3. Plugin hook: registerAdditionalCols() — extensible point for campaign values
  4. Contact: email, website
  5. Mailing address: addressText, addressText2, zipCode, city, country, state
  6. Business address: full block (auto-registered via registerAddress(sheet, ""))
  7. Postal address: full block (registerAddress(sheet, "postal"))
  8. Phones: businessPhone, fax, mobilePhone
  9. Private: full address block, privateEmail, privatePhone, privateMobilePhone
  10. Metadata: birthday, lastUpdate, comment, fingerprint, publicKey, id

Size constants from ExcelUtils.Size control column widths: STANDARD (default), EMAIL, ZIPCODE, PHONENUMBER, EXTRA_LONG.

Export Flow (export())

  1. Access control: Members of FINANCE_GROUP or MARKETING_GROUP receive all addresses; other users only get their personal favorites (matched via personalAddressMap).
  2. Workbook creation: Uses Merlin's ExcelWorkbook with try-with-resources via .use { }.
  3. Sheet setup: Title row, header row with bold styling, freeze pane at (2,2), and auto-filter on the header row.
  4. Merged header regions: Four merged cell regions in row 0 group mailing, business, postal, and private address columns under bold section headers.
  5. Hook call: configureSheet(sheet, *params) for subclass customization.
  6. Row population: Each address becomes an Excel row. Calls ExcelUtils.autoFill() for standard property mapping, manually fills mailing address cells and communication language, then invokes handleAddressCampaign() for campaign data.

Extension Points

Git History

868d6abb7 2025 -> 2026
83cbccb11 ExcelUtils AddressExport: stream.use (streams weren't closed before?)
78a38ca8f ExcelUtils.createFont and used by all font creating excel routines.
63081666f Source file headers: 2024-> 2025.
4c04cfd65 MAJOR-CHANGE! Migration of integer id's to Long id's
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
dce7927f4 deprecated Kotlin function decapitalize() replaced
5f7ef41b8 Copyright 2021 -> 2022
e1538819c Merlin: using now Autoclosure of ExcelWorkbook
91554ea83 New Merlin version.
EN · DE · RU · FR · ES

#824: AddressExport.kt

@Service("addressExport") — Excel export service, projectforge-business/src/main/kotlin/org/projectforge/business/address/AddressExport.kt
Spring service that exports address data into Excel workbooks (.xlsx). Handles column registration, access-controlled filtering, and multi-section merged header rows for mailing, business, postal, and private address blocks.

Architecture

Class Hierarchy

AddressExport is an open class annotated with @Service("addressExport"), designed for extension by plugins. The marketing plugin's AddressCampaignValueExport extends it, overriding registerAdditionalCols(), configureSheet(), and handleAddressCampaign() to add campaign-specific fields.

Column Registration (registerCols)

Registers ~40 columns in order:

  1. Identity: name, firstName, form, title, contactStatus
  2. Organization: organization, division, positionText, communicationLanguage
  3. Plugin hook: registerAdditionalCols() — extensible point for campaign values
  4. Contact: email, website
  5. Mailing address: addressText, addressText2, zipCode, city, country, state
  6. Business address: full block (auto-registered via registerAddress(sheet, ""))
  7. Postal address: full block (registerAddress(sheet, "postal"))
  8. Phones: businessPhone, fax, mobilePhone
  9. Private: full address block, privateEmail, privatePhone, privateMobilePhone
  10. Metadata: birthday, lastUpdate, comment, fingerprint, publicKey, id

Size constants from ExcelUtils.Size control column widths: STANDARD (default), EMAIL, ZIPCODE, PHONENUMBER, EXTRA_LONG.

Export Flow (export())

  1. Access control: Members of FINANCE_GROUP or MARKETING_GROUP receive all addresses; other users only get their personal favorites (matched via personalAddressMap).
  2. Workbook creation: Uses Merlin's ExcelWorkbook with try-with-resources via .use { }.
  3. Sheet setup: Title row, header row with bold styling, freeze pane at (2,2), and auto-filter on the header row.
  4. Merged header regions: Four merged cell regions in row 0 group mailing, business, postal, and private address columns under bold section headers.
  5. Hook call: configureSheet(sheet, *params) for subclass customization.
  6. Row population: Each address becomes an Excel row. Calls ExcelUtils.autoFill() for standard property mapping, manually fills mailing address cells and communication language, then invokes handleAddressCampaign() for campaign data.

Extension Points

Git History

868d6abb7 2025 -> 2026
83cbccb11 ExcelUtils AddressExport: stream.use (streams weren't closed before?)
78a38ca8f ExcelUtils.createFont and used by all font creating excel routines.
63081666f Source file headers: 2024-> 2025.
4c04cfd65 MAJOR-CHANGE! Migration of integer id's to Long id's
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
dce7927f4 deprecated Kotlin function decapitalize() replaced
5f7ef41b8 Copyright 2021 -> 2022
e1538819c Merlin: using now Autoclosure of ExcelWorkbook
91554ea83 New Merlin version.