Hi, I have a problem in the POI for Excel. I add an OLEObjects "Forms.CommandButton.1" in the excel file. Please refer to the Macro recorded. “ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=35.25, Top:=171, Width:=100.5, Height:= 28.5).Select”. Now I add some rows before the CommandButton, but it does not move down. It still stay in Left:=35.25, Top:=171. When we manual insert a new row in the excel file, the CommandButton will move to the next. Please tell to me how to do use the POI. Please help me. Thanks! Best Regards, Jianfeng Jiang
I'm not sure you're actually using poi... Please re-open the bug if you can supply the code that's failing
Created attachment 22724 [details] the not correct result
for(int recorderNo=1;recorderNo<=2;recorderNo++){ String fileName = generateFileName(examYr,examLvlCd, examSeriesCd, recordTo.getValue("SUBJ_CD").toString(), recordTo.getValue("PAPER_NO").toString(), recordTo.getValue("MOA_CD").toString(), formCd, String.valueOf(markerNo), String.valueOf(recorderNo)); ExcelWriter ew = new ExcelWriter(templateFile1,fileName); if(qtnNoList != null && qtnNoList.size() > 0){ ew.setIntValue(0, 2, 4, examYr, ew.getStyle(0, 2, 4)); StringBuffer subject = new StringBuffer(); subject.append(recordTo.getValue("SUBJ_CD")).append(" ").append(recordTo.getValue("SUBJ_NM")); ew.setStringValue(0, 4, 4, subject.toString(),ew.getStyle(0, 4, 4)); ew.setIntValue(0, 5, 4, recordTo.getValue("PAPER_NO").toString(), ew.getStyle(0, 5, 4)); ew.setIntValue(0, 6, 4, String.valueOf(markerNo),ew.getStyle(0, 6, 4)); ew.setIntValue(0, 7, 4, String.valueOf(recorderNo),ew.getStyle(0, 7, 4)); HSSFCellStyle s1 = ew.getStyle(0, 23, 3); HSSFCellStyle s2 = ew.getStyle(0, 23, 4); HSSFCellStyle s3 = ew.getStyle(0, 23, 5); HSSFCellStyle s4 = ew.getStyle(0, 23, 6); for(int i=23;i<23+qtnNoList.size();i++){ HSSFRow row = ew.createRowWithShift(0, i); row.createCell((short)3).setCellStyle(s1); ew.setStringValue(0, i, 3, qtnNoList.get(i-23).getValue("QTN_NO").toString(),s1); row.createCell((short)4).setCellStyle(s2); row.createCell((short)5).setCellStyle(s3); row.createCell((short)6).setCellStyle(s4); } ew.deleteRow(0, ew.getRow(0, 23+qtnNoList.size())); } ew.save(); } The above is my code for createRowWithShift rows. but the button did not move down. Please check with the attached files(the incorrect result)
shiftRows won't update everything. You'll need to manually move your buttons
In the POI how to getb the buttons handle. Can you give a sample? Thanks!