You are reading the documentation of sheetsmith 1.0.x.See the latest version (1.0.x)
Setup and validation
Validation at startup and in tests
Section titled “Validation at startup and in tests”sheetsmith: validation: packages: com.example.exportEvery @ExcelSheet type under com.example.export is validated when the application starts; a mistake prevents the startup with the complete list of errors. For tests, see section 11.7.
Sheet names built from data
Section titled “Sheet names built from data”Names that come from data (customer names, categories) must be made valid by the caller, because sheetsmith rejects invalid names instead of changing them.
static String sheetName(String raw, Set<String> used) { String name = raw.replaceAll("[\\\\/?*\\[\\]:]", "_").strip(); while (name.startsWith("'")) name = name.substring(1); while (name.endsWith("'")) name = name.substring(0, name.length() - 1); if (name.isEmpty()) name = "Sheet"; if (name.length() > 31) name = name.substring(0, 31); if (name.equalsIgnoreCase("History")) name = "History_"; String candidate = name; for (int i = 2; !used.add(candidate.toLowerCase(Locale.ROOT)); i++) { String suffix = " (" + i + ")"; candidate = name.substring(0, Math.min(name.length(), 31 - suffix.length())) + suffix; } return candidate;}Plain Java with a dependency injection container
Section titled “Plain Java with a dependency injection container”Sheetsmith sheetsmith = Sheetsmith.builder() .converterFactory(new CellConverterFactory() { @Override public <C extends CellConverter<?>> C create(Class<C> type) { return container.get(type); // CDI, Guice, Dagger, ... } }) .converter(Instant.class, new InstantConverter(ZoneId.of("UTC"))) .defaults(new SheetsmithDefaults("dd/mm/yyyy", "dd/mm/yyyy hh:mm", "", TablePreset.MEDIUM, "#4472C4")) .build();