You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/05/11 12:07:47 UTC
[Bug 59458] New: Exporting xlsx using apache poi 3.13 on weblogic :
File format or extension not valid
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
Bug ID: 59458
Summary: Exporting xlsx using apache poi 3.13 on weblogic :
File format or extension not valid
Product: POI
Version: 3.13-FINAL
Hardware: PC
OS: Linux
Status: NEW
Severity: blocker
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: kishan089.ce@gmail.com
Earlier I was exporting xls with Apache POI 2.5.1 to export `.xls` file using
`HSSFWorkbook`.
With updated Apache POI to 3.13 I am exporting `.xlsx` file using
`SXSSFWorkbook` but its exporting corrupted file.
MS Excel failed to open file with **File format or extension not valid** error.
Note that this issue I am facing only on `WebLogic` server, it works fine with
`JBoss`.
Anybody can help what I am doing wrong here or it is POI bug?
Code:
List<JRField> fields = ds.getFields();
SXSSFWorkbook wb = new SXSSFWorkbook();
SXSSFSheet sheet = wb.createSheet("Sheet1");
try {
CellStyle cellStyle = wb.createCellStyle();
CellStyle cellStyleColName = wb.createCellStyle();
CellStyle cellStyleTitle = wb.createCellStyle();
Font boldFont = wb.createFont();
boldFont.setFontHeightInPoints((short)16);
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// Cell Style for body
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
cellStyle.setWrapText(true);
// Cell Style for Column Names
cellStyleColName.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
cellStyleColName.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleColName.setBorderTop(HSSFCellStyle.BORDER_MEDIUM); //
single line border
cellStyleColName.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); //
single line border
// Cell Style for Title
cellStyleTitle.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleTitle.setFont(boldFont);
// Creating Title Row
Row row1 = sheet.createRow((short) 0);
// Creating the Title line
Cell cell1 = row1.createCell((short) 0);
cell1.setCellValue("Demo Title");
cell1.setCellStyle(cellStyleTitle);
// Title Region
CellRangeAddress regionTitle = new CellRangeAddress( (short) 0,
// From Row
(short) 0, // From Col
(short) 0, // To Row
(short) (this.displayCols.size()-1) // To Col
);
sheet.addMergedRegion(regionTitle);
// Column Name Row
int j =0;
Row row2 = sheet.createRow((short) 1);
for (ReportColumn col : this.displayCols)
{
Cell cell2 = row2.createCell((short) j++);
cell2.setCellValue(col.getDisplayName());
cell2.setCellStyle(cellStyleColName);
}
int i =2;
while (ds.next()) {
Row rows = sheet.createRow((short) 0 + i);
int k = 0;
for (JRField field : fields) {
String fieldAsString = (ds.getFieldValue(field) != null ?
ds.getFieldValue(field).toString():null);
Cell cell = rows.createCell((short) k++);
cell.setCellStyle(cellStyle);
cell.setCellValue(fieldAsString);
}
i++;
if (i > RECORD_LIMIT_FROM_POI){
log.info("Row limit from poi reached #1048576 and exported
data is truncated.");
break;
}
}
wb.write(os);
}
catch (Exception e) {
log.error("error in createXlsFile method", e);
}
**Failed attempts:**
1. Updated mime type in response header from `application/vnd.ms-excel`
to `vnd.openxmlformats-officedocument.spreadsheetml.sheet`
2. Added `xlsx=vnd.openxmlformats-officedocument.spreadsheetml.sheet` in
custom mime mapping file for WebLogic
Notes:
WebLogic running on Linux SuSe
WebLogic version 10.3.5.0
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
--- Comment #4 from Kishan Sarsecha <ki...@gmail.com> ---
Minimal code which is not working on WebLogic 10.3.5
SXSSFWorkbook wb = new SXSSFWorkbook();
SXSSFSheet sheet = wb.createSheet("Sheet1");
String[] displayCols = new String[] {"FirstColumn", "SecondColumn",
"ThirdColumn"};
String[][] values = new String[][] {
{"Value1", "Value2", "Value3"},
{"Value4", "Value5", "Value6"},
{"Value7", "Value8", "Value9"}
};
// Creating Title Row
Row row1 = sheet.createRow(0);
// Creating the Title line
Cell cell1 = row1.createCell(0);
cell1.setCellValue("This is test report");
// Column Name Row
int j =0;
Row row2 = sheet.createRow(1);
for (String col : displayCols)
{
Cell cell2 = row2.createCell(j++);
cell2.setCellValue(col);
}
int i = 2;
for( String[] strs: values) {
Row rows = sheet.createRow(i);
int k = 0;
for ( String value: strs) {
Cell cell = rows.createCell(k++);
cell.setCellValue(value);
}
i++;
}
try {
wb.write(os); // os is ServletOutputStream of HTTPServletResponse
} catch (IOException e) {
e.printStackTrace();
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
--- Comment #5 from Nick Burch <ap...@gagravarr.org> ---
As this is working on other platforms, I'd suggest you'd be best off speaking
to Weblogic support
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
Javen O'Neal <on...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #1 from Javen O'Neal <on...@apache.org> ---
Your example is missing a few critical lines, such as what os is.
FileOutputStream("/tmp/Workbook.xlsx") I hope.
Your example probably contains more lines than are relevant. Can any of the
lines in the body be deleted and still recreate your problem? The more you cut
out irrelevant parts of your code, the easier it is to provide suggestions.
Have you tried using XSSFWorkbook yet?
SO post
http://stackoverflow.com/q/37159328/2683399
Looks like you're using poi-3.13, poi-ooxml-3.13, and poi-ooxml-schemas-3.13,
so at least you're not mixing POI versions. Make sure you don't have any other
versions of POI on your class path.
It's probably better to ask usage questions on one of the POI mailing lists.
http://poi.apache.org/mailinglists.html
Closing this bug unless someone can demonstrate a bug in POI rather than an
environment configuration problem.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
--- Comment #7 from Nick Burch <ap...@gagravarr.org> ---
Apache POI supports all standards-compliant Java Virtual Machines (JVMs), and
is routinely tested with most of the main freely available ones. For
compatibility with paid-for java platforms, you'll be best off asking the
support team of the product you're paying money for - they're much more likely
to know than volunteers giving up their spare time to support software they've
given to you for free...
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
Kishan Sarsecha <ki...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
--- Comment #3 from Kishan Sarsecha <ki...@gmail.com> ---
Tested with,
FileOutputStream stream = new FileOutputStream("/tmp/testfile.xlsx");
wb.write(stream);
stream.flush();
stream.close();
Still not working, facing the same issue.
Reopening.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
--- Comment #6 from Kishan Sarsecha <ki...@gmail.com> ---
Want to confirm whether Apache POI 3.13 supports all WebLogic version ?
Could someone please confirm here that exporting .xlsx using SXSSFWorkbook
supported on WebLogic 10.3.5.0 ?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
--- Comment #2 from Kishan Sarsecha <ki...@gmail.com> ---
Responses are given inline.
Your example is missing a few critical lines, such as what os is.
- WebLogic running on Linux Suse
Your example probably contains more lines than are relevant. Can any of the
lines in the body be deleted and still recreate your problem? The more you cut
out irrelevant parts of your code, the easier it is to provide suggestions.
- I have tried removing CellRangeAddress and all CellStyle, still facing the
issue.
Have you tried using XSSFWorkbook yet?
- Yes tried using XSSFWorkbook as well, still facing the issue.
SO post
http://stackoverflow.com/q/37159328/2683399
Looks like you're using poi-3.13, poi-ooxml-3.13, and poi-ooxml-schemas-3.13,
so at least you're not mixing POI versions. Make sure you don't have any other
versions of POI on your class path.
- Confirmed, no conflicts.
Closing this bug unless someone can demonstrate a bug in POI rather than an
environment configuration problem.
- Seems like issue is on this specific version of WebLogic, I have tested on
higher versions and its working fine (Please refer:
http://stackoverflow.com/q/37159328/2683399)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
--- Comment #8 from Kishan Sarsecha <ki...@gmail.com> ---
Thanks Nick :)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
Kishan Sarsecha <ki...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kishan089.ce@gmail.com
Priority|P2 |P1
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59458] Exporting xlsx using apache poi 3.13 on weblogic : File
format or extension not valid
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59458
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |INVALID
--- Comment #9 from Dominik Stadler <do...@gmx.at> ---
Resolving this one again here as we do not see anything being done incorrectly
in POI at the moment.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org