Browse Source

测试formatter

pull/2430/head
Jiaju Zhuang 3 years ago
parent
commit
f07df6237a
  1. 2
      easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
  2. 17
      easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiFormatTest.java

2
easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java

@ -37,7 +37,7 @@ public class Lock2Test {
// File file = TestFileUtil.readUserHomeFile("test/test6.xls"); // File file = TestFileUtil.readUserHomeFile("test/test6.xls");
File file = new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/src/test/resources/converter/converter07.xlsx"); File file = new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/src/test/resources/converter/converter07.xlsx");
List<Object> list = EasyExcel.read("/Users/zhuangjiaju/test/test3.xlsx").sheet(0).headRowNumber(0).doReadSync(); List<Object> list = EasyExcel.read("/Users/zhuangjiaju/Downloads/测试格式.xlsx").sheet(0).headRowNumber(0).doReadSync();
LOGGER.info("数据:{}", list.size()); LOGGER.info("数据:{}", list.size());
for (Object data : list) { for (Object data : list) {
LOGGER.info("返回数据:{}", CollectionUtils.size(data)); LOGGER.info("返回数据:{}", CollectionUtils.size(data));

17
easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiFormatTest.java

@ -2,11 +2,17 @@ package com.alibaba.easyexcel.test.temp.poi;
import java.io.File; import java.io.File;
import java.io.IOException; 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.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.streaming.SXSSFRow; import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; 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.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -40,14 +46,15 @@ public class PoiFormatTest {
@Test @Test
public void lastRowNumXSSF() throws IOException { 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); XSSFWorkbook xssfWorkbook = new XSSFWorkbook(file);
LOGGER.info("一共:{}个sheet", xssfWorkbook.getNumberOfSheets()); LOGGER.info("一共:{}个sheet", xssfWorkbook.getNumberOfSheets());
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum());
XSSFRow row = xssfSheet.getRow(0); XSSFRow row = xssfSheet.getRow(1);
LOGGER.info("第一行数据:{}", row); XSSFCell xssfCell = row.getCell(0);
xssfSheet.createRow(20); DataFormatter d = new DataFormatter(Locale.CHINA);
LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); LOGGER.info("fo:{}", d.formatCellValue(xssfCell));
} }
} }

Loading…
Cancel
Save