forked from github/easyexcel
Jiaju Zhuang
5 years ago
8 changed files with 150 additions and 1 deletions
@ -0,0 +1,54 @@
|
||||
package com.alibaba.easyexcel.test.temp; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.util.List; |
||||
|
||||
import org.junit.Ignore; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.excel.support.ExcelTypeEnum; |
||||
import com.alibaba.fastjson.JSON; |
||||
|
||||
/** |
||||
* 临时测试 |
||||
* |
||||
* @author Jiaju Zhuang |
||||
**/ |
||||
@Ignore |
||||
public class Lock2Test { |
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Lock2Test.class); |
||||
|
||||
@Test |
||||
public void test() throws Exception { |
||||
File file = new File("D:\\test\\珠海2.xlsx"); |
||||
|
||||
List<Object> list = EasyExcel.read(file).sheet().headRowNumber(0).doReadSync(); |
||||
LOGGER.info("数据:{}", list.size()); |
||||
for (Object data : list) { |
||||
LOGGER.info("返回数据:{}", JSON.toJSONString(data)); |
||||
} |
||||
LOGGER.info("文件状态:{}", file.exists()); |
||||
file.delete(); |
||||
Thread.sleep(500 * 1000); |
||||
} |
||||
|
||||
@Test |
||||
public void test2() throws Exception { |
||||
File file = new File("D:\\test\\converter03.xls"); |
||||
|
||||
List<Object> list = EasyExcel.read(file).sheet().headRowNumber(0).doReadSync(); |
||||
LOGGER.info("数据:{}", list.size()); |
||||
for (Object data : list) { |
||||
LOGGER.info("返回数据:{}", JSON.toJSONString(data)); |
||||
} |
||||
LOGGER.info("文件状态:{}", file.exists()); |
||||
file.delete(); |
||||
Thread.sleep(500 * 1000); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.alibaba.easyexcel.test.temp.poi; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
|
||||
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.XSSFRow; |
||||
import org.apache.poi.xssf.usermodel.XSSFSheet; |
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
||||
import org.junit.Ignore; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import com.alibaba.easyexcel.test.util.TestFileUtil; |
||||
|
||||
/** |
||||
* 测试poi |
||||
* |
||||
* @author Jiaju Zhuang |
||||
**/ |
||||
@Ignore |
||||
public class Poi2Test { |
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Poi2Test.class); |
||||
|
||||
@Test |
||||
public void test() throws IOException { |
||||
String file = "D:\\test\\珠海.xlsx"; |
||||
SXSSFWorkbook xssfWorkbook = new SXSSFWorkbook(new XSSFWorkbook(file)); |
||||
SXSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); |
||||
LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); |
||||
SXSSFRow row = xssfSheet.getRow(0); |
||||
LOGGER.info("第一行数据:{}", row); |
||||
} |
||||
|
||||
@Test |
||||
public void lastRowNumXSSF() throws IOException { |
||||
String file = "D:\\test\\珠海.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()); |
||||
} |
||||
} |
Loading…
Reference in new issue