main
黄海 2 years ago
parent 014dad882d
commit 0ddece912d

@ -1,36 +0,0 @@
package UnitTest.ImportExcel;
import com.dsideal.QingLong.Util.PoiUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class AddComment {
//工作目录
public static String path = "D:\\dsWork\\QingLong\\src\\main\\resource\\Excel\\";
public static void main(String[] args) throws Exception {
//学校上传的Excel
String source = path + "1.xlsx";
//要进行标注的行和列
int r = 5, c = 6;//第6行第7列
//对文件进行校验,标注
try (FileInputStream fileIn = new FileInputStream(source);
Workbook workbook = new XSSFWorkbook(fileIn)) {
//在指定单元格上添加背景黄色+标注提示信息
Cell cell = workbook.getSheetAt(0).getRow(r).getCell(c);
PoiUtil.addComment(workbook, cell, "此单元格应该是非空的!");
// 保存
FileOutputStream fileOut = new FileOutputStream(source);
workbook.write(fileOut);
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -133,6 +133,6 @@ public class CreateTableAndTemplate {
//关闭Excel
wb.close();
//输出
System.out.println("恭喜,所有的表格创建成功!");
System.out.println("恭喜,数据库表创建成功,共创建" + kvList.size() + "个。");
}
}

Loading…
Cancel
Save