import com.googlecode.xcelite.reader.SheetReader; import com.googlecode.xcelite.sheet.Sheet; public class ExcelReader { public static void main(String[] args) { File file = new File("path/to/your/excel/file.xlsx"); Xcelite xcelite = new Xcelite(file); Sheet sheet = xcelite.getSheet(0); SheetReader<YourDataClass> reader = sheet.getBeanReader(YourDataClass.class); List<YourDataClass> data = reader.read(); for(YourDataClass item : data) { System.out.println(item.toString()); } } } import com.googlecode.xcelite.writer.SheetWriter; import com.googlecode.xcelite.sheet.XceliteSheet; public class ExcelWriter { public static void main(String[] args) { File file = new File("path/to/your/excel/file.xlsx"); Xcelite xcelite = new Xcelite(); XceliteSheet sheet = xcelite.createSheet("Sheet1"); SheetWriter<YourDataClass> writer = sheet.getBeanWriter(YourDataClass.class); List<YourDataClass> data = new ArrayList<>(); writer.write(data); xcelite.write(file); } }


上一篇:
下一篇:
切换中文