I am currently creating a custom importer/exporter for my own file type with java using XFilter.
I now have a serious bottleneck when importing. Here is my code for inserting my content into a spreadsheet:
XSpreadsheetDocument document = UnoRuntime.queryInterface(
XSpreadsheetDocument.class,
targetDocument);
XMultiServiceFactory serviceFactory = UnoRuntime.queryInterface(
com.sun.star.lang.XMultiServiceFactory.class,
document);
for (int i = 0; i < numberOfSpreadsheets; i++) {
Object spreadsheetObject = serviceFactory.createInstance("com.sun.star.sheet.Spreadsheet");
XSpreadsheet spreadsheet = UnoRuntime.queryInterface(
XSpreadsheet.class,
spreadsheetObject);
document.getSheets().insertByName(spreadsheetNames.get(i), spreadsheet);
// Not sure about this part
spreadsheet = UnoRuntime.queryInterface(
XSpreadsheet.class,
document.getSheets().getByName(spreadsheetNames.get(i));
for (int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) {
for (int columnIndex = 0; columnIndex < numberOfCellsInRow; columnIndex++) {
// This call to getCellByPosition seems to be the bottleneck
XCell cell = spreadsheet.getCellByPosition(columnIndex, rowIndex);
XText text = UnoRuntime.queryInterface(XText.class, cell);
text.setString(cellValue);
}
}
}
Is there any way I can omit all these calls to getCellByPosition?
Is there some sort of bulk API available?