2014-07-09 5 views
4

inplace 편집을 위해 OLE 프레임을 사용하여 응용 프로그램을 설치했습니다. 모두 Word 파일에는 적합하지만 Excel 저장은 작동하지 않습니다. Excel 응용 프로그램의 저장 단추가 회색으로 표시됩니다 (OLE가 아닌 Excel이 열려있을 때). 회색으로 표시되지 않으면 "새로 고침"(독일어로 표시됨)이지만 저장하지 않습니다. 어떤 종류의 오류 메시지도 표시되지 않습니다.OleFrame에서 Excel 파일을 저장할 수 없습니다.

OleControlSite#save(File, boolean) 작동하지만 고객에게 Excel 저장 버튼을 클릭 할 수없는 이유를 설명 할 수 없으므로 어떻게 든 고쳐야합니다.

public class OleDemoDialog extends Dialog { 

public static void main(String[] args) { 
    OleDemoDialog dialog = new OleDemoDialog(new Shell()); 
    dialog.open(); 
} 

protected OleDemoDialog(Shell parentShell) { 
    super(parentShell); 
    setShellStyle(getShellStyle()| SWT.SHELL_TRIM); 
} 

@Override 
protected Control createDialogArea(Composite parent) { 
    OleFrame oleFrame = new OleFrame(parent, SWT.CLIP_CHILDREN); 
    oleFrame.setBackground(JFaceColors.getBannerBackground(parent 
      .getDisplay())); 
    oleFrame.setLayoutData(new GridData(GridData.FILL_BOTH)); 

    OleControlSite oleControlSite = new OleControlSite(oleFrame, SWT.NONE, 
      new File("Mappe1.xlsx")); 
    oleControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); 

    return oleFrame; 
} 

@Override 
protected Point getInitialSize() { 
    return new Point(600, 600); 
} 
} 
+0

본 적이 있습니까? http://www.aspose.com/docs/display/slidesnet/Working+with+OLE+Object+Frames? – HellBaby

+0

@HellBaby 지금했는데 설명 된 버그에 대한 언급이 없습니다. –

답변

-1

저장 엑셀 파일 사용 OleFrame :

작은 데모

문제를 재현합니다.

OleClientSite clientSite.save(new File("D:\\JavaBooks.xlsx"), true); 

나는이 예제가 유용 바랍니다.

import java.io.*; 
import org.eclipse.swt.*; 
import org.eclipse.swt.events.*; 
import org.eclipse.swt.layout.*; 
import org.eclipse.swt.ole.win32.*; 
import org.eclipse.swt.widgets.*; 

public class OleDemoDialog { 

    OleClientSite clientSite; 
    OleFrame oleFrame; 

    public static void main(String[] args) { 
     Display display = new Display(); 
     OleDemoDialog example = new OleDemoDialog(); 
     example.open(display); 
    } 

    public void open(Display display) { 
     Shell shell = new Shell(display); 
     shell.setText("OleDemoDialog Example"); 
     shell.setLayout(new FillLayout()); 

     Composite parent = new Composite(shell, SWT.NONE); 
     parent.setLayout(new GridLayout(4, true)); 

     Composite buttons = new Composite(parent, SWT.NONE); 
     buttons.setLayout(new GridLayout()); 
     GridData gridData = new GridData(SWT.BEGINNING, SWT.FILL, false, false); 
     buttons.setLayoutData(gridData); 

     Composite displayArea = new Composite(parent, SWT.BORDER); 
     displayArea.setLayout(new FillLayout()); 
     displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); 

     Button openButton = new Button(buttons, SWT.NONE); 
     openButton.setText("Open file"); 
     openButton.addSelectionListener(new SelectionAdapter() { 
      public void widgetSelected(SelectionEvent e) { 
       //new File("your File_Path.xlsx ") 
       try { 
        clientSite = new OleClientSite(oleFrame, SWT.NONE, "Excel.Sheet", new File("D:\\JavaBooks.xlsx")); 
       } catch (SWTException error) {error.printStackTrace();} 
       if (clientSite != null) 
        clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); 
      } 
     }); 
     new Label(buttons, SWT.NONE); 

     Button excelButton = new Button(buttons, SWT.NONE); 
     excelButton.setText("Save"); 
     excelButton.addSelectionListener(new SelectionAdapter() { 
      public void widgetSelected(SelectionEvent e) { 

       clientSite.save(new File("D:\\JavaBooks.xlsx"), true); 
       System.out.println("save.."); 
      } 
     }); 

     oleFrame = new OleFrame(displayArea, SWT.NONE); 
     shell.setSize(800, 600); 
     shell.open(); 

     while (!shell.isDisposed()) { 
      if (!display.readAndDispatch()) 
       display.sleep(); 
     } 
    } 
} 
+0

이 문제는 전혀 해결되지 않습니다. –

+0

@Steffi S.이 답변에 만족하지 않습니다 ... –

관련 문제