Browse Source

完成2个测试案例

developing
Jiaju Zhuang 3 years ago
parent
commit
316db1f256
  1. 4
      src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java
  2. 6
      src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationDataTest.java
  3. 13
      src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationIndexAndNameDataTest.java

4
src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java

@ -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();

6
src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationDataTest.java

@ -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 {

13
src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationIndexAndNameDataTest.java

@ -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()

Loading…
Cancel
Save