Commit 05500501 authored by 竹天卫's avatar 竹天卫

导出下标 完成

parent ba3488c5
...@@ -199,17 +199,18 @@ public class ExcelUtil { ...@@ -199,17 +199,18 @@ public class ExcelUtil {
} }
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
// style.setWrapText(true); //关键 String value = data[i] == null ? null : data[i].toString();
cell = row.createCell(i); cell = row.createCell(i);
cell.setCellValue(data[i] == null ? null : data[i].toString());
//处理下标 //处理下标
if(cell.getStringCellValue().contains("<sub>") || cell.getStringCellValue().contains("</sub>") ){ if(value.contains("<sub>") || value.contains("</sub>") ){
cell.setCellStyle(style); cell.setCellStyle(style);
XSSFRichTextString richString = new XSSFRichTextString(cell.getStringCellValue().replaceAll("</sub>","<sub>").replaceAll("<sub>","")); XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sub>","<sub>").replaceAll("<sub>",""));
//提取下标位置 //提取下标位置
applyRichStringFont(cell.getStringCellValue(), richString, xxsfFont); applyRichStringFont(value, richString, xxsfFont);
cell.setCellValue(richString); cell.setCellValue(richString);
}else{ }else{
cell.setCellValue(value);
cell.setCellStyle(style); cell.setCellStyle(style);
} }
...@@ -232,7 +233,7 @@ public class ExcelUtil { ...@@ -232,7 +233,7 @@ public class ExcelUtil {
if (i % 2 != 0) { if (i % 2 != 0) {
it_str = it_str + split[i - 1]; it_str = it_str + split[i - 1];
} else { } else {
richString.applyFont(it_str.length(),(it_str+split[i-1]).length()-1,xxsfFont); richString.applyFont(it_str.length(),(it_str+split[i-1]).length(),xxsfFont);
it_str = it_str + split[i - 1]; it_str = it_str + split[i - 1];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment