admin 管理员组

文章数量: 887021


2024年1月17日发(作者:transient beauty)

break ; case _TYPE_NUMERIC: o = ericCellValue(); if (DateFormatted(cell)) { o = aDate(ericCellValue()); } break ; case _TYPE_STRING: o = ingCellValue(); break ; case _TYPE_ERROR: o = orCellValue(); break ; case _TYPE_BLANK: o = null ; break ; case _TYPE_FORMULA: o = lFormula(); break ; default : o = null ; break ; }

if (o == null ) return ;

for (Field field : fields) { essible( true ); if (e().equals(key)) { Boolean bool = true ; Map map = null ; if (edf == null ) { bool = false ; } else { map = (e()); if (map == null ) { bool = false ; } }

if (e().equals(Date. class )) { if (ss().equals(Date. class )) { (e, o); } else { (e, (ng())); } } else if (e().equals(String. class )) { if (ss().equals(String. class )) { (e, o); } else { (e, ng()); } } else if (e().equals(Long. class )) { if (ss().equals(Long. class )) { (e, o); } else { (e, ong(ng())); } } else if (e().equals(Integer. class )) { if (ss().equals(Integer. class )) { (e, o); } else { // 检查是否需要转换 if (bool) { (e, (ng()) != null

nt((ng())) : nt(ng())); } else { (e, nt(ng())); }

} } else if (e().equals(BigDecimal. class )) { if (ss().equals(BigDecimal. class )) { (e, o); } else { (e, f(ouble(ng()))); } } else if (e().equals(Boolean. class )) {

if (ss().equals(Boolean. class )) { (e, o); } else { // 检查是否需要转换 if (bool) { (e, (ng()) != null

oolean((ng())) : oolean(ng())); } else { (e, oolean(ng())); } } } else if (e().equals(Float. class )) { if (ss().equals(Float. class )) { (e, o); } else { (e, loat(ng())); } } else if (e().equals(Double. class )) { if (ss().equals(Double. class )) { (e, o); } else { (e, ouble(ng())); }

}

} }

} catch (Exception ex) { tackTrace(); // 如果还是读到的数据格式还是不对,只能放弃了 if (etimes > 7 ) { throw ex; } etimes++; if (o == null ) { readCellContent(key, fields, cell, e, edf); } } }

public static void main(String[] args) throws Exception { n( "写Excel" );

List list = new ArrayList(); User u = new User(); ( "3" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( false ); ( new BigDecimal( 123 )); (u);

u = new User(); ( "23" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( true ); ( new BigDecimal( 234 )); (u);

u = new User(); ( "123" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( false ); ( new BigDecimal( 2344 )); (u);

u = new User(); ( "22" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( true );

( new BigDecimal( 908 )); (u);

ExcelDataFormatter edf = new ExcelDataFormatter(); Map map = new HashMap(); ( "真" , "true" ); ( "假" , "false" ); ( "locked" , map);

// writeToFile(list,edf, "D:");

List xx = new ExcelUtils( new User()).readFromFile(edf, new File("D:" )); n( new GsonBuilder().create().toJson(xx));

}//测试代码 public static void main(String[] args) throws Exception { n( "写Excel" );

List list = new ArrayList(); User u = new User(); ( "3" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( false ); ( new BigDecimal( 123 )); (u);

u = new User(); ( "23" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( true ); ( new BigDecimal( 234 )); (u);

u = new User(); ( "123" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( false ); ( new BigDecimal( 2344 )); (u);

u = new User(); ( "22" ); e( "fdsafdsa" ); ( 123 .23D); ( new Date()); ked( true ); ( new BigDecimal( 908 )); (u);

ExcelDataFormatter edf = new ExcelDataFormatter(); Map map = new HashMap(); ( "真" , "true" ); ( "假" , "false" ); ( "locked" , map);

// writeToFile(list,edf, "D:");

List xx = new ExcelUtils( new User()).readFromFile(edf, new File("D:" )); n( new GsonBuilder().create().toJson(xx));

}}ataFormatter代码package ;

import p;import ;

/**


本文标签: 需要 读到 放弃 转换 检查