提交 316db1f2 编写于 作者: 庄家钜's avatar 庄家钜

完成2个测试案例

上级 7a2c5634
......@@ -728,8 +728,12 @@ public class CsvSheet implements Sheet, Closeable {
try {
for (CsvRow row : rowCache) {
Iterator<Cell> cellIterator = row.cellIterator();
int columnIndex = 0;
while (cellIterator.hasNext()) {
CsvCell csvCell = (CsvCell)cellIterator.next();
while (csvCell.getColumnIndex() > columnIndex++) {
csvPrinter.print(null);
}
csvPrinter.print(buildCellValue(csvCell));
}
csvPrinter.println();
......
......@@ -24,7 +24,7 @@ public class AnnotationDataTest {
public static void init() {
file07 = TestFileUtil.createNewFile("annotation07.xlsx");
file03 = TestFileUtil.createNewFile("annotation03.xls");
fileCsv = TestFileUtil.createNewFile("annotation.csv");
fileCsv = TestFileUtil.createNewFile("annotationCsv.csv");
}
@Test
......@@ -38,8 +38,8 @@ public class AnnotationDataTest {
}
@Test
public void t02ReadAndWriteCsv() throws Exception {
//readAndWrite(fileCsv);
public void t03ReadAndWriteCsv() throws Exception {
readAndWrite(fileCsv);
}
private void readAndWrite(File file) throws Exception {
......
......@@ -4,12 +4,12 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Annotation data test
*
......@@ -19,11 +19,13 @@ public class AnnotationIndexAndNameDataTest {
private static File file07;
private static File file03;
private static File fileCsv;
@BeforeClass
public static void init() {
file07 = TestFileUtil.createNewFile("annotationIndexAndName07.xlsx");
file03 = TestFileUtil.createNewFile("annotationIndexAndName03.xls");
fileCsv = TestFileUtil.createNewFile("annotationIndexAndNameCsv.csv");
}
@Test
......@@ -36,6 +38,11 @@ public class AnnotationIndexAndNameDataTest {
readAndWrite(file03);
}
@Test
public void t03ReadAndWrite03() {
readAndWrite(fileCsv);
}
private void readAndWrite(File file) {
EasyExcel.write(file, AnnotationIndexAndNameData.class).sheet().doWrite(data());
EasyExcel.read(file, AnnotationIndexAndNameData.class, new AnnotationIndexAndNameDataListener()).sheet()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册