Skip to content

Commit

Permalink
fix:mail send fail apache#2345 (apache#2346)
Browse files Browse the repository at this point in the history
Co-authored-by: dailidong <[email protected]>
  • Loading branch information
wen-hemin and davidzollo authored Mar 31, 2020
1 parent 4db2ac2 commit f60edc8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
Expand Down Expand Up @@ -102,7 +103,11 @@ public static void genExcelFile(String content,String title,String xlsFilePath){

for (int i = 0; i < headerList.size(); i++) {
sheet.setColumnWidth(i, headerList.get(i).length() * 800);
}

File file = new File(xlsFilePath);
if (!file.exists()) {
file.mkdirs();
}

//setting file output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ public void testGenExcelFile() {
ExcelUtils.genExcelFile(incorrectContent1, title, xlsFilePath);

}

/**
* Test GenExcelFile (check directory)
*/
@Test
public void testGenExcelFileByCheckDir() {
ExcelUtils.genExcelFile("[{\"a\": \"a\"},{\"a\": \"a\"}]", "t", "/tmp/xls");
File file = new File("/tmp/xls" + Constants.SINGLE_SLASH + "t" + Constants.EXCEL_SUFFIX_XLS);
file.delete();
}
}

0 comments on commit f60edc8

Please sign in to comment.