Examples of OdfSpreadsheetDocument


Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

    }
  }

  @Test
  public void testSetDefaultCellStyle() {
    OdfSpreadsheetDocument outputDocument;
    OdfContentDom contentDom; // the document object model for content.xml
    OdfStylesDom stylesDom; // the document object model for styles.xml
    // the office:automatic-styles element in content.xml
    OdfOfficeAutomaticStyles contentAutoStyles;
    // the office:styles element in styles.xml
    OdfOfficeStyles stylesOfficeStyles;
    OdfStyle style;
    String noaaDateStyleName;
    String noaaTempStyleName;

    try {
      outputDocument = OdfSpreadsheetDocument.newSpreadsheetDocument();
      contentDom = outputDocument.getContentDom();
      contentAutoStyles = contentDom.getOrCreateAutomaticStyles();

      OdfNumberDateStyle dateStyle = new OdfNumberDateStyle(contentDom,
          "yyyy-MM-dd", "numberDateStyle", null);
      OdfNumberStyle numberStyle = new OdfNumberStyle(contentDom,
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

    }
  }
       
        @Test
        public void testGetFromEmptyDateValue() throws Exception {
            OdfSpreadsheetDocument doc = OdfSpreadsheetDocument.newSpreadsheetDocument();
            OdfTable table = OdfTable.newTable(doc);
            OdfTableCell dateCell = table.appendRow().getCellByIndex(0);
            dateCell.setValueType(OfficeValueTypeAttribute.Value.DATE.toString());
            Assert.assertNull(dateCell.getDateValue());
        }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

            Assert.assertNull(dateCell.getDateValue());
        }
       
        @Test
        public void testGetFromEmptyTimeValue() throws Exception {
            OdfSpreadsheetDocument doc = OdfSpreadsheetDocument.newSpreadsheetDocument();
            OdfTable table = OdfTable.newTable(doc);
            OdfTableCell timeCell = table.appendRow().getCellByIndex(0);
            timeCell.setValueType(OfficeValueTypeAttribute.Value.TIME.toString());
            Assert.assertNull(timeCell.getTimeValue());
        }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

    cellRange1.setCellRangeName("TimeCellRange");
    cellRange1.merge();

    saveods("CellRangeName");
    try {
      OdfSpreadsheetDocument saveddos = (OdfSpreadsheetDocument) OdfSpreadsheetDocument.loadDocument(ResourceUtilities.getAbsolutePath(filename + "CellRangeName.ods"));
      OdfTable savedSheet = saveddos.getTableByName("Sheet1");
      OdfTableCellRange namedCellRange = savedSheet.getCellRangeByName("TimeCellRange");
      OdfTableCell cell = namedCellRange.getCellByPosition("A1");
      Assert.assertTrue(cell.getRowSpannedNumber() == 6);
    } catch (Exception e) {
      Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument

  }

  @Test
  public void testMergeExpandCellRange() {
    try {
      OdfSpreadsheetDocument ods = OdfSpreadsheetDocument
          .newSpreadsheetDocument();
      // the doc contain the table which only have one column and one row
      // element
      OdfTable table = ods.getTableByName("Sheet1");
      int nCols = table.getColumnCount();
      int nRows = table.getRowCount();
      Assert.assertTrue(nCols == 1);
      Assert.assertTrue(nRows == 1);
      OdfTableCellRange cellRange = table.getCellRangeByPosition("A1","E1");
      OdfTableCell cell = table.getCellByPosition("A1");
      cell.setStringValue("Merge A1:E1");
      cellRange.merge();
      OdfTable table2 = OdfTable.newTable(ods, 1, 1);
      table2.setTableName("Sheet2");
      OdfTableCellRange cellRange2 = table2.getCellRangeByPosition("A1","F3");
      OdfTableCell cell2 = table2.getCellByPosition("A1");
      cell2.setStringValue("Merge A1:F3");
      cellRange2.merge();
      ods.save(ResourceUtilities.newTestOutputFile(filename + "MergeExpandCell.ods"));
      table = ods.getTableByName("Sheet1");
      Assert.assertTrue(table.getColumnCount() == 5);
      Assert.assertTrue(table.getRowCount() == 1);
      table = ods.getTableByName("Sheet2");
      Assert.assertTrue(table.getColumnCount() == 6);
      Assert.assertTrue(table.getRowCount() == 3);
      OdfTextDocument odt = OdfTextDocument.newTextDocument();
      OdfTable swTable = OdfTable.newTable(odt, 1, 5);
      OdfTableCellRange swCellRange = swTable.getCellRangeByPosition("A1", "E2");
View Full Code Here

Examples of org.openoffice.odf.doc.OdfSpreadsheetDocument

        int binaryEncoding = coreStore.getInt( BrowserCoreConstants.PREFERENCE_FORMAT_ODF_BINARYENCODING );

        // export
        try
        {
            OdfSpreadsheetDocument doc = OdfSpreadsheetDocument.createSpreadsheetDocument();
            OdfFileDom contentDoc = doc.getContentDom();

            // Remove the default table added in construction
            Element spreadsheetElement = ( Element ) contentDoc.getElementsByTagNameNS( OdfNamespace.OFFICE.getUri(),
                "spreadsheet" ).item( 0 );
            OdfTable table = ( OdfTable ) ( spreadsheetElement.getElementsByTagNameNS( OdfNamespace.TABLE.getUri(),
                "table" ).item( 0 ) );
            table.getParentNode().removeChild( table );

            // create the table
            table = new OdfTable( contentDoc );
            table.setName( "Export" ); //$NON-NLS-1$
            Element officeSpreadsheet = ( Element ) contentDoc.getElementsByTagNameNS( OdfNamespace.OFFICE.getUri(),
                "spreadsheet" ).item( 0 );
            officeSpreadsheet.appendChild( table );

            // header
            OdfTableRow headerRow = new OdfTableRow( contentDoc );
            table.appendChild( headerRow );
            LinkedHashMap<String, Short> attributeNameMap = new LinkedHashMap<String, Short>();
            if ( this.exportDn )
            {
                short cellNum = ( short ) 0;
                //attributeNameMap.put( "dn", new Short( cellNum ) ); //$NON-NLS-1$
                OdfTableCell cell = new OdfTableCell( contentDoc );
                cell.setValueType( OdfValueType.STRING );
                cell.setStringValue( "dn" ); //$NON-NLS-1$
                headerRow.appendCell( cell );
            }

            // max export
            if ( searchParameter.getCountLimit() < 1 || searchParameter.getCountLimit() > MAX_COUNT_LIMIT )
            {
                searchParameter.setCountLimit( MAX_COUNT_LIMIT );
            }

            int count = 0;
            exportToOdf( browserConnection, searchParameter, contentDoc, table, headerRow, count, monitor,
                attributeNameMap, valueDelimiter, binaryEncoding, this.exportDn );

            doc.save( exportOdfFilename );
        }
        catch ( Exception e )
        {
            monitor.reportError( e );
        }
View Full Code Here

Examples of org.openoffice.odf.doc.OdfSpreadsheetDocument

        int binaryEncoding = coreStore.getInt( BrowserCoreConstants.PREFERENCE_FORMAT_ODF_BINARYENCODING );

        // export
        try
        {
            OdfSpreadsheetDocument doc = OdfSpreadsheetDocument.createSpreadsheetDocument();
            OdfFileDom contentDoc = doc.getContentDom();

            // Remove the default table added in construction
            Element spreadsheetElement = ( Element ) contentDoc.getElementsByTagNameNS( OdfNamespace.OFFICE.getUri(),
                "spreadsheet" ).item( 0 ); //$NON-NLS-1$
            OdfTable table = ( OdfTable ) ( spreadsheetElement.getElementsByTagNameNS( OdfNamespace.TABLE.getUri(),
                "table" ).item( 0 ) ); //$NON-NLS-1$
            table.getParentNode().removeChild( table );

            // create the table
            table = new OdfTable( contentDoc );
            table.setName( "Export" ); //$NON-NLS-1$
            Element officeSpreadsheet = ( Element ) contentDoc.getElementsByTagNameNS( OdfNamespace.OFFICE.getUri(),
                "spreadsheet" ).item( 0 ); //$NON-NLS-1$
            officeSpreadsheet.appendChild( table );

            // header
            OdfTableRow headerRow = new OdfTableRow( contentDoc );
            table.appendChild( headerRow );
            LinkedHashMap<String, Short> attributeNameMap = new LinkedHashMap<String, Short>();
            if ( this.exportDn )
            {
                //                short cellNum = ( short ) 0;
                //attributeNameMap.put( "dn", new Short( cellNum ) ); //$NON-NLS-1$
                OdfTableCell cell = new OdfTableCell( contentDoc );
                cell.setValueType( OdfValueType.STRING );
                cell.setStringValue( "dn" ); //$NON-NLS-1$
                headerRow.appendCell( cell );
            }

            // max export
            if ( searchParameter.getCountLimit() < 1 || searchParameter.getCountLimit() > MAX_COUNT_LIMIT )
            {
                searchParameter.setCountLimit( MAX_COUNT_LIMIT );
            }

            int count = 0;
            exportToOdf( browserConnection, searchParameter, contentDoc, table, headerRow, count, monitor,
                attributeNameMap, valueDelimiter, binaryEncoding, this.exportDn );

            doc.save( exportOdfFilename );
        }
        catch ( Exception e )
        {
            monitor.reportError( e );
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.