「java批注excel」Java快速注释

博主:adminadmin 2023-01-27 08:33:09 626

今天给各位分享java批注excel的知识,其中也会对Java快速注释进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java poi 操作excel 问题

首先回答你第一个问题:

读取注解代码如下:

Comment comment = sheet.getRow(7).getCell(5, Row.CREATE_NULL_AS_BLANK).getCellComment();

根据批注定位单元格做不到。。。

java里面如何把excel单元格中批注的图片读出来,然后存入数据库中,急急急

Comment.Text End If 如果该单元是没有批注的,这程序会出错,Comment不能放在ISNULL()里, 应该判断单元有没有批注,查找所有类型为带有注释的单元格子即可,存入数据库。

java怎么用注解操作excel

可以考虑先建一个空的excel

写一条数据就完成对excel的编辑.

每次循环重新读取这个excel 重复编辑这个excel

这样效率可能不行,不过你要程序中断也要写入一些数据

JAVA导出EXCEL表格的备注怎么写

public static void main(String[] args) throws IOException {

//创建工作簿对象

HSSFWorkbook wb=new HSSFWorkbook();

//创建工作表对象

HSSFSheet sheet=wb.createSheet("我的工作表");

//创建绘图对象

HSSFPatriarch p=sheet.createDrawingPatriarch();

//创建单元格对象,批注插入到4行,1列,B5单元格

HSSFCell cell=sheet.createRow(4).createCell(1);

//插入单元格内容

cell.setCellValue(new HSSFRichTextString("批注"));

//获取批注对象

//(int dx1, int dy1, int dx2, int dy2, short col1, int row1, short col2, int row2)

//前四个参数是坐标点,后四个参数是编辑和显示批注时的大小.

HSSFComment comment=p.createComment(new HSSFClientAnchor(0,0,0,0,(short)3,3,(short)5,6));

//输入批注信息

comment.setString(new HSSFRichTextString("插件批注成功!插件批注成功!"));

//添加作者,选中B5单元格,看状态栏

comment.setAuthor("toad");

//将批注添加到单元格对象中

cell.setCellComment(comment);

//创建输出流

FileOutputStream out=new FileOutputStream("writerPostil.xls");

wb.write(out);

//关闭流对象

out.close();

}

java poi 去读excel 怎么读取批注里内容

HSSFWorkbook wb = null;

POIFSFileSystem fs = null;

try {

fs = new POIFSFileSystem(new FileInputStream("e:\\workbook.xls"));

wb = new HSSFWorkbook(fs);

} catch (IOException e) {

e.printStackTrace();

}

HSSFSheet sheet = wb.getSheetAt(0);

HSSFRow row = sheet.getRow(0);

HSSFCell cell = row.getCell(0);

String msg = cell.getStringCellValue();

System.out.println(msg);

JAVA怎么向Excel中写入批量数据?

public static void drawExcel(HSSFWorkbook wb, String sheetName, String title, int n, List? exlList, int[] index){

ListObject[] exList =(ListObject[])exlList;

int len = exList.get(0).length;

// 创建一个sheet表单

HSSFSheet sheet = wb.createSheet(sheetName);

Region region = null;

//样式

HSSFCellStyle cellStyle1 = setStyleBorder(wb);

HSSFCellStyle cellStyle2 = setStyleFontBorder(wb);

// 创建标题行

HSSFRow row = sheet.createRow(0);

row.setHeight((short)500);

// 创建单元格

HSSFCell cell = null;

if(title != null !"".equals(title)){

region = new Region(0, (short)0, 0, (short)(len- 1));

sheet.addMergedRegion(region);

cell = row.createCell(0);

// 标题写入单元格

cell.setCellValue(title);

cell.setCellStyle(setStyleFontSize(wb, 18));

}else{

n = n - 1;

}

NumberFormat formatter = NumberFormat.getNumberInstance();

formatter.setMaximumFractionDigits(8);

//合计信息

Double[] sum = new Double[len];

Object[] s = null;

for(int i = 0; i exList.size(); i++){

s = exList.get(i);

row = sheet.createRow(i + n);

// 创建数据行

for(int j = 0; j s.length; j++){

cell = row.createCell(j);

/***

* jobin create

*/

if(s[j] instanceof Integer || s[j] instanceof Float){

cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

}else{

cell.setCellType(HSSFCell.CELL_TYPE_STRING);

}

if(!StringUtils.isNotEmpty(s[j])){

cell.setCellStyle(cellStyle1);

continue;

}

String[] rs = null;

int l = 3000;

if(i == 0 s[j].toString().indexOf(",") 0){

rs = s[j].toString().split(",");

cell.setCellValue(rs[0]);

l = Integer.parseInt(rs[1]);

}else{

cell.setCellValue(s[j].toString());

}

if(i == 0){

cell.setCellStyle(cellStyle2);

//设置列宽

// if(j == 0){

sheet.setColumnWidth(j, l);

// }else if(j == s.length -1){

// sheet.setColumnWidth(j, 5000);

// }else{

// sheet.setColumnWidth(j, 3000);

// }

}else{

cell.setCellStyle(cellStyle1);

//合计统计

if(index != null){

for(int in : index){

if(in == j){

if(sum[in] == null) sum[in] = 0.0;

sum[in] += Double.parseDouble(s[j].toString());

}

}

}

}

}

}

//合计信息

if(index != null){

region = new Region(exList.size() + 1, (short)0, exList.size() + 1, (short)(index[0]-1));

sheet.addMergedRegion(region);

row = sheet.createRow(exList.size() + n);

for(int i = 0; i sum.length; i++){

cell = row.createCell(i);

cell.setCellStyle(cellStyle2);

if(i == 0){

cell.setCellValue("合计");

}else if(sum[i] != null){

cell.setCellValue(formatter.format(sum[i]).replace(",", ""));

}

}

}

}

核心代码,我项目上使用的

java批注excel的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于Java快速注释、java批注excel的信息别忘了在本站进行查找喔。