示例#1
0
 @Test
 public void autoFilter() {
   File outFile =
       ImExpTestUtil.write(
           ImExpTestUtil.loadBook(FILTER_IMPORT_FILE_UNDER_TEST, "XSSFBook"), EXPORTER_TYPE);
   SBook book = ImExpTestUtil.loadBook(outFile, DEFAULT_BOOK_NAME);
   autoFilter(book);
 }
示例#2
0
 @Test
 public void cellBorderTest() {
   File outFile =
       ImExpTestUtil.write(
           ImExpTestUtil.loadBook(IMPORT_FILE_UNDER_TEST, "XSSFBook"), EXPORTER_TYPE);
   SBook book = ImExpTestUtil.loadBook(outFile, DEFAULT_BOOK_NAME);
   cellBorderTest(book);
 }
示例#3
0
 @Test
 public void scatterChart() {
   File outFile =
       ImExpTestUtil.write(
           ImExpTestUtil.loadBook(CHART_IMPORT_FILE_UNDER_TEST, "XSSFBook"), EXPORTER_TYPE);
   SBook book = ImExpTestUtil.loadBook(outFile, DEFAULT_BOOK_NAME);
   scatterChart(book);
 }
示例#4
0
 @Test
 public void lastChangedColumnTest() {
   File outFile =
       ImExpTestUtil.write(
           ImExpTestUtil.loadBook(IMPORT_FILE_UNDER_TEST, "XSSFBook"), EXPORTER_TYPE);
   SBook book = ImExpTestUtil.loadBook(outFile, DEFAULT_BOOK_NAME);
   lastChangedColumnTest(book);
 }
示例#5
0
  @Test
  public void richTextModelTest() {
    SBook book = SBooks.createBook("rich");
    SSheet sheet = book.createSheet("first");
    SCell cell = sheet.getCell(0, 0);

    SRichText rText = cell.setupRichTextValue();
    SFont font1 = book.createFont(true);
    font1.setColor(book.createColor("#0000FF"));
    font1.setStrikeout(true);
    rText.addSegment("abc", font1);

    SFont font2 = book.createFont(true);
    font2.setColor(book.createColor("#FF0000"));
    font2.setBoldweight(Boldweight.BOLD);
    rText.addSegment("123", font2);

    SFont font3 = book.createFont(true);
    font3.setColor(book.createColor("#C78548"));
    font3.setUnderline(Underline.SINGLE);
    rText.addSegment("xyz", font3);

    cell = sheet.getCell(0, 1);
    rText = cell.setupRichTextValue();
    font1 = book.createFont(true);
    font1.setColor(book.createColor("#FFFF00"));
    font1.setItalic(true);
    rText.addSegment("Hello", font1);

    font2 = book.createFont(true);
    font2.setColor(book.createColor("#FF33FF"));
    font2.setBoldweight(Boldweight.BOLD);
    rText.addSegment("World", font2);

    font3 = book.createFont(true);
    font3.setColor(book.createColor("#CCCC99"));
    font3.setName("HGPSoeiKakupoptai");
    rText.addSegment("000", font3);

    ImExpTestUtil.write(book, ExcelExportFactory.Type.XLSX);
  }
示例#6
0
  @Test
  public void picture() {
    File outFile =
        ImExpTestUtil.write(
            ImExpTestUtil.loadBook(PICTURE_IMPORT_FILE_UNDER_TEST, "XSSFBook"), EXPORTER_TYPE);
    SBook book = ImExpTestUtil.loadBook(outFile, DEFAULT_BOOK_NAME);
    picture(book);

    SSheet sheet2 = book.getSheet(1);
    assertEquals(2, sheet2.getPictures().size());
    SPicture flowerJpg = sheet2.getPicture(0);
    assertEquals(Format.JPG, flowerJpg.getFormat());
    assertEquals(569, flowerJpg.getAnchor().getWidth());
    assertEquals(427, flowerJpg.getAnchor().getHeight());

    // different spec in XLS
    SPicture rainbowGif = sheet2.getPicture(1);
    assertEquals(Format.GIF, rainbowGif.getFormat());
    assertEquals(613, rainbowGif.getAnchor().getWidth());
    assertEquals(345, rainbowGif.getAnchor().getHeight());
  }
示例#7
0
  @SuppressWarnings("unused")
  @Test
  public void hyperlinkModelTest() {
    SBook book = SBooks.createBook("hyperlink");
    SSheet sheet = book.createSheet("link");
    SCell cell = sheet.getCell(0, 0);
    SHyperlink hyperlink =
        cell.setupHyperlink(
            SHyperlink.HyperlinkType.URL,
            "http://www.zkoss.org/download/zkspreadsheet",
            "Download ZK Spreadsheet");

    cell.setStringValue("Go to ZK Spreadsheet Download Page");

    SCell cellB4 = sheet.getCell("B4");

    SRichText rText = cellB4.setupRichTextValue();
    SFont font1 = book.createFont(true);
    font1.setColor(book.createColor("#0000FF"));
    font1.setStrikeout(true);
    rText.addSegment("abc", font1);

    SFont font2 = book.createFont(true);
    font2.setColor(book.createColor("#FF0000"));
    font2.setBoldweight(Boldweight.BOLD);
    rText.addSegment("123", font2);

    SFont font3 = book.createFont(true);
    font3.setColor(book.createColor("#C78548"));
    font3.setUnderline(Underline.SINGLE);
    rText.addSegment("xyz", font3);

    SHyperlink linkB4 =
        cellB4.setupHyperlink(
            SHyperlink.HyperlinkType.URL, "http://www.yahoo.com.tw/", "Hyperlink Label B4");

    ImExpTestUtil.write(book, ExcelExportFactory.Type.XLSX);
  }