@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // 导入Excel
    if (requestCode == REQUEST_FILE_PATH && resultCode == RESULT_OK) {

      excelHandler.readWorkBook(data.getStringExtra("URL"));
      if (excelHandler.openSucceed()) {
        Intent intent = new Intent(MainActivity.this, FirstActivity.class);
        startActivity(intent);
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * 创建单元格样式
  *
  * @param fontColor 字体颜色
  * @param fontBlod 字体加粗值
  * @param fontUnderLine 字体下划线
  * @param fontSize 字体大小
  * @param fontAlign 字体对齐方式
  * @param isBorder 单元格是否带边框
  * @return
  */
 public static CellStyle newInstance(
     ExcelHandler handler,
     short fontColor,
     short fontBlod,
     byte fontUnderLine,
     short fontSize,
     short fontAlign,
     boolean isBorder) {
   return newInstance(
       handler.getWorkbook(), fontColor, fontBlod, fontUnderLine, fontSize, fontAlign, isBorder);
 }
Ejemplo n.º 3
0
  @Test
  public void testReadFixedRows() throws Exception {
    ExcelRange range = ExcelRange.sheetIndex(0).rowFrom(1).rowTo(2).columnRange("A", "G");
    ExcelRangeData data = instance.readRange(range);
    assertEquals(2, data.getRowCount());

    assertEquals("suilink", data.getString(0, 0));
    assertEquals("广州穗灵通讯科技有限公司", data.getString(0, 1));
    assertTrue(DateUtils.isSameDay(data.getDate(0, 2), parseDate(2002, 7, 1)));
    assertNull(data.getDate(0, 3));
    assertEquals(1, data.getInt(0, 4).intValue());
    assertEquals(1L, data.getLong(0, 4).longValue());
    assertEquals(1.0, data.getDouble(0, 4).doubleValue(), 0.0001);
    assertNull(data.getDate(0, 5));
    assertFalse(data.getBoolean(0, 6));
    assertTrue(data.getBoolean(1, 6));
  }
Ejemplo n.º 4
0
 @Test(expected = IllegalStateException.class)
 public void testWrongDate() {
   ExcelRange range = ExcelRange.sheetIndex(0).rowFrom(1).rowTo(2).columnRange("A", "G");
   ExcelRangeData data = instance.readRange(range);
   data.getDate(0, 1);
 }