Skip to content

Commit 9cab5e6

Browse files
committed
refectoring spring boot excel
1 parent 2accbf1 commit 9cab5e6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
package com.titstory.heowc;
22

3+
import com.titstory.heowc.component.ExcelReadComponent;
4+
import com.titstory.heowc.domain.Product;
5+
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
36
import org.junit.Test;
47
import org.junit.runner.RunWith;
8+
import org.springframework.beans.factory.annotation.Autowired;
59
import org.springframework.boot.test.context.SpringBootTest;
610
import org.springframework.test.context.junit4.SpringRunner;
711

12+
import java.io.File;
13+
import java.io.IOException;
14+
815
@RunWith(SpringRunner.class)
916
@SpringBootTest
1017
public class SpringBootExcelApplicationTests {
1118

19+
@Autowired
20+
ExcelReadComponent excelReadComponent;
21+
1222
@Test
13-
public void contextLoads() {
23+
public void test_readExcel() throws IOException, InvalidFormatException {
24+
File xlsxFile = new File("{path}\\test.xlsx");
25+
26+
excelReadComponent
27+
.readExcelToList(xlsxFile, Product::new)
28+
.forEach(System.out::println);
1429
}
1530

1631
}

0 commit comments

Comments
 (0)