Пример #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 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());
  }
Пример #6
0
  @Test
  public void exportWidthSplitTest() {
    SBook book = SBooks.createBook("book1");
    SSheet sheet1 = book.createSheet("Sheet1");
    int defaultWidth = 100;
    sheet1.setDefaultColumnWidth(defaultWidth);
    sheet1.setDefaultRowHeight(200);
    Assert.assertEquals(defaultWidth, sheet1.getDefaultColumnWidth());
    Assert.assertEquals(200, sheet1.getDefaultRowHeight());

    Iterator<SColumnArray> arrays = sheet1.getColumnArrayIterator();
    Assert.assertFalse(arrays.hasNext());

    Assert.assertNull(sheet1.getColumnArray(0));

    sheet1.setupColumnArray(0, 8).setWidth(10);
    sheet1.setupColumnArray(11, 255);
    arrays = sheet1.getColumnArrayIterator();
    SColumnArray array = arrays.next();
    Assert.assertEquals(0, array.getIndex());
    Assert.assertEquals(8, array.getLastIndex());
    Assert.assertEquals(10, array.getWidth());

    array = arrays.next();
    Assert.assertEquals(9, array.getIndex());
    Assert.assertEquals(10, array.getLastIndex());
    Assert.assertEquals(defaultWidth, array.getWidth());

    array = arrays.next();
    Assert.assertEquals(11, array.getIndex());
    Assert.assertEquals(255, array.getLastIndex());
    Assert.assertEquals(defaultWidth, array.getWidth());

    ///////////// first export
    File outFile =
        ImExpTestUtil.writeBookToFile(
            book,
            ImExpTestUtil.DEFAULT_EXPORT_TARGET_PATH + ImExpTestUtil.DEFAULT_EXPORT_FILE_NAME_XLSX,
            EXPORTER_TYPE);
    SBook outBook = ImExpTestUtil.loadBook(outFile, "OutBook");

    sheet1 = outBook.getSheet(0);

    // default width become 104px
    // Assert.assertEquals(defaultWidth, sheet1.getDefaultColumnWidth());
    Assert.assertEquals(200, sheet1.getDefaultRowHeight());

    arrays = sheet1.getColumnArrayIterator();
    Assert.assertTrue(arrays.hasNext());

    arrays = sheet1.getColumnArrayIterator();
    array = arrays.next();
    Assert.assertEquals(0, array.getIndex());
    Assert.assertEquals(8, array.getLastIndex());
    Assert.assertEquals(10, array.getWidth());

    array = arrays.next();
    Assert.assertEquals(9, array.getIndex());
    Assert.assertEquals(10, array.getLastIndex());
    Assert.assertEquals(defaultWidth, array.getWidth());

    array = arrays.next();
    Assert.assertEquals(11, array.getIndex());
    Assert.assertEquals(255, array.getLastIndex());
    Assert.assertEquals(defaultWidth, array.getWidth());

    ///////////// second export
    File outFile2 =
        ImExpTestUtil.writeBookToFile(
            outBook,
            ImExpTestUtil.DEFAULT_EXPORT_TARGET_PATH + ImExpTestUtil.DEFAULT_EXPORT_FILE_NAME_XLSX,
            EXPORTER_TYPE);
    SBook outBook2 = ImExpTestUtil.loadBook(outFile2, "OutBook");

    sheet1 = outBook2.getSheet(0);

    // default width become 104px
    // Assert.assertEquals(100, sheet1.getDefaultColumnWidth());
    Assert.assertEquals(200, sheet1.getDefaultRowHeight());

    arrays = sheet1.getColumnArrayIterator();
    Assert.assertTrue(arrays.hasNext());

    arrays = sheet1.getColumnArrayIterator();
    array = arrays.next();
    Assert.assertEquals(0, array.getIndex());
    Assert.assertEquals(8, array.getLastIndex());
    Assert.assertEquals(10, array.getWidth());

    array = arrays.next();
    Assert.assertEquals(9, array.getIndex());
    Assert.assertEquals(10, array.getLastIndex());
    Assert.assertEquals(100, array.getWidth());

    array = arrays.next();
    Assert.assertEquals(11, array.getIndex());
    Assert.assertEquals(255, array.getLastIndex());
    Assert.assertEquals(100, array.getWidth());
  }
Пример #7
0
 @Test
 public void export4HumanChecking() {
   SBook book = ImExpTestUtil.loadBook(IMPORT_FILE_UNDER_TEST, "XSSFBook");
   ImExpTestUtil.writeBookToFile(
       book, ImExpTestUtil.DEFAULT_EXPORT_TARGET_PATH + "humanChecking.xlsx", EXPORTER_TYPE);
 }