Suppose I have some HTML code in cells A1 and A2 of an Excel sheet. On exporting to HTML , I would want A1 to be treated as plain text. And want A2 to be treated as an HTML element

Well if I have an Excel sheet in which I want some cells containing HTML code to be treated as string and some cells containing HTML code to be treated as HTML on exporting to HTML, is there any way to do that?

Suppose I have:
< iframe src = https : /fly .com / >
in cells A1 and A2.
On exporting to HTML , I would want A1 to be treated as plain text. And want A2 to be treated as an HTML element.

Is this possible in any way?

@sandipanghosh111,

I 'm afraid, there may not be best way to cope with your custom needs. However I devised a workaround to cope with it though and you can use it. See the sample code segment with comments for your reference:
e.g
Sample code:

Workbook wb = new Workbook("F:\\Files\\TestHtmlInjection\\TestSheet1.xlsx");
		//Since you need to have A1 HTML as plain text, so you will re-insert its HTML as sting
		wb.getWorksheets().get(0).getCells().get("A1").putValue(wb.getWorksheets().get(0).getCells().get("A1").getHtmlString());
		//You do not need to do anything with A2 as its HTML will be processed and embedded.
		HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
		htmlSaveOptions.setPresentationPreference(true);
		htmlSaveOptions.setParseHtmlTagInCell(false);//You need to specify as "false".
		htmlSaveOptions.setExportHiddenWorksheet(false);
		htmlSaveOptions.setRefreshChartCache(true);
		
		wb.save("F:\\Files\\TestHtmlInjection\\out1.html", htmlSaveOptions);

Hope, this helps a bit.

Thanks :slight_smile:

@sandipanghosh111,

You are welcome.