Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support conversion from Strict OOXML #21

Merged
merged 5 commits into from
Nov 6, 2020
Merged

Support conversion from Strict OOXML #21

merged 5 commits into from
Nov 6, 2020

Conversation

selalerercapitolis
Copy link

No description provided.

@pjfanning
Copy link
Owner

thanks - I had not considered adding this support here but I'll consider it, might take me a few days to have a look

pom.xml Outdated
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.pjfanning</groupId>
<artifactId>excel-streaming-reader</artifactId>
<version>2.3.6-SNAPSHOT</version>
<version>2.3.7-SNAPSHOT</version>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this? - I'll worry about the version numbers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


public class OoXmlStrictConverter implements AutoCloseable {

private static final XMLEventFactory XEF = XMLEventFactory.newInstance();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a class called org.apache.poi.util.XMLHelper has methods to create the XML input and output factories - can you use those?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

private static final Properties mappings;

static {
XOF.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line won't be needed if you use the XMLHelper method to create an output factory

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

private static class ByteArrayOutputStreamExposed extends ByteArrayOutputStream {

public byte[] getBytes() {
return buf;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

@selalerercapitolis selalerercapitolis Nov 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toByteArray() creates a copy.

Probably not that important, performance-wise, considering we're doing IO and unzipping and zipping unnecessarily but just seemed weird to clone the array when all I need to do is read from it.

Add to that, that the ByteArrayOutputStream has this field protected and not private it seems like that was the intention.

} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println("loaded mappings entries=" + props.size());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove the println?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@pjfanning pjfanning merged commit 4ce3c80 into pjfanning:master Nov 6, 2020
@pjfanning
Copy link
Owner

I published a new 2.3.6-SNAPSHOT release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants