Exemplo n.º 1
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());
  }
Exemplo n.º 2
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);
 }