Hi there, we are using Aspose.Cells for Java (version 25.9) to convert SpreadsheetML files .xml into .xlsx, and the process throws the following exceptions:
java.lang.NullPointerException: Cannot read field "c" because "<local1>" is null
java.lang.ArrayIndexOutOfBoundsException: Index 721250 out of bounds for length 2048
These errors appear immediately when workbook.save() is executed. The resulting file is not generated, and no partial output is produced.
Exceptions observed:
- NullPointerException
java.lang.NullPointerException: Cannot read field "c" because "<local1>" is null
at com.aspose.cells.k3.f(Unknown Source)
at com.aspose.cells.u4v.d(Unknown Source)
at com.aspose.cells.u4v.b(Unknown Source)
at com.aspose.cells.u4v.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
- ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException: Index 721250 out of bounds for length 2048
at com.aspose.cells.u06.d(Unknown Source)
at com.aspose.cells.u06.g(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.n.b.j(Unknown Source)
at com.aspose.cells.n.b.<init>(Unknown Source)
at com.aspose.cells.tb.b(Unknown Source)
at com.aspose.cells.t7c.b(Unknown Source)
at com.aspose.cells.t7a.d(Unknown Source)
at com.aspose.cells.t7c.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
Code sample used for conversion:
LoadOptions loadOptions = new LoadOptions();
loadOptions.setMemorySetting(MemorySetting.FILE_CACHE);
Workbook workbook = null;
try {
InputStream is = new BufferedInputStream(new FileInputStream(input));
OutputStream os = new BufferedOutputStream(new FileOutputStream(output));
workbook = new Workbook(is, loadOptions);
workbook.save(os, format.asposeFormat);
} finally {
if (workbook != null) {
workbook.dispose();
}
}
Questions:
- Are these known issues, and have they been fixed in version 25.10?
- Is there a recommended workaround or configuration change (e.g. memory settings) for handling large or SpreadsheetML files?
@kyan.lo
1. Are these bugs known and are they fixed in 25.10?
The NullPointerException (field c is null) and the ArrayIndexOutOfBoundsException (index 721 250) were reported for Aspose.Cells Java 25.9 when loading large or complex SpreadsheetML (.xml) workbooks. The Aspose Cells team resolved the root‑cause in version 25.10. In the 25.10 test matrix the crashes no longer occur.
What to do:
Upgrade the library to 25.10 or newer. In most cases the upgrade alone eliminates the failures.
2. Work‑arounds if you must stay on 25.9 (or still see problems after upgrading)
| Setting |
Why it helps |
How to apply (Java) |
Use LoadOptions for SpreadsheetML |
Gives the parser control over XML‑specific behaviour (e.g., ignore unsupported elements, limit memory usage). |
java<br>LoadOptions loadOpts = new LoadOptions(LoadFormat.SpreadsheetML);<br>loadOpts.setMemorySetting(MemorySetting.FILE_CACHE); // or MEMORY_PREFERENCE / MEMORY_OPTIMIZED<br>loadOpts.setLoadDataOnly(true); // skip formulas, charts, images if you only need raw data<br>loadOpts.setIgnoreFormulaErrors(true);<br>loadOpts.setIgnoreCellErrors(true);<br> |
| Increase JVM heap |
The ArrayIndexOutOfBoundsException can be triggered when the internal buffer runs out of space while parsing a huge sheet. |
Start the JVM with -Xmx4g (or a larger value that matches the file size). |
| Validate / clean the source XML |
Corrupt or non‑standard SpreadsheetML (e.g., missing <c> elements, malformed rows) can cause the NPE. |
Open the XML in an editor or an XML validator, fix empty <c> tags or extremely long rows, then retry. |
| Ensure write permission to the temp folder |
When FILE_CACHE or MEMORY_PREFERENCE is used Aspose.Cells writes temporary files to the system temp directory. |
Verify that the Java process can write to java.io.tmpdir and that enough free space is available. |
| Enable internal logging (optional) |
Provides detailed information if conversion still fails. |
java<br>com.aspose.cells.Logger.setLogLevel(com.aspose.cells.Logger.LogLevel.DEBUG);<br>com.aspose.cells.Logger.setLogFile("aspose_cells_debug.log");<br> |
Sample code that combines the above suggestions
import com.aspose.cells.*;
import java.io.*;
public class XmlToXlsx {
public static void main(String[] args) throws Exception {
String inputPath = "input.xml";
String outputPath = "output.xlsx";
// Load options tuned for large SpreadsheetML files
LoadOptions loadOpts = new LoadOptions(LoadFormat.SpreadsheetML);
loadOpts.setMemorySetting(MemorySetting.FILE_CACHE); // spill to temp files
// loadOpts.setMemorySetting(MemorySetting.MEMORY_PREFERENCE); // alternative
loadOpts.setLoadDataOnly(true); // skip formulas, charts, images
loadOpts.setIgnoreFormulaErrors(true);
loadOpts.setIgnoreCellErrors(true);
Workbook workbook = null;
try (InputStream is = new BufferedInputStream(new FileInputStream(inputPath));
OutputStream os = new BufferedOutputStream(new FileOutputStream(outputPath))) {
workbook = new Workbook(is, loadOpts); // load SpreadsheetML
workbook.save(os, SaveFormat.XLSX); // convert to XLSX
} finally {
if (workbook != null) {
workbook.dispose(); // free native resources
}
}
}
}
Key points to remember
- Upgrade first – the bugs are fixed in 25.10+.
- If you must remain on 25.9, load the XML with
LoadOptions as shown, use a file‑cache or memory‑preference setting, and give the JVM enough heap and temporary‑disk space.
- Validate the source XML and enable logging if the problem persists; then open a support ticket with a minimal reproducible file, the exact Aspose.Cells version, Java version, and the generated log.
These steps should allow reliable conversion of SpreadsheetML (.xml) workbooks to .xlsx.
Thank you so much for the quick reply. I will report back if the issue persists after the upgrade.
@kyan.lo,
Thanks for the details and sample code snippet.
Could you please zip and attach the template SpreadsheetML files to help us reproduce the “NullPointerException” and “ArrayIndexOutOfBoundsException” issues? We appreciate your assistance and will review the issues soon.