/* $Id: FXscrExcel.java,v 1.3 2011/05/27 15:17:21 afix Exp $
* $Revision: 1.3 $
******************************************************************************
* $Log: FXscrExcel.java,v $
* Revision 1.3 2011/05/27 15:17:21 afix
* Change: add functions...
*
* Revision 1.2 2011/05/23 11:22:50 afix
* Change: more functions.
*
* Revision 1.1 2011/05/19 13:04:38 afix
* Cleanups.
*
******************************************************************************
*/
package fix.libs.jacob.scr;
import com.jacob.com.*;
import fix.libs.jacob.*;
import fix.scr.comp.*;
import fix.scr.engine.*;
import fix.std.base.*;
import fix.std.tools.*;
import java.util.*;
/** The class <code>FXscrExcel</code> provides system functions to the script engine. Some of the
* function here need a system object like a process handle.<br>
* The command name is <code><b>System</b></code>.
*
******************************************************************************
* <dl compact>
* <dt><b> Project: </b></dt><dd> jarScript </dd>
* <dt><b> Author: </b></dt><dd> Axel Fix </dd>
* <dt><b> Created: </b></dt><dd> 18.06.2010 </dd>
* <dt><b> Revision: </b></dt><dd> $Revision: 1.3 $ </dd>
* </dl>
******************************************************************************
*/
public final class FXscrExcel extends FXscrCompBaseA
{
private static final String CLZ = "Excel";
private static final String KEY = FXscrExcel.class.getSimpleName();
private static final String DSP_RANGE = "Range";
private static final String DSP_VALUE = "Value";
enum enTransl implements FXbaseEnumTrlI
{
CLASS("Excel functions. "),
INTRO("Documentation of %0 object. This object provides a number of\nstatic functions to access Excel files via COM.\n" +
"No contructor exist!"),
FUN_RECORD( "Recording:\n----------"),
FUN_REC_START(" recStart(fnm[,ms]): starts recording into the specified file and returns the handle for recStop()"),
FUN_REC_STOP( " recStop(hnd): stop recording at the specified record handle"),
FUN_REC_VOL( " recVolume(hnd, v): set the recording volume"),
FUN_PLAY( "Playing:\n--------"),
FUN_PLY_START(" play(fnm[,ms]): starts playing the specified file and returns the handle for playStop()"),
FUN_PLY_LOOP( " playLoop(fnm[,ms]): starts playing the specified file in a loop and returns the handle for playStop()"),
FUN_PLY_STOP( " playStop(hnd): stop playing at the specified play handle"),
FUN_PLY_VOL( " playVolume(hnd, v): set the playing volume"),
FUN_CALC( "Calculation:\n-----------"),
FUN_CLC_PESQ( " pesqTest(fr,ft): calculates PESQ values of reference and test file\n" +
" returns a double vector with the results"),
;
enTransl(String t) { FXbaseTranslator.addDefault(KEY, name(), t); }
public String key0() { return KEY; }
public String text(Object... p) { return new FXbaseTranslator(KEY, name(), p).string(); }
};
public static abstract class XlsElement
{
XlsElement(Dispatch d) { _mDsp = d; }
public Dispatch getDispatch() { return _mDsp; }
protected final Dispatch _mDsp;
};
public static final class WorkBook extends XlsElement
{
WorkBook(Dispatch d) { super(d); }
};
public static final class Sheet extends XlsElement
{
Sheet(Dispatch d) { super(d); }
};
public abstract class ShapeA extends XlsElement
{
ShapeA(Dispatch d) { super(d); }
public final void copy() throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspCall(_mHnd, _mDsp, "Copy");
}
public final void copyPic() throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspCall(_mHnd, _mDsp, "CopyPicture");
}
public final void remove() throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspCall(_mHnd, _mDsp, "Delete");
}
public final void setRect(int x, int y, int w, int h) throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspPut(_mHnd, _mDsp, "Left", x);
FXjacobCtrl.ref().dspPut(_mHnd, _mDsp, "Top", y);
if (w > 0)
FXjacobCtrl.ref().dspPut(_mHnd, _mDsp, "Width", w);
if (h > 0)
FXjacobCtrl.ref().dspPut(_mHnd, _mDsp, "Height",h);
}
}
public final class Shape extends ShapeA
{
Shape(Dispatch d) { super(d); }
public void setText(String txt) throws FXbaseThrow
{
_checkState();
Dispatch d = (Dispatch)FXjacobCtrl.ref().dspGet(_mHnd, _mDsp, "DrawingObject");
FXjacobCtrl.ref().dspPut(_mHnd, d, "Text", txt);
}
};
public final class Chart extends ShapeA
{
Chart(Dispatch d) { super(d); }
};
/** Creates a new instance of FXscrExcel */
private FXscrExcel() { super(); }
public static void register()
{
if (_sProto == null)
_sProto = new FXscrExcel();
FXscrCompBaseReg.registerComp(_sProto);
}
public static FXscrCompBaseA install(FXscrEngine vm)
{
if (_sProto == null)
_sProto = new FXscrExcel();
FXscrExcel scs = new FXscrExcel();
vm.installComp(scs);
return scs;
}
public String clazz() { return CLZ; }
protected FXscrCompBaseA _prototype() { return null; }
protected String _classHelp() { return enTransl.CLASS.text(); }
protected void _destroy() {}
public void help()
{
_help(enTransl.values());
}
public FXjacobCtrl.Data comHandle()
{
return _mHnd;
}
public void init() throws FXbaseThrow
{
_checkEngState();
if (_mHnd != null)
destroy();
_mHnd = FXjacobCtrl.ref().open("Excel.application");
}
public void destroy()
{
if (_mHnd == null)
return;
try
{ quit(); }
catch (FXjacobThrow x)
{ x.getExtErrStr(); }
FXjacobCtrl.ref().close(_mHnd);
_mHnd = null;
}
public void setVisible() throws FXbaseThrow
{
setVisible(true);
}
public void setVisible(boolean en) throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspPut(_mHnd, "Visible", true);
}
public void quit() throws FXjacobThrow
{
FXjacobCtrl.ref().dspCall(_mHnd, "Quit");
}
/**
*
* @param fnm
* @return workbook dispatch handle
*/
public WorkBook wbOpen(String fnm) throws FXbaseThrow
{
_checkState();
Dispatch wbs = FXjacobCtrl.ref().getProperty(_mHnd, "Workbooks");
return new WorkBook((Dispatch)FXjacobCtrl.ref().dspCall(_mHnd, wbs, "Open", fnm));
}
public void wbSave(WorkBook wb) throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspCall(_mHnd, wb.getDispatch(), "Save");
}
public void wbClose(WorkBook wb) throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspCall(_mHnd, wb.getDispatch(), "Close", false);
}
public void wbSelect(WorkBook wb) throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspCall(_mHnd, wb.getDispatch(), "Activate"); // Select
}
public Sheet sheet(WorkBook wb, String snm) throws FXbaseThrow
{
_checkState();
Dispatch shs = (Dispatch)FXjacobCtrl.ref().dspGet(_mHnd, wb.getDispatch(), "Worksheets");
Sheet s = new Sheet((Dispatch)FXjacobCtrl.ref().dspCall(_mHnd, shs, "Item", snm));
sheetSelect(s);
return s;
}
public void sheetSelect(Sheet s) throws FXbaseThrow
{
_checkState();
FXjacobCtrl.ref().dspCall(_mHnd, s.getDispatch(), "Select");
}
public int sheetNumRows(Sheet s) throws FXbaseThrow
{
_checkState();
Dispatch d1 = (Dispatch)FXjacobCtrl.ref().dspGet(_mHnd, s.getDispatch(), "UsedRange");
Dispatch d2 = (Dispatch)FXjacobCtrl.ref().dspGet(_mHnd, d1
jacob_example2.zip_jacob_jacob example
版权申诉
8 浏览量
2022-09-24
17:06:23
上传
评论
收藏 9KB ZIP 举报
寒泊
- 粉丝: 76
- 资源: 1万+
最新资源
- Screenrecording_20240509_230927_20240509_231814.mp3
- 基于Dart的复健科东方国际咖啡馆管理系统设计源码
- Python 常用标准库模块 1
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例典型案例:万达消防系统图
- 一篇精雕细琢的 Python 进阶总结
- man,what can I say;
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例第四篇:电缆分接箱部分
- 一篇精雕细琢的 Python 入门总结
- 基于 vxe-table 表格的适配插件,用于兼容 ant-design-vue 组件库
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例第三部分:开关站通用设计模块(24张)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