parent
6de43fb1af
commit
5cd6c75bb7
@ -1,93 +1,27 @@
|
||||
package UnitTest.ImportExcel.Bean;
|
||||
|
||||
import com.aspose.cells.*;
|
||||
import com.dsideal.QingLong.Util.AsposeUtil;
|
||||
|
||||
/**
|
||||
* 单元格vo
|
||||
*/
|
||||
public class CellBean {
|
||||
private String value = "";//值
|
||||
private String backgroundColor = "";//背景色
|
||||
private String fontColor = "";//文字颜色
|
||||
|
||||
private String type="";
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static class AsposeAddCommet {
|
||||
//工作目录
|
||||
public static String path = "D:\\dsWork\\QingLong\\src\\main\\resource\\Excel\\";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
//获取授权
|
||||
AsposeUtil.getLicense();
|
||||
// 打开现有的工作簿
|
||||
Workbook workbook = new Workbook(path + "\\1.xlsx");
|
||||
Worksheet sheet = workbook.getWorksheets().get(0);
|
||||
//添加新的批注
|
||||
CommentCollection comments = sheet.getComments();
|
||||
comments.clear();
|
||||
* 单元格vo
|
||||
*/
|
||||
public class CellBean {
|
||||
private String value = "";//值
|
||||
private String backgroundColor = "";//背景色
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
int idx = comments.add(7, 3);
|
||||
Comment comment = comments.get(idx);
|
||||
//System.out.println(comment.getCommentShape().getFill());
|
||||
comment.setNote("我是内容");
|
||||
comment.setAuthor("黄海");
|
||||
comment.getFont().setName("黑体");
|
||||
// 设置批注的背景颜色为黄色
|
||||
// 保存工作簿
|
||||
workbook.save(path + "\\4.xlsx");
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static class AsposeAddXiaLaKuang {
|
||||
//工作目录
|
||||
public static String path = "D:\\dsWork\\QingLong\\src\\main\\resource\\Excel\\";
|
||||
public String getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
//获取授权
|
||||
AsposeUtil.getLicense();
|
||||
// 打开现有的工作簿
|
||||
Workbook workbook = new Workbook(path+"\\1.xlsx");
|
||||
// 获取第一个工作表
|
||||
Worksheet worksheet = workbook.getWorksheets().get(0);
|
||||
// 创建下拉列表
|
||||
Validation validation = worksheet.getValidations().get(worksheet.getValidations().add());
|
||||
validation.setType(ValidationType.LIST);
|
||||
validation.setFormula1("男,女,未知"); // 设置下拉列表的选项
|
||||
// 设置下拉列表的范围
|
||||
CellArea area = new CellArea();
|
||||
area.StartRow = 1; // 从第2行开始
|
||||
area.EndRow = 29; // 到第30行结束
|
||||
area.StartColumn = 0; // 第一列
|
||||
validation.addArea(area);
|
||||
// 应用到工作表
|
||||
worksheet.getValidations().add(validation);
|
||||
// 保存工作簿
|
||||
workbook.save(path+"\\3.xlsx");
|
||||
}
|
||||
public void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue