簡體   English   中英

如何使用displaytag ExcelHssfView類在Excel工作表單元格中編寫HTML內容

[英]How to write html content in excel sheet cell using displaytag ExcelHssfView class

我想使用displaytag ExcelHssfView類將html內容寫入excel中的單元格。 以下是我的代碼段

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("NewSheet");
sheet.addMergedRegion(new CellRangeAddress(3,15,1,20));
HSSFRow xlsRow2 = sheet.createRow(sheet.getMergedRegion(1).getFirstRow());
HSSFCell cell = xlsRow2.createCell(1);
writeCell("Type:<ol><li>Sedan<ul style='list-style-type:disc'></ul></li><li>SUV<ul style='list-style-type:disc'></ul></li><li>Hatchback<ul style='list-style-type:disc'></ul></li></ol>", cell);

問題是html內容在帶有標簽的單元格中原樣顯示。 是否可以在單元格中正確編寫html內容?

在寫入單元格之前,先用Java處理文本。 例如,用\\ t和ul的unicode替換ul標簽,即excel識別和顯示文本的\\ t \\ t \\ t \\ u2022,就像ul標簽在瀏覽器中一樣。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM