|
@@ -15,17 +15,19 @@ import com.mixsmart.utils.FormulaUtils;
|
|
import com.mixsmart.utils.ListUtils;
|
|
import com.mixsmart.utils.ListUtils;
|
|
import com.mixsmart.utils.RegexUtils;
|
|
import com.mixsmart.utils.RegexUtils;
|
|
import com.spire.xls.FileFormat;
|
|
import com.spire.xls.FileFormat;
|
|
-import com.spire.xls.Worksheet;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFRichTextString;
|
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
import org.apache.poi.util.IOUtils;
|
|
import org.apache.poi.util.IOUtils;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
@@ -1403,7 +1405,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
//获取excel流 和 html流
|
|
//获取excel流 和 html流
|
|
InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
|
|
InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
|
|
- Workbook workbook = WorkbookFactory.create(exceInp);
|
|
|
|
|
|
+
|
|
|
|
+ Workbook workbook=null;
|
|
|
|
+ int index = excelTab.getFileUrl().lastIndexOf(".");
|
|
|
|
+ String suffix = excelTab.getFileUrl().substring(index);
|
|
|
|
+
|
|
|
|
+ if (".xls".equals(suffix)) {
|
|
|
|
+ workbook = new HSSFWorkbook(exceInp);
|
|
|
|
+ } else if (".xlsx".equals(suffix)) {
|
|
|
|
+ workbook = new XSSFWorkbook(exceInp);
|
|
|
|
+ }
|
|
|
|
|
|
//获取工作表
|
|
//获取工作表
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
@@ -1633,12 +1644,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
|
|
redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
|
|
redFont.setFontHeightInPoints(Short.valueOf("1"));//设置字体大小
|
|
redFont.setFontHeightInPoints(Short.valueOf("1"));//设置字体大小
|
|
redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
- CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
|
- newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
|
- newStyle.setFont(redFont);
|
|
|
|
- newStyle.setShrinkToFit(true);
|
|
|
|
- cell.setCellStyle(newStyle);
|
|
|
|
- cell.setCellValue(dqid);
|
|
|
|
|
|
+ String CellValue = cell.getStringCellValue().trim();
|
|
|
|
+
|
|
|
|
+ if(CellValue!=null && StringUtils.isNotEmpty(CellValue)){
|
|
|
|
+ RichTextString ts= new HSSFRichTextString(CellValue + "--"+dqid);
|
|
|
|
+ // ts.applyFont(0,CellValue.length(),oldfontAt);
|
|
|
|
+ // ts.applyFont(10,ts.length(),redFont);
|
|
|
|
+ cell.setCellValue(ts);
|
|
|
|
+ }else{
|
|
|
|
+ CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
|
+ newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
|
+ newStyle.setFont(redFont);
|
|
|
|
+ newStyle.setShrinkToFit(true);
|
|
|
|
+ cell.setCellStyle(newStyle);
|
|
|
|
+ cell.setCellValue(dqid);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|