① 如何用java來將excel文件轉化為html文件問題

用POI解析Excel,解析好後轉成xml,在輸出到html就可以了
類似這樣,sheet是工作區,column是行,cell是單元格
不過這樣這樣的話merge過的單元格可能比較難表示
<sheet>
<column>
<cell />
<cell />
</column>
</sheet>

② java excel轉html多個sheet怎麼合並到一個excel里

poi在讀取excel的時候,是按每個sheet,row,cell讀取的,分別對應sheet頁,行,單元格,你順序讀取,全都讀取到內存里,然後再按照你的格式在前台顯示就完了。

③ javaPOI把excel轉換成html 中怎麼去掉序號列

excelToHtmlConverter.setOutputColumnHeaders(false);
excelToHtmlConverter.setOutputRowNumbers(false);
就可以了。

④ java 通過jacob完成excel轉成html格式時報錯:com.jacob.com.ComFailException: Invoke of: SaveAs

你就根據異常檢查吧,看看你要復制的文件是否存在

⑤ java怎麼講excel轉為html

用POI解析Excel,解析好後轉成xml,在輸出到html就可以了
類似這樣,sheet是工作專區屬,column是行,cell是單元格
不過這樣這樣的話merge過的單元格可能比較難表示
<sheet>
<column>
<cell />
<cell />
</column>
</sheet>

⑥ java如何將html轉為excel文件

建議找一下有關java導出excel的資料,html轉pdf就試過,html轉excel沒試過

⑦ 如何將excel轉換成html要支持Java調用

Excel和Html相互格式轉換方法_網路經驗 http://jingyan..com/article/597a0643886051312b5243fb.html

⑧ java excel怎麼讀取到html

一般都是用jacob的,這里不能發地址,自己搜一下,要下.9的版本
1、我們解開下載的jacob_1.9.zip,在文件夾中找到jacob.dll和jacob.jar兩個文件
2、將壓縮包解壓後,Jacob.jar添加到Libraries中;
3、將Jacob.dll放至「WINDOWS\SYSTEM32」下面。
需要注意的是:
【使用IDE啟動Web伺服器時,系統讀取不到Jacob.dll,例如用MyEclipse啟動Tomcat,就需要將dll文件到MyEclipse安裝目錄的「jre\bin」下面。
一般系統沒有載入到Jacob.dll文件時,報錯信息為:「java.lang.UnsatisfiedLinkError: no jacob in java.library.path」】

使用Jacob轉換Word,Excel為HTML

JAVA代碼

Java代碼
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;

public class TransformFiletoHtml
{
int WORD_HTML = 8;
int WORD_TXT = 7;
int EXCEL_HTML = 44;

/**
* 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[] {});
}
}

/**
* 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);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
app.invoke("Quit", new Variant[] {});
}
}

/**
* /刪除指定文件夾
* @param folderPath 文件夾全路徑
* @param htmlfile 轉換後HTML存放路徑
*/
public void delFolder(String folderPath)
{
try
{
delAllFile(folderPath); //刪除完裡面所有內容
String filePath = folderPath;
filePath = filePath.toString();
java.io.File myFilePath = new java.io.File(filePath);
myFilePath.delete(); //刪除空文件夾
} catch (Exception e) {e.printStackTrace();}
}

/**
* /刪除指定文件夾下所有文件
* @param path 文件全路徑
*/
public boolean delAllFile(String path)
{
boolean flag = false;
File file = new File(path);
if (!file.exists())
{
return flag;
}
if (!file.isDirectory())
{
return flag;
}
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++)
{
if (path.endsWith(File.separator))
{
temp = new File(path + tempList[i]);
}
else
{
temp = new File(path + File.separator + tempList[i]);
}
if (temp.isFile())
{
temp.delete();
}
if (temp.isDirectory())
{
delAllFile(path + "/" + tempList[i]);//先刪除文件夾裡面的文件
delFolder(path + "/" + tempList[i]);//再刪除空文件夾
flag = true;
}
}
return flag;
}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;

public class TransformFiletoHtml
{
int WORD_HTML = 8;
int WORD_TXT = 7;
int EXCEL_HTML = 44;

/**
* 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[] {});
}
}

/**
* 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);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
app.invoke("Quit", new Variant[] {});
}
}

/**
* /刪除指定文件夾
* @param folderPath 文件夾全路徑
* @param htmlfile 轉換後HTML存放路徑
*/
public void delFolder(String folderPath)
{
try
{
delAllFile(folderPath); //刪除完裡面所有內容
String filePath = folderPath;
filePath = filePath.toString();
java.io.File myFilePath = new java.io.File(filePath);
myFilePath.delete(); //刪除空文件夾
} catch (Exception e) {e.printStackTrace();}
}

/**
* /刪除指定文件夾下所有文件
* @param path 文件全路徑
*/
public boolean delAllFile(String path)
{
boolean flag = false;
File file = new File(path);
if (!file.exists())
{
return flag;
}
if (!file.isDirectory())
{
return flag;
}
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++)
{
if (path.endsWith(File.separator))
{
temp = new File(path + tempList[i]);
}
else
{
temp = new File(path + File.separator + tempList[i]);
}
if (temp.isFile())
{
temp.delete();
}
if (temp.isDirectory())
{
delAllFile(path + "/" + tempList[i]);//先刪除文件夾裡面的文件
delFolder(path + "/" + tempList[i]);//再刪除空文件夾
flag = true;
}
}
return flag;
}
}調用JAVA代碼:

Java代碼
public class Test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
TransformFiletoHtml trans = new TransformFiletoHtml();
trans.wordToHtml("D:\\sinye.doc", "D:\\sinye.html");
}

}

public class Test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
TransformFiletoHtml trans = new TransformFiletoHtml();
trans.wordToHtml("D:\\sinye.doc", "D:\\sinye.html");
}

} 只寫了一個測試word轉html的,excel轉html的同理,在TransformFiletoHtml類中,寫了兩個方法,一個是刪除文件夾的方法(delFolder()),一個是刪除文件夾下所有文件的方法(delAllFile())。

⑨ java 通過jacob完成excel轉成html格式時報錯:

你的錯誤沒有貼出來,可能是tomcat裡面的jar包和你運行報錯的那一段的jar包裡面有沖突。需要調整jar包的載入順序。

⑩ Java問題:word、EXCEL轉化成HTML文件怎麼設置utf-8編碼格式

可用notepad++打開你的文本文件,然後在字元選擇UTF-8,