資源簡介
統(tǒng)計報表功能有excel轉(zhuǎn)html的場景,但官方提供的demo,導出的html不能很好的展示合并的單元格。
優(yōu)點:基于官方demo修改了部分代碼,能夠滿足合并單元格需求,同時屏蔽了難看的表頭編號和行號,前端看起來,不會讓人容易聯(lián)想到和excel有什么關(guān)系了。
不足:合并的單元格默認顯示虛線框,這個被我強制屏蔽了,有待進一步優(yōu)化。

代碼片段和文件信息
/*?====================================================================
???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?this?file?to?You?under?the?Apache?License?Version?2.0
???(the?“License“);?you?may?not?use?this?file?except?in?compliance?with
???the?License.??You?may?obtain?a?copy?of?the?License?at
???????http://www.apache.org/licenses/LICENSE-2.0
???Unless?required?by?applicable?law?or?agreed?to?in?writing?software
???distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
???WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
???See?the?License?for?the?specific?language?governing?permissions?and
???limitations?under?the?License.
====================================================================?*/
package?org.apache.poi.ss.examples.html;
import?org.apache.poi.hssf.usermodel.HSSFCell;
import?org.apache.poi.hssf.usermodel.HSSFFont;
import?org.apache.poi.hssf.usermodel.HSSFWorkbook;
import?org.apache.poi.ss.format.CellFormat;
import?org.apache.poi.ss.format.CellFormatResult;
import?org.apache.poi.ss.usermodel.*;
import?org.apache.poi.ss.util.CellRangeAddress;
import?org.apache.poi.ss.util.Region;
import?org.apache.poi.xssf.usermodel.XSSFWorkbook;
import?java.io.BufferedReader;
import?java.io.Closeable;
import?java.io.FileInputStream;
import?java.io.FileWriter;
import?java.io.IOException;
import?java.io.InputStream;
import?java.io.InputStreamReader;
import?java.io.PrintWriter;
import?java.util.Formatter;
import?java.util.HashMap;
import?java.util.HashSet;
import?java.util.Iterator;
import?java.util.Map;
import?java.util.Set;
import?static?org.apache.poi.ss.usermodel.Cellstyle.*;
import?org.apache.poi.openxml4j.exceptions.InvalidFormatException;
/**
?*?This?example?shows?how?to?display?a?spreadsheet?in?HTML?using?the?classes?for
?*?spreadsheet?display.
?*
?*?@author?Ken?Arnold?Industrious?Media?LLC
?*/
public?class?ToHtml?{
????private?final?Workbook?wb;
????private?final?Appendable?output;
????private?boolean?completeHTML;
????private?Formatter?out;
????private?boolean?gotBounds;
????private?int?firstColumn;
????private?int?endColumn;
????private?HtmlHelper?helper;
????private?static?final?String?DEFAULTS_CLASS?=?“excelDefaults“;
????private?static?final?String?COL_HEAD_CLASS?=?“colHeader“;
????private?static?final?String?ROW_HEAD_CLASS?=?“rowHeader“;
????private?static?final?Map?ALIGN?=?mapFor(ALIGN_LEFT?“l(fā)eft“
????????????ALIGN_CENTER?“center“?ALIGN_RIGHT?“right“?ALIGN_FILL?“l(fā)eft“
????????????ALIGN_JUSTIFY?“l(fā)eft“?ALIGN_CENTER_SELECTION?“center“);
????private?static?final?Map?VERTICAL_ALIGN?=?mapFor(
????????????VERTICAL_BOTTOM?“bottom“?VERTICAL_CENTER?“middle“?VERTICAL_TOP
????????????“top“);
????p
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????312839??2015-06-11?13:54??ToHtml\poi-example-3.10-FINAL.jar
?????文件????1031421??2015-03-25?09:53??ToHtml\poi-ooxm
?????文件??????17671??2015-06-18?14:30??ToHtml\ToHtml.java
?????目錄??????????0??2015-06-18?14:47??ToHtml
-----------?---------??----------?-----??----
??????????????1361931????????????????????4
- 上一篇:基于vfw的USB攝像頭視頻采集程序
- 下一篇:3D相冊html5源碼
評論
共有 條評論