I'm using docx4j in eclipse to get the contents of an excel sheet but all what I'm getting is numbers. For simplicity, assume this is my sheet:
| asd | sd |
| hgn |
The code I'm using to load the contents is:
public static void load(String outputfilepath) throws FileNotFoundException{
try {
SpreadsheetMLPackage exc = SpreadsheetMLPackage
.load(new java.io.File(outputfilepath));
WorksheetPart sheet = exc.getWorkbookPart().getWorksheet(0);
System.out.println(sheet.getPartName().getName());
Worksheet ws = sheet.getJaxbElement();
SheetData data = ws.getSheetData();
int ic = 0;
for (Row r : data.getRow()) {
System.out.println("row " + ic);
int ir = 0;
for (Cell c : r.getC()) {
System.out.println("cell " + ir + " contains "
+ c.getV().toString());
ir++;
}
ic++;
}
System.out.println("\ndone");
} catch (Docx4JException e) {
e.printStackTrace();
} catch (Xlsx4jException e) {
e.printStackTrace();
}
}
And this is my output:
/xl/worksheets/sheet1.xml
row 0
cell 0 contains 0
cell 1 contains 1
row 1
cell 0 contains 2
done
What should I do to get the actual content?
Note: The problem occurs only with strings. ie if there are numbers in a cell I get them without problems.