Browse Source

添加了javadoc和对method的测试

pull/2445/head
khw 3 years ago
parent
commit
7b8546e4e5
  1. 8
      src/main/java/com/alibaba/excel/util/NumberUtils.java
  2. 22
      src/test/java/com/alibaba/easyexcel/test/temp/issue2443/Issue2443Test.java

8
src/main/java/com/alibaba/excel/util/NumberUtils.java

@ -95,11 +95,11 @@ public class NumberUtils {
} }
/** /**
* parse * parse Integer from string
* *
* @param string * @param string An integer read in string format
* @param contentProperty * @param contentProperty Properties of the content read in
* @return * @return An integer converted from a string
*/ */
public static Integer parseInteger(String string, ExcelContentProperty contentProperty) throws ParseException { public static Integer parseInteger(String string, ExcelContentProperty contentProperty) throws ParseException {
if (!hasFormat(contentProperty)) { if (!hasFormat(contentProperty)) {

22
src/test/java/com/alibaba/easyexcel/test/temp/issue2443/Issue2443Test.java

@ -1,14 +1,17 @@
package com.alibaba.easyexcel.test.temp.issue2443; package com.alibaba.easyexcel.test.temp.issue2443;
import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener; import com.alibaba.excel.read.listener.PageReadListener;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*;
import java.io.File; import java.io.File;
import java.text.ParseException;
@Ignore @Ignore
@Slf4j @Slf4j
@ -33,4 +36,21 @@ public class Issue2443Test {
} }
})).sheet().doRead(); })).sheet().doRead();
} }
@Test
public void parseIntegerTest1() throws ParseException {
String string = "1.00";
ExcelContentProperty contentProperty = null;
int Int = NumberUtils.parseInteger(string,contentProperty);
assertEquals(1, Int);
}
@Test
public void parseIntegerTest2() throws ParseException {
String string = "2.00";
ExcelContentProperty contentProperty = null;
int Int = NumberUtils.parseInteger(string,contentProperty);
assertEquals(2, Int);
}
} }

Loading…
Cancel
Save