Free Support Forum - aspose.com

Error message "This is not a structured storage file" whene trying to merge files

Hi,

To evaluate the use of the aspose cell API in a project, I try to merge two Excel (.xlsx) files into a single file with JAVA and I have the following error message:

Error :

cd C:\Users\ThinkPad\Documents\NetBeansProjects\excelApp; "JAVA_HOME=C:\\Program Files\\Java\\jdk-14" cmd /c "\"D:\\NetBeans-11.3\\netbeans\\java\\maven\\bin\\mvn.cmd\" -Dexec.args=\"-classpath %classpath com.kt.excelapp.MergeExcel\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk-14\\bin\\java.exe\" -Dmaven.ext.class.path=D:\\NetBeans-11.3\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.5.0:exec"
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...
                                                                        
------------------------------------------------------------------------
Building excelApp 1.0.0.0
------------------------------------------------------------------------

--- exec-maven-plugin:1.5.0:exec (default-cli) @ excelApp ---
Exception in thread "main" java.lang.IllegalStateException: This is not a structured storage file.
	at com.aspose.cells.zakt.<init>(Unknown Source)
	at com.aspose.cells.zzm.b(Unknown Source)
	at com.aspose.cells.zzm.<init>(Unknown Source)
	at com.aspose.cells.zaun.a(Unknown Source)
	at com.aspose.cells.zaun.a(Unknown Source)
	at com.aspose.cells.CellsHelper.mergeFiles(Unknown Source)
	at com.kt.excelapp.MergeExcel.main(MergeExcel.java:31)
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
	at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
	at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
	at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
	at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
	at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 8.155 s
Finished at: 2020-04-20T19:38:24+01:00
Final Memory: 7M/30M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (default-cli) on project excelApp: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

This is the java code

package com.kt.excelapp;

import com.aspose.cells.CellsHelper;
import com.aspose.cells.Workbook;


public class MergeExcel {
    
    
    public static void main(String[] args) throws Exception {
		// ExStart:1
		//String dataDir = Utils.getSharedDataDir(MergeFiles.class) + "CellsHelperClass\\";

		// Create an Array (length=2)
		String[] files = new String[2];
		// Specify files with their paths to be merged
		files[0] = "c.xlsx";
		files[1] = "w.xlsx";

		// Create a cachedFile for the process
		String cacheFile = "test.txt";
		// Output File to be created
		String dest = "output.xls";

		// Merge the files in the output file
		CellsHelper.mergeFiles(files, cacheFile, dest);

		// Now if you need to rename your sheets, you may load the output file
		Workbook workbook = new Workbook("output.xls");

		int cnt = 1;

		// Browse all the sheets to rename them accordingly
		for (int i = 0; i < workbook.getWorksheets().getCount(); i++) {
			//workbook.getWorksheets().get(i).setName("Sheet1" + cnt);
			cnt++;
		}
		// Re-save the file
		workbook.save("MergeFiles-out.xls");
		// ExEnd:1
	}

}

You’ll find attached my two files.excelApp.zip (13.1 KB)

Can you help me to fix this problem ?

Thank you for your help and support.

Regard.

@AmineBoussaidi,

Thanks for the details and stacktrace.

Please zip your source files and paste your sample code (runnable) to reproduce the issue, we will check it soon.

Hi.

Thank you for your help.

I just updated my message, please check.

Regards.

@AmineBoussaidi,

Thanks for the template files and sample code.

After an initial test, I am able to reproduce the issue as you mentioned by using your sample code with your template files. I found an exception “java.lang.IllegalStateException: This is not a structured storage file” when merging Excel files. I have logged a ticket with an id “CELLSJAVA-43168” for your issue. We will look into it soon.

Once we have an update on it or we figure it out, we will let you know.

Thank you for your support and reactivity :ok_hand::+1:

@AmineBoussaidi,
You are welcome.

@AmineBoussaidi,
This method is used to merge large xls files to xls file, it does not support merging xlsx files.
Please use workbook.Combine() method to merge them and let us know your feedback.

Yes :slight_smile: I did it, I combined the two files by using the methde Workbook.combine();

    Workbook file1 = new Workbook("c.xlsx");
    Workbook file2 = new Workbook("w.xlsx");
    file1.combine(file2);
    file1.save("output_file.xlsx");

Thank you for your support, very helpful.

@AmineBoussaidi,
You are welcome.

The issues you have found earlier (filed as CELLSJAVA-43168) have been fixed in Aspose.Cells for Java v20.5. This message was posted using Bugs notification tool by ahsaniqbalsidiqui