com.jacob.com.Dispatch Java Examples

The following examples show how to use com.jacob.com.Dispatch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OfficeHtmlUtil.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
 * EXCEL转HTML
 * 
 * @param xlsfile
 *            EXCEL文件全路径
 * @param htmlfile
 *            转换后HTML存放路径
 */
public void excelToHtml(String xlsfile, String htmlfile) {
	ActiveXComponent app = new ActiveXComponent("Excel.Application"); // 启动excel
	try {
		app.setProperty("Visible", new Variant(false));
		Dispatch excels = app.getProperty("Workbooks").toDispatch();
		Dispatch excel = Dispatch.invoke(excels, "Open", Dispatch.Method, new Object[] { xlsfile, new Variant(false), new Variant(true) }, new int[1]).toDispatch();
		Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] { htmlfile, new Variant(EXCEL_HTML) }, new int[1]);
		Variant f = new Variant(false);
		Dispatch.call(excel, "Close", f);
		org.jeecgframework.core.util.LogUtil.info("wordtohtml转换成功");
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		app.invoke("Quit", new Variant[] {});
	}
}
 
Example #2
Source File: IiTunes.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the currently targetd track.
 *
 * @return An ITTrack object corresponding to the currently targeted track.
 * Will be set to NULL if there is no currently targeted track.
 */
public IITTrack getCurrentTrack() {
	Variant variant = iTunes.getProperty("CurrentTrack");
	if (variant.isNull()) {
		return null;
	}
	Dispatch item = variant.toDispatch();
	IITTrack track = new IITTrack(item);
	if (track.getKind() == IITTrackKind.ITTrackKindFile) {
		return new IITFileOrCDTrack(item);
	} else if (track.getKind() == IITTrackKind.ITTrackKindCD) {
		return new IITFileOrCDTrack(item);
	} else if (track.getKind() == IITTrackKind.ITTrackKindURL) {
		return new ITURLTrack(item);
	} else {
		return track;
	}
}
 
Example #3
Source File: OfficeHtmlUtil.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
 * WORD转HTML
 * 
 * @param docfile
 *            WORD文件全路径
 * @param htmlfile
 *            转换后HTML存放路径
 */
public void wordToHtml(String docfile, String htmlfile) {
	ActiveXComponent app = new ActiveXComponent("Word.Application"); // 启动word
	try {
		app.setProperty("Visible", new Variant(false));
		Dispatch docs = app.getProperty("Documents").toDispatch();
		Dispatch doc = Dispatch.invoke(docs, "Open", Dispatch.Method, new Object[] { docfile, new Variant(false), new Variant(true) }, new int[1]).toDispatch();
		Dispatch.invoke(doc, "SaveAs", Dispatch.Method, new Object[] { htmlfile, new Variant(WORD_HTML) }, new int[1]);
		Variant f = new Variant(false);
		Dispatch.call(doc, "Close", f);
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		app.invoke("Quit", new Variant[] {});
	}
}
 
Example #4
Source File: OfficeHtmlUtil.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * EXCEL转HTML
 * 
 * @param xlsfile
 *            EXCEL文件全路径
 * @param htmlfile
 *            转换后HTML存放路径
 */
public void excelToHtml(String xlsfile, String htmlfile) {
	ActiveXComponent app = new ActiveXComponent("Excel.Application"); // 启动excel
	try {
		app.setProperty("Visible", new Variant(false));
		Dispatch excels = app.getProperty("Workbooks").toDispatch();
		Dispatch excel = Dispatch.invoke(excels, "Open", Dispatch.Method, new Object[] { xlsfile, new Variant(false), new Variant(true) }, new int[1]).toDispatch();
		Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] { htmlfile, new Variant(EXCEL_HTML) }, new int[1]);
		Variant f = new Variant(false);
		Dispatch.call(excel, "Close", f);
		org.jeecgframework.core.util.LogUtil.info("wordtohtml转换成功");
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		app.invoke("Quit", new Variant[] {});
	}
}
 
Example #5
Source File: IiTunes.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
/**
 * Returns the currently targetd track.
 *
 * @return An ITTrack object corresponding to the currently targeted track.
 * Will be set to NULL if there is no currently targeted track.
 */
public IITTrack getCurrentTrack() {
	Variant variant = iTunes.getProperty("CurrentTrack");
	if (variant.isNull()) {
		return null;
	}
	Dispatch item = variant.toDispatch();
	IITTrack track = new IITTrack(item);
	if (track.getKind() == IITTrackKind.ITTrackKindFile) {
		return new IITFileOrCDTrack(item);
	} else if (track.getKind() == IITTrackKind.ITTrackKindCD) {
		return new IITFileOrCDTrack(item);
	} else if (track.getKind() == IITTrackKind.ITTrackKindURL) {
		return new ITURLTrack(item);
	} else {
		return track;
	}
}
 
Example #6
Source File: IITArtworkCollection.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Returns an ITArtwork object corresponding to the given index (1-based).
 *
 * @param index Index of the playlist to retrieve, must be less than or
 *              equal to <code>ITArtworkCollection.getCount()</code>.
 * @return Returns an ITArtwork object corresponding to the given index.
 * Will be set to NULL if no playlist could be retrieved.
 */
