您好,我试图在XSSFWorkBook的帮助下使用FlatFileReader读取xlsx文件,但是使用XSSFWorkBook读取是可以的,但是当尝试使用FlatFileReader读取工作表时,我们无法read.code如下所示,请查看
String fileName = "E:\\LLS-6192013-42631.csv";
File file = new File(fileName);
FileSystemResource fsr = new FileSystemResource(fileName);
XSSFWorkbook workbook = new XSSFWorkbook(fileName);
int sheetIndex = 0;
XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
//System.out.println("sheet content : " + sheet);
ApplicationContext appContext = new ClassPathXmlApplicationContext(
"classpath:/launch-context.xml");
@SuppressWarnings("rawtypes")
FlatFileItemReader flatFileItemReader = (FlatFileItemReader) appContext
.getBean("redemptionReader");
flatFileItemReader.setResource(resource);如何使用FlatFileReader读取xlsx文件?
发布于 2013-06-26 21:49:10
不能使用平面文件项读取器读取XSLX,因为它不是具有简单分隔符的项的平面文件。如果要读取XSLX文件,请使用Apache POI。
但是根据您的代码,您正在读取一个CSV文件。这可以作为平面文件来完成,或者使用Apache Common CSV library更容易。
因此,请检查文件的确切格式并使用相应的库:-)
https://stackoverflow.com/questions/17321038
复制相似问题