use of org.docx4j.openpackaging.parts.SpreadsheetML.SharedStrings in project com.revolsys.open by revolsys.
the class XlsxRecordReader method initDo.
@Override
protected void initDo() {
super.initDo();
try (InputStream in = this.resource.newBufferedInputStream()) {
final SpreadsheetMLPackage spreadsheetPackage = (SpreadsheetMLPackage) OpcPackage.load(in);
final DocPropsCustomPart customProperties = spreadsheetPackage.getDocPropsCustomPart();
if (customProperties != null) {
int srid = 0;
try {
srid = Integer.parseInt(customProperties.getProperty("srid").getLpwstr());
} catch (final Throwable e) {
}
int axisCount = 2;
try {
axisCount = Integer.parseInt(customProperties.getProperty("axisCount").getLpwstr());
if (axisCount > 4) {
axisCount = 2;
}
} catch (final Throwable e) {
}
double scaleXy = 0;
try {
scaleXy = Double.parseDouble(customProperties.getProperty("scaleXy").getLpwstr());
} catch (final Throwable e) {
}
double scaleZ = 0;
try {
scaleZ = Double.parseDouble(customProperties.getProperty("scaleZ").getLpwstr());
} catch (final Throwable e) {
}
final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scaleXy, scaleXy, scaleZ);
setGeometryFactory(geometryFactory);
}
WorksheetPart worksheetPart = null;
for (final Part part : spreadsheetPackage.getParts().getParts().values()) {
if (part instanceof WorksheetPart) {
if (worksheetPart == null) {
worksheetPart = (WorksheetPart) part;
}
} else if (part instanceof SharedStrings) {
final SharedStrings sharedStrings = (SharedStrings) part;
final CTSst contents = sharedStrings.getContents();
this.sharedStringList = contents.getSi();
}
}
if (worksheetPart != null) {
final Worksheet worksheet = worksheetPart.getContents();
final SheetData sheetData = worksheet.getSheetData();
this.rows = sheetData.getRow();
final List<String> line = readNextRow();
final String baseName = this.resource.getBaseName();
newRecordDefinition(baseName, line);
}
} catch (final IOException | Docx4JException e) {
Logs.error(this, "Unable to open " + this.resource, e);
} catch (final NoSuchElementException e) {
}
}
Aggregations