Results 1 to 1 of 1
- 01-12-2014, 10:57 AM #1
Member
- Join Date
- Jan 2014
- Posts
- 1
- Rep Power
- 0
Print Preview does not work in SWT OLE Excel
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.getCo lor(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();
}
}
Similar Threads
-
Excel - Print Titles - jxl
By mermaid in forum New To JavaReplies: 5Last Post: 05-04-2012, 04:48 PM -
Need to read an excel file and print it as an xml
By syntel in forum Advanced JavaReplies: 1Last Post: 08-10-2011, 01:58 PM -
Build (RUN) and preview the work?
By crAzygEEk in forum New To JavaReplies: 1Last Post: 07-25-2010, 12:54 PM -
looking for print preview library
By j2me64 in forum AWT / SwingReplies: 3Last Post: 03-17-2010, 01:14 PM -
Print the text file and print preview them
By Java Tip in forum java.awtReplies: 0Last Post: 06-22-2008, 11:04 PM
Bookmarks