收录日期:2021/02/25 05:11:47 时间:2016/08/02 18:10:38 标签:Eclipse
如何用Java2Word改写已有word表格中的数据,我现在要用LinkedList final_list里放的数据去替换1.doc中第一个表格中的数据。
代码如下:
public static void WriteToDoc( LinkedList final_list)
{
Document doc = null;
try {
doc = new Document();
doc.open("C://Documents and Settings/tw/桌面/1.doc");
doc.replaceTable(1, 1, 1,final_list);
// doc.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally
{
try {
if(doc!=null) doc.close(true);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
可是会报错:
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;
at com.heavenlake.wordapi.Document.replaceTable(Document.java:681)
at com.heavenlake.wordapi.Document.replaceTable(Document.java:602)
请高手指点,谢谢!
at com.heavenlake.wordapi.Document.replaceTable(Document.java:567)