首页 养生问答 疾病百科 养生资讯 女性养生 男性养生

poi读取Excel,之后生成另一个Excel

发布网友 发布时间:2022-04-23 15:30

我来回答

1个回答

热心网友 时间:2022-05-11 22:03

File fi=new File("D:\\20110221144419.xls");
System.out.println(11);
//创建一个工作薄
POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(fi));
HSSFWorkbook wb=new HSSFWorkbook(fs);
int i = 0;
HSSFSheet hsheet = wb.getSheetAt(i);
if(hsheet==null)
hsheet = wb.createSheet("Sheet"+(i)+"");
HSSFPatriarch patriarch = hsheet.createDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(0,0,512,255,(short) 1,1,(short)10,20);
patriarch.createPicture(anchor , wb.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));
fileOut= new FileOutputStream(fi);
//写入excel文件
wb.write(fileOut);
fileOut.close();追问fileOut和byteArrayOut会报错。。

热心网友 时间:2022-05-11 22:03

File fi=new File("D:\\20110221144419.xls");
System.out.println(11);
//创建一个工作薄
POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(fi));
HSSFWorkbook wb=new HSSFWorkbook(fs);
int i = 0;
HSSFSheet hsheet = wb.getSheetAt(i);
if(hsheet==null)
hsheet = wb.createSheet("Sheet"+(i)+"");
HSSFPatriarch patriarch = hsheet.createDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(0,0,512,255,(short) 1,1,(short)10,20);
patriarch.createPicture(anchor , wb.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));
fileOut= new FileOutputStream(fi);
//写入excel文件
wb.write(fileOut);
fileOut.close();追问fileOut和byteArrayOut会报错。。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com