Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.SpreadsheetDocument


 
 
  @Test
  public void testSetFontName() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, StyleTypeDefinitions.TextLinePosition.REGULAR, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      //cell.setFont(font);
      font.setFamilyName("Chinese");
      cell.setStringValue("testGetFontStyle.");
     
      TextProperties textProperties = cell.getStyleHandler().getTextPropertiesForWrite();
      textProperties.setFont(font);
     
      //validate
      String fontname = textProperties.getFontName();
      Assert.assertEquals("Chinese", fontname);
     
      //save
      document.save(ResourceUtilities.newTestOutputFile("testFontOutput1.ods"));
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here


    Border borderbase1 = new Border(new Color("#ff3333"), 5, SupportedLinearMeasure.PT);
    Border borderbase2 = new Border(new Color("#0000ff"), 0.0154, 0.0008, 0.0008, SupportedLinearMeasure.IN);
    Border borderbase3 = new Border(new Color("#ff3333"), 0.0362, 0.0008, 0.0008, SupportedLinearMeasure.IN);
    Border borderbase4 = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      Cell cell1 = table.getCellByPosition("A8");
      Border border1 = cell1.getBorder(CellBordersType.BOTTOM);
      Border border11 = cell1.getBorder(CellBordersType.LEFT);
      Assert.assertEquals(borderbase1, border1);
      Assert.assertEquals(borderbase1, border11);
View Full Code Here

 
  @Test
  public void testSetWidth() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      //setWidth
      borderbase.setWidth(0.056);
     
      Cell cell = table.getCellByPosition("A14");
      cell.setBorders(CellBordersType.LEFT, borderbase);
View Full Code Here

 
  @Test
  public void testSGetInnerLineWidth() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      //setWidth
      borderbase.setInnerLineWidth(0.0156);
     
      Cell cell = table.getCellByPosition("A14");
      cell.setBorders(CellBordersType.LEFT, borderbase);
View Full Code Here

 
  @Test
  public void testSGetDistance() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      //setWidth
    //  borderbase.setInnerLineWidth(0.0156);
      borderbase.setDistance(0.123);
     
      Cell cell = table.getCellByPosition("A14");
View Full Code Here

 
  @Test
  public void testSGetOuterLineWidth() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
     
      System.out.println(borderbase.getOuterLineWidth());
      borderbase.setOuterLineWidth(0.125);
      System.out.println(borderbase.getOuterLineWidth());     
     
View Full Code Here

 
  @Test
  public void testSGetLinearMeasure() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
     
      borderbase.setLinearMeasure(StyleTypeDefinitions.SupportedLinearMeasure.CM);
     
      Cell cell = table.getCellByPosition("A14");
      cell.setBorders(CellBordersType.LEFT, borderbase);
View Full Code Here

    // get type
    align = fcell.getHorizontalAlignmentType();
    Assert.assertEquals(HorizontalAlignmentType.RIGHT, align);
    saveods();

    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      HorizontalAlignmentType horizonAlignment = cell.getHorizontalAlignmentType();
      Assert.assertEquals(HorizontalAlignmentType.DEFAULT, horizonAlignment);

      table = ods.getTableByName("Sheet2");
      if (table != null) {
        table.remove();
      }
      table = Table.newTable(ods);
      table.setTableName("Sheet2");
View Full Code Here

 

  @Test
  public void testVerticalAlignmentType() throws Exception{
    try {
      SpreadsheetDocument odsdoc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("TestSpreadsheetTable.ods"));
   
      int columnindex = 0, rowindex = 3;
      Table table = odsdoc.getTableByName("Sheet1");
      Cell fcell = table.getCellByPosition(columnindex, rowindex);
 
      System.out.println(fcell.getStringValue());
     
      StyleTypeDefinitions.VerticalAlignmentType align = fcell.getVerticalAlignmentType();
View Full Code Here

    fcell.setVerticalAlignment(StyleTypeDefinitions.VerticalAlignmentType.BOTTOM);
    align = fcell.getVerticalAlignmentType();
    Assert.assertEquals(StyleTypeDefinitions.VerticalAlignmentType.BOTTOM, align);
    saveods();
    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      StyleTypeDefinitions.VerticalAlignmentType verticalAlignment = cell.getVerticalAlignmentType();
      Assert.assertEquals(StyleTypeDefinitions.VerticalAlignmentType.DEFAULT, verticalAlignment);

      table = ods.getTableByName("Sheet2");
      if (table != null) {
        table.remove();
      }
      table = Table.newTable(ods);
      table.setTableName("Sheet2");
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.SpreadsheetDocument

Copyright © 2018 www.massapicom. 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.