Excel export enum replacer
Skill kjuhwa/skills-hub/skills/backend/excel-export-enum-replacer
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill excel-export-enum-replacerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use DataToBeReplace.builder() to map enum/code values to display labels before passing content to ExcelExportManager.objectToExcelAndDownload()
SKILL.md
4.1 KB, 761 tokens by cl100k_base, as published. Nobody here has run it
Excel Export Enum Replacer
Problem
When exporting domain objects to Excel, enum or code fields (e.g. status codes, boolean flags) must be displayed as human-readable labels. Embedding this mapping inside the DTO or service layer couples presentation concerns to business logic.
Pattern
- Build a
DataToBeReplaceobject that maps raw field values to display strings, keyed by DTO field name. - Pass it alongside the column definitions and data list to
ExcelExportManager.objectToExcelAndDownload(...). - The export manager applies the replacement during cell rendering, keeping DTOs and services unaware of Excel-specific labels.
- The endpoint returns
ResponseEntity<Resource>with aContent-Disposition: attachmentheader and an appropriate MIME type.
Example (sanitized)
// Controller method
@PostMapping("/items/list-filter-excel")
@FunctionId({FunctionIds.ITEM_EXCEL})
public ResponseEntity<Resource> downloadItemsExcel(
@RequestBody ExportParameterDto parameter) throws UnsupportedEncodingException {
// Force full-page query for export
parameter.getFiltersPageableDto().setPageNumber(1);
parameter.getFiltersPageableDto().setPagePerSize(Integer.MAX_VALUE);
Criteria criteria = CriteriaMakeHelper.INSTANCE
.gridFiltersToCriteria(parameter.getFiltersPageableDto().getGridFilters());
Page<ItemDto> items = itemService.findByCriteria(criteria,
parameter.getFiltersPageableDto().toPageable());
// Build enum-to-label replacement map
DataToBeReplace replaceData = DataToBeReplace.builder()
.replaceData("status", Map.of(
"ACTIVE", "Active",
"INACTIVE", "Inactive",
"PENDING", "Pending"
))
.replaceData("permission", Map.of(
Boolean.TRUE, "Allowed",
Boolean.FALSE, "Denied"
))
.build();
byte[] excelBytes = excelExportManager.objectToExcelAndDownload(
parameter.getGridColumnDataDto().getColumnDefs(), // List<ColumnDef>
items.getContent(), // List<?>
replaceData,
0, // sheet index
"yyyy-MM-dd HH:mm:ss" // date format
);
String encodedFilename = UriUtils.encode("items.xlsx", StandardCharsets.UTF_8);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename*=UTF-8''" + encodedFilename)
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(new ByteArrayResource(excelBytes));
}
When to Use
- Any
POSTendpoint that downloads filtered data as an Excel file. - DTO fields contain codes, enums, or boolean flags that must appear as labels in the sheet.
- The column definition (which columns appear and their order) is supplied by the UI at request time.
Pitfalls
- Missing replacement key: if a field value has no matching entry in the replacement map, the raw value is written to the cell. Add a default/fallback entry or document the expected value set.
- Large exports: setting
pagePerSize = Integer.MAX_VALUEloads the entire result set into memory. Add a row-count guard or stream-based export for collections exceeding a few thousand rows. - Filename encoding: always
UriUtils.encodethe filename forContent-Dispositionto handle non-ASCII characters correctly across browsers. - Date format: the
dateFormatparameter applies to all date fields in the sheet. Ensure the format string matches the locale expected by the consumer.
Related
grid-filter-to-criteria-converter— the sameFiltersPageableDtois reused as the filter input for export endpoints.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.
Gives 0 of the 12 instructions most pdf office docs skills give in 761 tokens
Counted across 636 of the 690 authors here whose files we hold, read 2026-08-07
- extract text using pdfplumberin 89 of 636, across 23 files
- create PDFs using reportlabin 83 of 636, across 16 files
- read forms.md to fill out pdf formsin 80 of 636, across 13 files
- OCR scanned PDFs using pytesseractin 77 of 636, across 10 files
- merge or split PDFs using qpdfin 70 of 636, across 3 files
- use excel formulas instead of hardcoded calculated valuesin 68 of 636, across 13 files
- unpack edit xml and repack existing documentsin 63 of 636, across 8 files
- document sources for hardcoded valuesin 61 of 636, across 9 files
- write minimal python code without unnecessary commentsin 59 of 636, across 7 files
- run the recalculation script after adding or modifying formulasin 59 of 636, across 7 files
- fix all identified formula errors and recalculatein 58 of 636, across 6 files
- format years as text stringsin 57 of 636, across 5 files
Said here and by no other author read
- build a DataToBeReplace object mapping raw values to labels
- pass the replacement map to ExcelExportManager.objectToExcelAndDownload
- return ResponseEntity<Resource> with a Content-Disposition attachment header
- set a MIME type on the response
- force a full-page query for exports
- UriUtils.encode the filename for the Content-Disposition header
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.