XlsxRenderer.java

1
package pro.verron.officestamper.utils.sml;
2
3
import org.docx4j.openpackaging.packages.SpreadsheetMLPackage;
4
import org.xlsx4j.org.apache.poi.ss.usermodel.DataFormatter;
5
import org.xlsx4j.sml.Cell;
6
7
import static java.util.stream.Collectors.joining;
8
9
/// Utility class for rendering SpreadsheetML (Excel) files to string representations. This class provides methods to
10
/// convert Excel spreadsheets into human-readable formats.
11
public class XlsxRenderer {
12
13
    private XlsxRenderer() {
14
        throw new IllegalStateException("Utility class");
15
    }
16
17
    /// Converts the content of a SpreadsheetMLPackage into a string by extracting and formatting cell data from the
18
    /// Excel file.
19
    ///
20
    /// @param spreadsheet the Excel file represented as a [SpreadsheetMLPackage]
21
    ///
22
    /// @return a string representation of the cell content within the Excel spreadsheet
23
    public static String xlsxToString(SpreadsheetMLPackage spreadsheet) {
24
        var formatter = new DataFormatter();
25 1 1. xlsxToString : replaced return value with "" for pro/verron/officestamper/utils/sml/XlsxRenderer::xlsxToString → NO_COVERAGE
        return new XlsxIterator(spreadsheet).filter(Cell.class::isInstance)
26
                                            .map(Cell.class::cast)
27 1 1. lambda$xlsxToString$0 : replaced return value with "" for pro/verron/officestamper/utils/sml/XlsxRenderer::lambda$xlsxToString$0 → NO_COVERAGE
                                            .map(cell -> cell.getR() + ": " + formatter.formatCellValue(cell))
28
                                            .collect(joining("\n"));
29
    }
30
}

Mutations

25

1.1
Location : xlsxToString
Killed by : none
replaced return value with "" for pro/verron/officestamper/utils/sml/XlsxRenderer::xlsxToString → NO_COVERAGE

27

1.1
Location : lambda$xlsxToString$0
Killed by : none
replaced return value with "" for pro/verron/officestamper/utils/sml/XlsxRenderer::lambda$xlsxToString$0 → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.0