• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Print Preview does not work in SWT OLE Excel

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

My project need embed Excel to view and print excel documents. I'm using SWT OLE and facing to a problem that print command of OLE Excel works perfectly but print preview command does nothing. Please, help me to debug this?

Here are my code:

package oletest;

import java.io.File;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleControlSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

public class EmbeddingTest {

public static void main(final String[] args) {

Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(592, 426);

OleFrame frame = new OleFrame(shell, SWT.NONE);
frame.setBounds(10, 10, 391, 185);
final OleControlSite controlSite = new OleControlSite(frame, SWT.BORDER, new File("C:\\Book1.xlsx"));
controlSite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
controlSite.exec(OLE.OLECMDID_HIDETOOLBARS, OLE.OLECMDEXECOPT_DODEFAULT, null, null);

Button prinButton = new Button(shell, SWT.NONE);
prinButton.setText("Print");
prinButton.setBounds(115, 327, 98, 25);
prinButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
controlSite.exec(OLE.OLECMDID_PRINT, OLE.OLECMDEXECOPT_PROMPTUSER, null, null);
}
});
Button prinPreviewButton = new Button(shell, SWT.NONE);
prinPreviewButton.setText("Print Preview");
prinPreviewButton.setBounds(219, 327, 98, 25);
prinPreviewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
controlSite.exec(OLE.OLECMDID_PRINTPREVIEW, OLE.OLECMDEXECOPT_PROMPTUSER, null, null);
}
});
shell.open();
while (!shell.isDisposed()) {

if (!display.readAndDispatch()) {
display.sleep();
}
}

display.dispose();
}

}
 
reply
    Bookmark Topic Watch Topic
  • New Topic