Java操作Microsoft Word之jacob (2)
这里有一个MSWordManager 类,是jacob官方发布的工具类,里面有大多数Java操作MS Office的工具。
package com.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class MSWordManager {
// word文档
private Dispatch doc;
// word运行程序对象
private ActiveXComponent word;
// 所有word文档集合
private Dispatch documents;
// 选定的范围或插入点
private Dispatch selection;
private boolean saveOnExit = true;
/** *//**
*
* @param visible 为true表示word应用程序可见
*/
public MSWordManager(boolean visible) {
if (word == null) {
word = new ActiveXComponent("Word.Application");
word.setProperty("Visible", new Variant(visible));
&nbs
相关文档:
问题域:
--系统中你需要获得某个类的唯一实例,所有客户端对它的访问都将通过一个公共的访问点获得
--创建一个类并使其:(A)定义一个私有的构造器(B)定义一个私有、静态的变量指向自己(C)定义一个公有、静态的访问方法用于返回该类的一个唯一实例
分为 饿汉式 和 懒汉式,下面是一个简单的示例代码,应该 ......
String startTime, String endTime;
Date start = null;
Date end = null;
Date startTimeStamp = null;
Date endTimeStamp = null;
try {
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
......
这几天遇到了java的package问题(这种问题只是在cmd命令行模式下会遇到,如果用eclipse就不会有这种问题),把java中的package编译运行的问题总结一下,作为备忘。
首先,如果你有两个类:
(1)A.java
import edu.ustc.*;
&n ......
如果想让所有用户share:
emacs -nw /etc/profile
然后在未尾加入
#set java environment
set JAVA_HOME=/usr/java/jdk1.5.0_16
set PATH=.:$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
如果仅当前用户使用:
把上面的加入用户目录下的.bash_profile或.bash-rc
然后运行source /etc/profile生效 ......
1.在系统中导入一下source
SetCharacterEncodingFilter.java
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses ......