|
|
|
@ -2,11 +2,17 @@ package com.alibaba.easyexcel.test.temp.poi;
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFDataFormatter; |
|
|
|
|
import org.apache.poi.ss.usermodel.DataFormatter; |
|
|
|
|
import org.apache.poi.ss.usermodel.DateUtil; |
|
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFRow; |
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFSheet; |
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFDataFormat; |
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
@ -40,14 +46,15 @@ public class PoiFormatTest {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void lastRowNumXSSF() throws IOException { |
|
|
|
|
String file = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx"; |
|
|
|
|
String file = "/Users/zhuangjiaju/Downloads/测试格式.xlsx"; |
|
|
|
|
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(file); |
|
|
|
|
LOGGER.info("一共:{}个sheet", xssfWorkbook.getNumberOfSheets()); |
|
|
|
|
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); |
|
|
|
|
LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); |
|
|
|
|
XSSFRow row = xssfSheet.getRow(0); |
|
|
|
|
LOGGER.info("第一行数据:{}", row); |
|
|
|
|
xssfSheet.createRow(20); |
|
|
|
|
LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); |
|
|
|
|
XSSFRow row = xssfSheet.getRow(1); |
|
|
|
|
XSSFCell xssfCell = row.getCell(0); |
|
|
|
|
DataFormatter d = new DataFormatter(Locale.CHINA); |
|
|
|
|
LOGGER.info("fo:{}", d.formatCellValue(xssfCell)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|