odftoolkit icon indicating copy to clipboard operation
odftoolkit copied to clipboard

Help Request: Formating cells in an ODF-Table

Open Boarschti42 opened this issue 2 years ago • 1 comments

Hi,

i currently face the problem of exporting data from a database into an odf-table. Inserting data seems to work fine, but formating goes cracy since i dont want to use simple-odf.

Here is the problem: After writing a cell and formating it bold or set a background color, the next cell i write also uses this style, not the default plain setting. (as i read a little, this has something to do with automatic styles?)

how do i get this resolved? Some samples down below...

// Calls to formating like this
protected void fillCompanyInformation(int row) {

        // Fill the first cells with company data
        setCellTextInItalic(row++, 0, prefs.get(Constants.PREFERENCES_YOURCOMPANY_NAME, ""));
        setCellTextInItalic(row++, 0, prefs.get(Constants.PREFERENCES_YOURCOMPANY_OWNER, ""));
        setCellTextInItalic(row++, 0, prefs.get(Constants.PREFERENCES_YOURCOMPANY_STREET, ""));
        setCellTextInItalic(row++, 0, prefs.get(Constants.PREFERENCES_YOURCOMPANY_ZIP, "") + " " + prefs.get(Constants.PREFERENCES_YOURCOMPANY_CITY, ""));
    }


// Formating works like this
public static void setBold(final OdfTable spreadsheet, final int row, final int column) {

        // Get the cell by the row and the column
        OdfTableCell cell = getCell(spreadsheet, row, column);
        cell.getOdfElement().setProperty(OdfTextProperties.FontWeight, "bold");
    }


Thank you for your help in advance.

Boarschti42 avatar Jan 03 '24 18:01 Boarschti42

I am sorry, I have too little time to dive into it and fix it. Unless someone else fixes this specific problem. You might preformat the spreadsheet you are using. Otherwise, if the functionality is not doing what is expected. Please assist and try to provide a patch. Thanks in advance! Svante

svanteschubert avatar Jan 19 '24 20:01 svanteschubert