parent
6de43fb1af
commit
5cd6c75bb7
@ -1,93 +1,27 @@
|
|||||||
package UnitTest.ImportExcel.Bean;
|
package UnitTest.ImportExcel.Bean;
|
||||||
|
|
||||||
import com.aspose.cells.*;
|
|
||||||
import com.dsideal.QingLong.Util.AsposeUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单元格vo
|
* 单元格vo
|
||||||
*/
|
*/
|
||||||
public class CellBean {
|
public class CellBean {
|
||||||
private String value = "";//值
|
private String value = "";//值
|
||||||
private String backgroundColor = "";//背景色
|
private String backgroundColor = "";//背景色
|
||||||
private String fontColor = "";//文字颜色
|
|
||||||
|
public String getValue() {
|
||||||
private String type="";
|
return value;
|
||||||
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();
|
|
||||||
|
|
||||||
int idx = comments.add(7, 3);
|
public void setValue(String value) {
|
||||||
Comment comment = comments.get(idx);
|
this.value = value;
|
||||||
//System.out.println(comment.getCommentShape().getFill());
|
|
||||||
comment.setNote("我是内容");
|
|
||||||
comment.setAuthor("黄海");
|
|
||||||
comment.getFont().setName("黑体");
|
|
||||||
// 设置批注的背景颜色为黄色
|
|
||||||
// 保存工作簿
|
|
||||||
workbook.save(path + "\\4.xlsx");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AsposeAddXiaLaKuang {
|
public String getBackgroundColor() {
|
||||||
//工作目录
|
return backgroundColor;
|
||||||
public static String path = "D:\\dsWork\\QingLong\\src\\main\\resource\\Excel\\";
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public void setBackgroundColor(String backgroundColor) {
|
||||||
//获取授权
|
this.backgroundColor = backgroundColor;
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue