📄 testerror.java
字号:
import jp.ne.so_net.ga2.no_ji.jcom.*;
public class testError {
public static void main(String[] args) throws Exception {
ReleaseManager rm = new ReleaseManager();
try {
System.out.println("EXCEL傪婲摦拞...");
IDispatch xlApp = new IDispatch(rm, "Excel.Application"); // EXCEL杮懱
xlApp.put("Visible", new Boolean(true)); // '僨僼僅儖僩偼False(昞帵偟側偄)
IDispatch xlBooks = (IDispatch)xlApp.get("Workbooks");
IDispatch xlBook = (IDispatch)xlBooks.method("Add",null); // 怴偟偄僽僢僋傪嶌惉
IDispatch xlSheet = (IDispatch)xlApp.get("ActiveSheet");
Object[] arglist = new Object[1];
arglist[0] = "A1";
IDispatch xlRange = (IDispatch)xlSheet.get("Range",arglist);
xlRange.put("Value","=1/0");
Object value = xlRange.get("Value");
System.out.println("value="+value);
if (value != null) System.out.println("value.getClass()="+value.getClass());
System.out.println("僄儔乕偺応崌丄VariantError傪曉偡傛偆偵偟傑偟偨丅");
System.out.println("[Enter]傪墴偟偰偔偩偝偄丅");
System.in.read();
Object[] arglist3 = new Object[3];
arglist3[0] = new Boolean(false);
arglist3[1] = null;
arglist3[2] = new Boolean(false);
xlBook.method("Close", arglist3);
xlApp.method("Quit", null);
}
catch(Exception e) { e.printStackTrace(); }
finally { rm.release(); }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -