import com.jniwrapper.win32.automation.types.Variant; import com.jniwrapper.win32.excel._Workbook; import com.jniwrapper.win32.jexcel.ui.JWorkbook;
import javax.swing.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent;
/** * This sample demonstrates how to protect the workbook structure. * Sample requires jexcel-full.jar in classpath */ public class WorkbookProtection { public static void main(String[] args) throws Exception { final JWorkbook _workbook = new JWorkbook();
final JFrame frame = new JFrame(); frame.setContentPane(_workbook); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (_workbook != null) { _workbook.close(); } } }); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(800, 800); frame.setVisible(true);
final _Workbook workbookPeer = _workbook.getWorkbook().getNativePeer(); _workbook.getApplication().getOleMessageLoop().doInvokeLater(new Runnable() { public void run() { Variant missing = Variant.createUnspecifiedParameter(); workbookPeer.protect( missing, new Variant(true), missing); } });
} } |