Lines 186-215
Link Here
|
186 |
private void injectData(File zipfile, OutputStream out) throws IOException |
186 |
private void injectData(File zipfile, OutputStream out) throws IOException |
187 |
{ |
187 |
{ |
188 |
ZipFile zip = new ZipFile(zipfile); |
188 |
ZipFile zip = new ZipFile(zipfile); |
189 |
|
189 |
try |
190 |
ZipOutputStream zos = new ZipOutputStream(out); |
|
|
191 |
|
192 |
@SuppressWarnings("unchecked") |
193 |
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries(); |
194 |
while (en.hasMoreElements()) |
195 |
{ |
190 |
{ |
196 |
ZipEntry ze = en.nextElement(); |
191 |
ZipOutputStream zos = new ZipOutputStream(out); |
197 |
zos.putNextEntry(new ZipEntry(ze.getName())); |
192 |
try |
198 |
InputStream is = zip.getInputStream(ze); |
|
|
199 |
XSSFSheet xSheet=getSheetFromZipEntryName(ze.getName()); |
200 |
if(xSheet!=null) |
201 |
{ |
193 |
{ |
202 |
SXSSFSheet sxSheet=getSXSSFSheet(xSheet); |
194 |
@SuppressWarnings("unchecked") |
203 |
copyStreamAndInjectWorksheet(is,zos,sxSheet.getWorksheetXMLInputStream()); |
195 |
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries(); |
|
|
196 |
while (en.hasMoreElements()) |
197 |
{ |
198 |
ZipEntry ze = en.nextElement(); |
199 |
zos.putNextEntry(new ZipEntry(ze.getName())); |
200 |
InputStream is = zip.getInputStream(ze); |
201 |
XSSFSheet xSheet=getSheetFromZipEntryName(ze.getName()); |
202 |
if(xSheet!=null) |
203 |
{ |
204 |
SXSSFSheet sxSheet=getSXSSFSheet(xSheet); |
205 |
InputStream xis = sxSheet.getWorksheetXMLInputStream(); |
206 |
try |
207 |
{ |
208 |
copyStreamAndInjectWorksheet(is,zos,xis); |
209 |
} |
210 |
finally |
211 |
{ |
212 |
xis.close(); |
213 |
} |
214 |
} |
215 |
else |
216 |
{ |
217 |
copyStream(is, zos); |
218 |
} |
219 |
is.close(); |
220 |
} |
204 |
} |
221 |
} |
205 |
else |
222 |
finally |
206 |
{ |
223 |
{ |
207 |
copyStream(is, zos); |
224 |
zos.close(); |
208 |
} |
225 |
} |
209 |
is.close(); |
|
|
210 |
} |
226 |
} |
211 |
|
227 |
finally |
212 |
zos.close(); |
228 |
{ |
|
|
229 |
zip.close(); |
230 |
} |
213 |
} |
231 |
} |
214 |
private static void copyStream(InputStream in, OutputStream out) throws IOException { |
232 |
private static void copyStream(InputStream in, OutputStream out) throws IOException { |
215 |
byte[] chunk = new byte[1024]; |
233 |
byte[] chunk = new byte[1024]; |
Lines 649-655
Link Here
|
649 |
} |
667 |
} |
650 |
|
668 |
|
651 |
//Save the template |
669 |
//Save the template |
652 |
File tmplFile = File.createTempFile("poi-sxxsf-template", ".xlsx"); |
670 |
File tmplFile = File.createTempFile("poi-sxssf-template", ".xlsx"); |
653 |
tmplFile.deleteOnExit(); |
671 |
tmplFile.deleteOnExit(); |
654 |
FileOutputStream os = new FileOutputStream(tmplFile); |
672 |
FileOutputStream os = new FileOutputStream(tmplFile); |
655 |
_wb.write(os); |
673 |
_wb.write(os); |
656 |
+ native |
674 |
+ native |