一、strut2框架 利用其上傳下載功能
二、xml解析技術 定製導入模板
三、jquery UI 製做前臺 html
四、
jquery
HSSF 與office03-07格式對應,版本低,兼容性好
XSSF 與xlsx格式對應apache
工做薄 excel
工做表 Sheet
行記錄 row
單元格 cell框架
詳見 http://poi.apache.org/overview.htmlmaven
如:spa
<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.8</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.8</version> </dependency>
一、建立Excel工做簿
二、建立工做表sheet
三、建立第一行 title
四、建立一個文件
五、存盤excel
HSSFWorkbook
HSSFSheet
HSSFRow
HSSFCell
code
HSSFWorkbook book = new HSSFWorkbook(); HSSFSheet sheet = book.createSheet(); String[] columns = {"id","名字","性別"}; HSSFRow headeRow = sheet.createRow(0); for (int i = 0; i < columns.length; i++) { HSSFCell cell = headeRow.createCell(i); cell.setCellValue(columns[i]); } for (int i = 1; i < 11; i++) { HSSFRow nextRow = sheet.createRow(i); HSSFCell cell2 = nextRow.createCell(0); cell2.setCellValue(i); cell2 = nextRow.createCell(1); cell2.setCellValue("name" + i); cell2 = nextRow.createCell(2); cell2.setCellValue("男"); } FileOutputStream outputStream; try { outputStream = new FileOutputStream(new File(fileName)); book.write(outputStream); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }
一、建立Excel,讀取文件內容
二、默認讀取第一個工做表xml
//建立Excel,讀取文件內容 HSSFWorkbook workbook = new HSSFWorkbook(FileUtils.openInputStream(file)); //獲取第一個工做表workbook.getSheet("Sheet0"); //HSSFSheet sheet = workbook.getSheet("Sheet0"); //讀取默認第一個工做表sheet HSSFSheet sheet = workbook.getSheetAt(0); int firstRowNum = 0; //獲取sheet中最後一行行號 int lastRowNum = sheet.getLastRowNum(); for (int i = firstRowNum; i <=lastRowNum; i++) { HSSFRow row = sheet.getRow(i); //獲取當前行最後單元格列號 int lastCellNum = row.getLastCellNum(); for (int j = 0; j < lastCellNum; j++) { HSSFCell cell = row.getCell(j); String value = cell.getStringCellValue(); System.out.print(value + " "); } System.out.println(); }