Uploaded image for project: 'ODF Toolkit'
  1. ODF Toolkit
  2. ODFTOOLKIT-217

setHorizontalAlignment and setVerticalAlignment do not work for new created table.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • odfdom-1.0
    • None
    • performance
    • None
    • Operating System: Windows
      Platform: PC
    • 248

    Description

      I just installed simple0.2_binary and odfsom_0.9snapshot.

      1. I cannot find cell.setColumnSpannedNumber or cell.setRowSpannedNumber
      2. cell.setHorizontalAlignmentand cell.setVerticalAlignment do not seem to work.

      Here is my code:

      package odfDom;

      import org.odftoolkit.simple.SpreadsheetDocument;
      import org.odftoolkit.simple.table.Cell;
      import org.odftoolkit.simple.table.Table;

      public class TestSimple {

      public static void setCell(Table table, int cellCol, int cellRow,
      int colSpan, int rowSpan, String hAlign, String vAlign,
      String dispText, String styleName,
      Double value, Boolean percentage){
      if (table!=null){
      Cell cell;
      cell = table.getCellByPosition(cellCol, cellRow);
      // cell.setColumnSpannedNumber(colSpan);
      // cell.setRowSpannedNumber(rowSpan);
      cell.setHorizontalAlignment(hAlign);
      cell.setVerticalAlignment(vAlign);
      if (dispText!=null)

      { cell.setValueType("string"); cell.setDisplayText(dispText, styleName); // cell.setStringValue(dispText); }

      else

      { if (percentage) cell.setPercentageValue(value); else cell.setDoubleValue(value); }

      }
      }
      /**

      • @param args
        */
        public static void main(String[] args) {
        String h1StyleName = null;
        SpreadsheetDocument odsDoc=null;
        Table table=null;
        String tName = "IRR";
        String fSpec = "c:/Users/msimeon/Documents/table_export_test.ods";
        try { odsDoc = SpreadsheetDocument.loadDocument(fSpec); }

        catch (Exception e)

        { System.out.println("Unable to connect to "+fSpec); }

        if (odsDoc!=null)

        Unknown macro: { table = odsDoc.getTableByName(tName); if (table!=null) table.remove(); try { table = Table.newTable(odsDoc); table.setTableName(tName); } catch (Exception e) { System.out.println("Could not create table "+tName); } }

        setCell(table, 0, 0, 3, 0, "center", "center", "blurrrrp", h1StyleName, null, null);
        setCell(table, 0, 1, 3, 0, "center", "center", "bla bla blop blurrrrp", "Heading", null, null);
        try

        { odsDoc.save(fSpec); }

        catch (Exception e)

        { System.out.println("Unable to save to " + fSpec +"\nCheck that it is not open by an other application"); }


        if (odsDoc!=null) odsDoc.close();
        }
        }

      Attachments

        Activity

          People

            Unassigned Unassigned
            msimeon@odftoolkit.org msimeon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: