java使用poi读取excel内容方法实例
本文导语: 代码如下:import java.io.BufferedInputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.nio.channels.FileChannel;import java.text.DecimalFormat;import java.text.SimpleDateFormat;import java.util.Date; import org.ap...
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class FileOperator {
public static void main(String[] args) throws Exception {
String path = "F:\1.xls";
print(path);
}
public static void print(String path) throws IOException{
BufferedInputStream in = new BufferedInputStream(
new FileInputStream(new File(path)));
POIFSFileSystem fs = new POIFSFileSystem(in);
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFCell cell = null;
HSSFSheet st = wb.getSheetAt(0);
for (int rowIndex = 0; rowIndex