Skip to content

Inconsistent Styling of Footer Cell in Certain Cases #105

@brunoagretti

Description

@brunoagretti

When using a custom NumberColumnFormatProvider, an inconsistency in styling occurs for footer cells when their styles match those of the rows. In those cases, the footer cell's style is erroneously set as if it were a data cell.

This issue is reproducible with the following simple grid and exporter example:

Grid<String> myGrid = new Grid<>();                                                                                    
Column<String> itemColumn = myGrid.addColumn( str -> str).setHeader("Item");                                           
Column<String> upperColumn = myGrid.addColumn( str -> String.valueOf(Math.random() * 100)).setHeader("Number");        
itemColumn.setFooter("Unformatted footer");                                                                            
upperColumn.setFooter("50.00");                                                                                        
                                                                                                                       
myGrid.setItems(new ArrayList<>(List.of("Item 1", "Item 2", "Item 3")));                                               
add(myGrid);                                                                                                           
                                                                                                                       
GridExporter<String> exporter = GridExporter.createFor(myGrid);                                                        
exporter.setNumberColumnFormatProvider(upperColumn, new DecimalFormat("#,##0.000"), item -> {                          
	if (item == null)                                                                                                  
	{                                                                                                                  
		return "$ #,##0.000";                                                                                            
	}                                                                                                                  
	return "#,##0.000";                                                                                                
});                                                                                                                    

When executing this example and exporting the grid to xlsx format, the output matches the expected styling:
image

However, after changing the format of the column for null items (the format for the footer) to match the formats of other items, we encounter an unexpected change in the footer's background color. Instead of using the footer's expected background color, it adopts the background color of the data cells:

exporter.setNumberColumnFormatProvider(upperColumn, new DecimalFormat("#,##0.000"), item -> {
    if (item == null) {
        // Changed to match the other rows' formats
        return "#,##0.000";
    }
    return "#,##0.000";
});

This inconsistency in footer cell styling is visually shown below:
image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions