资源简介
统计报表功能有excel转html的场景,但官方提供的demo,导出的html不能很好的展示合并的单元格。
优点:基于官方demo修改了部分代码,能够满足合并单元格需求,同时屏蔽了难看的表头编号和行号,前端看起来,不会让人容易联想到和excel有什么关系了。
不足:合并的单元格默认显示虚线框,这个被我强制屏蔽了,有待进一步优化。

代码片段和文件信息
/* ====================================================================
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 “left“
ALIGN_CENTER “center“ ALIGN_RIGHT “right“ ALIGN_FILL “left“
ALIGN_JUSTIFY “left“ 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源码
相关资源
- bootstrap3.0带源代码
- uploadifive1.2.2 uploadify HTML5
- 管理系统HTML模板
- 非常漂亮的导航菜单(html)
- 网页文件HTML
-
html中获取xm
l数据 - HTML AJAX(手写ajax)显示数据库数据
- HTML5 CSS3 :canvas 模拟实现电子彩票刮
- 仿Win10 UI界面(前端html模板)
- 永劫无间主题 html+css
- 登录html
- 游戏商城html模板(首页)
- 生日祝福html代码(带背景音乐)
- 基础html小米商城
- W3C html5 参考手册(教学资源免费)
- html5 2048小游戏
- oa html模板(基于Vue开发)
- 个人网站备案的HTML模板
- html旅游静态网站
- 简易京东网页HTML代码(HTMLamp;JS;)
- 有问必答项目 html源码
- html 塔防游戏runner
- html 二十一点
- 生日祝福html网页源码(特效很多)
- 时时彩网站 html模板(手机端 )
- HTML可视化面板
- 印象烘培 首页html源码
- H5彩票网站html代码
- 教育类网站html代码
- 人才招聘资讯博客HTML模板手机版自适
评论
共有 条评论