发布网友 发布时间: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会报错。。