I am trying to make a Java standalone Program that reads an excel file containing the PhD Thesis titles of students in each row.
For example: “The decomposition of “
The fancy equation has been inserted using “Insert Equation” option in excel, which I have no control over.
I need to fetch and display that as is in an html page.
I have tried Using:
private static String convertRichTextToHtml(Cell cell) {
XSSFRichTextString richText = (XSSFRichTextString) cell.getRichStringCellValue();
StringBuilder htmlBuilder = new StringBuilder();
for (int i = 0; i < richText.length(); i++) {
String charText = richText.getString().substring(i, i + 1);
Font font = richText.getFontAtIndex(i);
if (font != null && font.getTypeOffset() == Font.SS_SUB) {
htmlBuilder.append("<sub>").append(charText).append("</sub>");
} else if (font != null && font.getTypeOffset() == Font.SS_SUPER) {
htmlBuilder.append("<sup>").append(charText).append("</sup>");
} else {
htmlBuilder.append(charText);
}
}
return htmlBuilder.toString();
}
But the ‘0’ and ‘s’ for example, are not alligned in a single line. Converting to latex also gives rise to the same issue.
I ask humbly of you kind sirs to help me with a possible solution that can take care of any inked equation inserted into the excel cell ( maybe Integrals too), that takes care of the formatting as well.