poi做核心的xlsx文件解析优化,效率解决

这个jar包依赖于poi.本质上还是采用poi的解析原理,只是在解析时把xlsx文件转换成xls来进行解析.所以在效率上是比直接解析xlsx快的.

依赖的jar:ant.jar
          poi-3.11.jar
          poi-excelant-3.11.jar
          poi-ooxml-3.11.jar
          poi-ooxml-schemas-3.11.jar
          poi-scratchpad-3.11.jar
          xmlbeans-2.6.0.jar

具体的如下:
package test;

import java.io.File;

import org.junit.Test;

import com.zte.ums.towerzj.util.excel.ExcelBuilder;
import com.zte.ums.towerzj.util.excel.ExcelDataCell;
import com.zte.ums.towerzj.util.excel.ExcelDataRow;
import com.zte.ums.towerzj.util.excel.ExcelSheetReader;
import com.zte.ums.towerzj.util.excel.ExcelSheetReaderConsumer;


public class ExlsTest {
@Test
public void test() {
File destFile = new File("C:/Users/64/Desktop/test.xlsx");
ExcelBuilder.makeReader( destFile ).withDefaultSheet( new ExcelSheetReader().withSheetReaderConsumer( new ExcelSheetReaderConsumer(){
            public void readOneRow(int aSheetIndex, ExcelDataRow aRow) {
            if(aSheetIndex != 0){
            return;
            }
            /*int rowIndex = aRow.getRowIndex();
            if(rowIndex == 0){
            //ignore header row
            return;
            }*/
            //int cellCount = aRow.getCellCount();
           
           
            ExcelDataCell nextCell = aRow.getCellAt(0);
            String text = nextCell.getCellValueText().toString();
           
            ExcelDataCell vcell = aRow.getCellAt(1);
            String vText = vcell.getCellValueText().toString();
           
            System.out.println("'" + text + "'" + " : " + "'" + vText + "',");
           
            }
})).doRead();

}

}


依赖的jar,附件

猜你喜欢

转载自shuhui.iteye.com/blog/2287794