mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -159,13 +159,11 @@ public class WorkbookUtil {
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public static Workbook createBook(boolean isXlsx) {
|
||||
Workbook workbook;
|
||||
if (isXlsx) {
|
||||
workbook = new XSSFWorkbook();
|
||||
} else {
|
||||
workbook = new org.apache.poi.hssf.usermodel.HSSFWorkbook();
|
||||
try {
|
||||
return WorkbookFactory.create(isXlsx);
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package cn.hutool.poi.excel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WorkbookUtilTest {
|
||||
|
||||
@Test
|
||||
public void createBookTest(){
|
||||
Workbook book = WorkbookUtil.createBook(true);
|
||||
Assert.assertNotNull(book);
|
||||
|
||||
book = WorkbookUtil.createBook(false);
|
||||
Assert.assertNotNull(book);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user