-
Notifications
You must be signed in to change notification settings - Fork 0
Major Java APIs
XlBean read(InputStream)
XlBean read(File)
InputStream in = XlBeanReaderTest.class.getResourceAsStream("TestBook_format.xlsx");
XlBeanReader reader = new XlBeanReader();
XlBean bean = reader.read(in);
XlBeanReaderContext readContext(InputStream)
XlBeanReaderContext readContext(File)
InputStream in = XlBeanReaderTest.class.getResourceAsStream("TestBook_option.xlsx");
XlBeanReader reader = new XlBeanReader();
XlBeanReaderContext context = reader.readContext(in);
XlBean bean = context.getXlBean();
DefinitionRepository definitions = context.getDefinitions();
XlBean itself is a implementation of java.util.Map
so it supports Object get(String)
by default. In addition to standard Map methods, XlBean implements conversion APIs for your convenience.
XlBean bean(String key)
List<XlBean> beans(String key)
String string(String key)
List<String> strings(String key)
Boolean bool(String key)
List<Boolean> bools(String key)
Integer integer(String key)
List<Integer> integers(String key)
Long lng(String key)
List<Long> longs(String key)
Double dbl(String key)
List<Double> doubles(String key)
Short shrt(String key)
List<Short> shorts(String key)
Float flt(String key)
List<Float> floats(String key)
Character character(String key)
List<Character> characters(String key)
XlBean
object can be converted to instance of any class by using of
methods, including nested beans. Internally it uses org.xlbean.converter.BeanConverter#toBean(Object)
so that detail specification of this conversion is defined by this class.
<T> T of(Class<T> destinationClass)
-
<T> T beanOf(String sourceKey, Class<T> destinationClass)
: Convert an object retrieved bysourceKey
todestinationClass
-
<T> List<T> listOf(String sourceKey, Class<T> destinationClass)
: Convert a List retrieved bysourceKey
to a List ofdestinationClass
XlBean
supports only String, XlBean or List as values by default. If you want to add other type of values, then convert those values to String, XlBean or List by yourself or use set
method instead. set
method will use org.xlbean.converter.BeanConverter#toMap(Object)
internally to convert any type of value to supported types.
void set(Object obj)
void set(String key, Object obj)