POI中过滤掉带消除线的文字 (Excel 2003 版)
来源:互联网 发布:上海网站的优化 编辑:程序博客网 时间:2024/06/07 01:52
直接上代码:
HSSFRichTextString richTextString = cell.getRichStringCellValue();
String realString = richTextString.getString();
boolean isCellStrikeOut = false;
HSSFCellStyle cellStyle = cell.getCellStyle();
if (cellStyle != null) {
HSSFFont font = workbook.getFontAt(cellStyle.getFontIndex());
if (font.getStrikeout()) {
isCellStrikeOut = true;
}
}
if (richTextString.numFormattingRuns() == 0) {
if (isCellStrikeOut) {
return "";
}
return realString;
} else if (!isCellStrikeOut) {
StringBuilder sb = new StringBuilder(realString);
int lastIndex = realString.length();
for (int i = richTextString.numFormattingRuns() - 1; i >= 0 ; i --) {
short fontIndex = richTextString.getFontOfFormattingRun(i);
HSSFFont font = workbook.getFontAt(fontIndex);
if (font.getStrikeout()) {
sb.delete(richTextString.getIndexOfFormattingRun(i), lastIndex);
}
lastIndex = richTextString.getIndexOfFormattingRun(i);
}
return sb.toString();
} else {
StringBuilder sb = new StringBuilder();
int lastIndex = realString.length();
for (int i = richTextString.numFormattingRuns() - 1; i >= 0 ; i --) {
short fontIndex = richTextString.getFontOfFormattingRun(i);
HSSFFont font = workbook.getFontAt(fontIndex);
if (!font.getStrikeout()) {
sb.insert(0, realString.substring(richTextString.getIndexOfFormattingRun(i), lastIndex));
}
lastIndex = richTextString.getIndexOfFormattingRun(i);
}
return sb.toString();
}
- POI中过滤掉带消除线的文字 (Excel 2003 版)
- POI中过滤掉带消除线的文字 (Excel 2007 版)
- java poi解析excel,带合并单元的excel
- 过滤掉$string 中包含$string1的文字
- poi excel带公式导出
- poi excel带公式导出
- apache POI学习(三)——生成带格式的excel表格
- POI读取Excel文件的带注释小例子
- POI读取Excel文件的带注释小例子
- POI导出带级联下拉框的excel
- Java中利用POI操作Excel(支持2003、2007)
- poi导出Excel中图片的设置
- java中excel的导出 poi
- POI写excel(带单元格合并)上
- POI写excel(带单元格合并)下
- Cool Edit Pro 中把歌曲的原唱声消除掉制作伴奏带
- POI Excel 文字竖着显示(图)
- Java poi Excel 文字缩进处理
- 读取.9.png图像的黑色拉伸条
- Windows服务器或vps远程桌面黑 ...
- NetBeans IDE 6.9 第二个补丁版发布
- sort
- myeclipse下安装svn
- POI中过滤掉带消除线的文字 (Excel 2003 版)
- Java 内存调试命令
- A DSL in 5 Languages
- Abstract类总结
- 关于变量的作用域问题
- Android开发小结
- Linux进程学习一
- 关于单片机的C语言编程基础知识(初学注意)
- 让IE浏览器打开时默认最大化