public IITArtwork getItem(int index) {
	Variant variant = Dispatch.call(object, "Item", index);
	if (variant.isNull()) {
		return null;
	}
	Dispatch item = variant.toDispatch();
	return new IITArtwork(item);
}
 
Example #7
Source File: IITArtworkCollection.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
public IITArtworkCollection(Dispatch d) {
	object = d;
}
 
Example #8
Source File: ITURLTrack.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
public ITURLTrack (Dispatch d) {
    super(d);
}
 
Example #9
Source File: IITObject.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
public IITObject(Dispatch d) {
	object = d;
}
 
Example #10
Source File: IITTrack.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return a collection containing the artwork for the track.
 */
public IITArtworkCollection getArtwork() {
	Dispatch art = Dispatch.get(object, "Artwork").toDispatch();
	return new IITArtworkCollection(art);

}
 
Example #11
Source File: ITURLTrack.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
public ITURLTrack (Dispatch d) {
    super(d);
}
 
Example #12
Source File: IITTrack.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Delete this object.
 */
public void delete() {
	Dispatch.call(object, "Delete");
}
 
Example #13
Source File: IITObject.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
public IITObject(Dispatch d) {
	object = d;
}
 
Example #14
Source File: IITArtwork.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
public IITArtwork(Dispatch d) {
	super(d);
}
 
Example #15
Source File: IITTrack.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Start playing this object.
 */
public void play() {
	Dispatch.call(object, "Play");
}
 
Example #16
Source File: IITTrack.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return the kind of the track.
 */
public IITTrackKind getKind() {
	return IITTrackKind.values()[Dispatch.get(object, "Kind").getInt()];
}
 
Example #17
Source File: IITTrack.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
public IITTrack(Dispatch d) {
	super(d);
}
 
Example #18
Source File: IITArtworkCollection.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
public IITArtworkCollection(Dispatch d) {
	object = d;
}
 
Example #19
Source File: IITArtworkCollection.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns an ITArtwork object corresponding to the given index (1-based).
 *
 * @param index Index of the playlist to retrieve, must be less than or
 *              equal to <code>ITArtworkCollection.getCount()</code>.
 * @return Returns an ITArtwork object corresponding to the given index.
 * Will be set to NULL if no playlist could be retrieved.
 */
public IITArtwork getItem(int index) {
	Variant variant = Dispatch.call(object, "Item", index);
	if (variant.isNull()) {
		return null;
	}
	Dispatch item = variant.toDispatch();
	return new IITArtwork(item);
}
 
Example #20
Source File: IITArtwork.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
public IITArtwork(Dispatch d) {
	super(d);
}
 
Example #21
Source File: IITArtwork.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
/**
 * Delete this object.
 */
public void delete() {
	Dispatch.call(object, "Delete");
}
 
Example #22
Source File: IITArtwork.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
/**
 * @return true if the artwork was downloaded by iTunes.
 */
public boolean getIsDownloadedArtwork() {
	return Dispatch.get(object, "IsDownloadedArtwork").getBoolean();
}
 
Example #23
Source File: IITTrack.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
public IITTrack(Dispatch d) {
	super(d);
}
 
Example #24
Source File: IITTrack.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
/**
 * Start playing this object.
 */
public void play() {
	Dispatch.call(object, "Play");
}
 
Example #25
Source File: IITTrack.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
/**
 * @return the kind of the track.
 */
public IITTrackKind getKind() {
	return IITTrackKind.values()[Dispatch.get(object, "Kind").getInt()];
}
 
Example #26
Source File: IITTrack.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
/**
 * @return a collection containing the artwork for the track.
 */
public IITArtworkCollection getArtwork() {
	Dispatch art = Dispatch.get(object, "Artwork").toDispatch();
	return new IITArtworkCollection(art);

}
 
Example #27
Source File: IITFileOrCDTrack.java    From The-5zig-Mod with MIT License 4 votes vote down vote up
public IITFileOrCDTrack(Dispatch d) {
	super(d);
}
 
Example #28
Source File: IITArtwork.java    From The-5zig-Mod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Delete this object.
 */
public void delete() {
	Dispatch.call(object, "Delete");
}
 
Example #29
Source File: IITArtworkCollection.java    From The-5zig-Mod with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Returns an ITArtwork object with the specified persistent ID. See the
 * documentation on ITObject for more information on persistent IDs.
 *
 * @param highID The high 32 bits of the 64-bit persistent ID.
 * @param lowID  The low 32 bits of the 64-bit persistent ID.
 * @return Returns an ITArtwork object with the specified persistent ID.
 * Will be set to NULL if no playlist could be retrieved.
 */
public IITArtwork getItemByPersistentID(int highID, int lowID) {
	Variant variant = Dispatch.call(object, "ItemByPersistentID", highID, lowID);
	if (variant.isNull()) {
		return null;
	}
	Dispatch item = variant.toDispatch();
	return new IITArtwork(item);
}
 
Example #30
Source File: IITTrack.java    From The-5zig-Mod with MIT License 2 votes vote down vote up
/**
 * Returns the length of the object (in MM:SS format).
 *
 * @return Returns the length of the object (in MM:SS format).
 */
public String getTime() {
	return Dispatch.get(object, "Time").getString();
}