⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listtypes.java

📁 使用JCom的时候
💻 JAVA
字号:
import jp.ne.so_net.ga2.no_ji.jcom.*;
import java.io.*;
import java.util.*;
import java.text.DateFormat;

public class ListTypes {

	static String tab = "\t";
	void listTypes(ITypeLib typeLib) {
		try {
			// 僼傽僀儖傪僆乕僾儞(CSV偱曐懚偟偰偄傞偲偙傠偑丄怱憺偄墘弌)
			PrintWriter out = 
					new PrintWriter(new BufferedWriter(new FileWriter("ExcelTypes.csv")));

			int infocount = typeLib.getTypeInfoCount();
			for(int i=0; i<infocount; i++) {
				ITypeInfo info = typeLib.getTypeInfo(i);
				out.print(info.getDocumentation(-1)[0]+tab);
				ITypeInfo.TypeAttr attr = info.getTypeAttr();
				out.print(attr.getIID()+tab);
				switch(attr.getTypeKind()) {
					case ITypeInfo.TypeAttr.TKIND_ENUM:			out.print("TKIND_ENUM");		break;
					case ITypeInfo.TypeAttr.TKIND_RECORD:		out.print("TKIND_RECORD");		break;
					case ITypeInfo.TypeAttr.TKIND_MODULE:		out.print("TKIND_MODULE");		break;
					case ITypeInfo.TypeAttr.TKIND_INTERFACE:	out.print("TKIND_INTERFACE");	break;
					case ITypeInfo.TypeAttr.TKIND_DISPATCH:		out.print("TKIND_DISPATCH");	break;
					case ITypeInfo.TypeAttr.TKIND_COCLASS:		out.print("TKIND_COCLASS");		break;
					case ITypeInfo.TypeAttr.TKIND_ALIAS:		out.print("TKIND_ALIAS");		break;
					case ITypeInfo.TypeAttr.TKIND_UNION:		out.print("TKIND_UNION");		break;
				}
				out.println(tab+"Func="+attr.getFuncs()+tab+"Var="+attr.getVars());
			}
			out.close();
		}
		catch(Exception e) { e.printStackTrace(); }
	}

	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(昞帵偟側偄)

			ITypeInfo typeInfo = xlApp.getTypeInfo();
			ITypeLib typeLib = typeInfo.getTypeLib();
			ListTypes listTypes = new ListTypes();
			listTypes.listTypes(typeLib);
			xlApp.invoke("Quit", null);
			System.out.println("偛惷挳丄偁傝偑偲偆偛偞偄傑偟偨丅");
		}
		catch(Exception e) { e.printStackTrace(); }
		finally { rm.release(); }
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -