Hi,
I am trying to convert the attached html to Excel using the following code snippet. I see the ActionData column has ‘WrapText’ property turned on in excel output and so the texts are wrapped. May I know how is this property turned on for this particular column? Attached both html and the excel output. If you notice the below code, I specifically mentioned as AutoFitColsAndRows to true which means the text should fit into the column without being wrapped, isn’t that correct?
private byte[] convertHtmlToExcel(byte[] htmlFile) throws Exception{
//Create html load options
HtmlLoadOptions opts = new HtmlLoadOptions();
opts.setAutoFitColsAndRows(true);
opts.setConvertNumericData(false); //This is to avoid displaying the large number as scientific notattion
//Create workbook from your HTML string
Workbook wb = new Workbook(new ByteArrayInputStream(htmlFile), opts);
wb.getWorksheets().get(0).setGridlinesVisible(true);
//Save the workbook in output format
ByteArrayOutputStream excelOut = new ByteArrayOutputStream();
wb.save(excelOut, new SpreadsheetML2003SaveOptions(SaveFormat.XLSX));
return excelOut.toByteArray();
}
Archive 2.zip (1.1 MB)