Bug 46002 - POI operate the excel OLEObjects Forms.CommandButton.1
Summary: POI operate the excel OLEObjects Forms.CommandButton.1
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.1-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-14 05:08 UTC by jianfeng
Modified: 2008-10-16 18:03 UTC (History)
0 users



Attachments
the not correct result (116.00 KB, application/octet-stream)
2008-10-14 05:32 UTC, jianfeng
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jianfeng 2008-10-14 05:08:49 UTC
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
Comment 1 Nick Burch 2008-10-14 05:13:08 UTC
I'm not sure you're actually using poi...

Please re-open the bug if you can supply the code that's failing
Comment 2 jianfeng 2008-10-14 05:32:20 UTC
Created attachment 22724 [details]
the not correct result
Comment 3 jianfeng 2008-10-14 05:45:43 UTC
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)
Comment 4 Nick Burch 2008-10-16 06:45:50 UTC
shiftRows won't update everything. You'll need to manually move your buttons
Comment 5 jianfeng 2008-10-16 18:03:35 UTC
In the POI how to getb the buttons handle. Can you give a sample? Thanks!