We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Reading an Excel file in .xlsm format from Java

Hi,

We are trying to read an Excel file in xlsm format using Aspose Cells for java 7.5.1 version.

Please let us know how exactly we can read it , currently we are getting exceptions while reading the file.
"This is not a structured
storage file."

Please let us know how to approach this problem.

Hi,

Thanks for your posting and using Aspose.Cells for Java.

Please download and use the latest version: Aspose.Cells
for Java v7.7.2.1
it works fine.

We have tested your issue with the following code and it did not throw any exception.

Java


String filePath = “F:\Shak-Data-RW\Downloads\RMteplate.xlsm”;


Workbook workbook = new Workbook(filePath);

workbook.save(filePath + “.out.xlsm”);



Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have used the same code in my web based application, that was working in standalone application.

Now it’s giving below exception.

java.lang.IllegalArgumentException.

Here is my code.

hssfWrkbook = new Workbook(rmcFile.getAbsolutePath());

The value of argument passed to WorkBook constructor as below.

C:\jboss-5.0.1.GA\server\default\tmp\a491v-6w716r-hs3c1f8g-1-hs3c2umy-9t\ctcreports.war\WEB-INF\classes\rm-templates\Qtools_LiftnDrag.xlsm

I have also tried with Stream as an argument as well.

Please suggest alternative code.

Thanks,

Hiren

Hi Hiren,

Thanks for your posting and using Aspose.Cells for Java.

The path argument looks fine. There shouldn’t be any problem. Could you please provide the full stack trace of the exception so that we could look into this issue more precisely?

Could you please also provide us the code which you are using in standalone application where the exception is not occurring and the web application code where the exception is occurring? It will also shed some light on this problem.

Hi ,

On continuation of previous issue. When we are trying to open the files with macros we get the attached error. Please fin the excel that we are using and snapshot of Error.

This is a macro based excel file. So please let us know if there is any option that we need to check while saving the output file.

Below is the similar code snippet we are trying to use.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

//Creating an Workbook object with excel 2000 file path and the loadOptions object

String path=new File("C:\\Abhinav\\jbosslatest\\jboss-eap\\jboss-as\\server\\default\\fmreports\\Output\\WithOutData_Qtools_DD_With_RM.xlsm").getAbsolutePath();

Workbook wb = new Workbook(path);

path2=new File("C:\\Abhinav\\jbosslatest\\jboss-eap\\jboss-as\\server\\default\\fmreports\\Output\\WithOutData_Qtools_DD_With_RM_out.xlsm").getAbsolutePath();

wb.save(path2);

Hi Abhinav,

Thanks for your posting and using Aspose.Cells.

This is the output xlsm file. Kindly provide the source xlsm file which you are opening and saving with Aspose.Cells and that gets corrupted.

We will look into this issue and update you asap.

Please find attached source xlsm file.

Just saw that if I enable macro from source excel , the macro itself is failing. I think I need to look into macro.

I will let you know if fixing the macro in spurce fixes the error on output.

Hi Abhinav,

Thank you for providing the sample spreadsheet.

We have re-evaluated your presented scenario on our end while using the latest version of Aspose.Cells for Java 7.7.2.5. Unfortunately, we are unable to replicate the problem as mentioned in your recent post. Although when loaded with MS Excel, the resultant spreadsheet causes a runtime error as shown in the attached snapshot. This is probably due to some problem in macros itself.

We would request you to please give the latest version a try on your end, and feed us back in case you encounter similar error.

Hi @shakeel.faiz
I am new to aspose cell in java.I have some doubts to be clarified.
using aspose can we read .xlsm file which is large in size(eg:160 mb)?
And what is the maven dependency for using aspose in java?

@shrimathi,

Thanks for your query.

Yes, Aspose.Cells for Java does support XLSM file format (read/write), see the document for supported file formats for your reference. You can read such big sized file (e.g 160 mb) file without any issue but kindly make sure you have sufficient amount of memory for the big process. Generally, Aspose.Cells requires 10 times or more memory of the size of the file when reading or writing it. Please try using our latest version/fix: Aspose.Cells for Java v19.12. If you find any issue, kindly do share your template file and sample code, we will check it soon.

Aspose.Cells is also hosted on Maven repository. You can easily use Aspose.Cells for Java API directly in your Maven Projects with simple configurations. See the document for your reference:
https://docs.aspose.com/display/cellsjava/Installation#Installation-InstallingAspose.CellsforJavafromMavenRepository

thanks @Amjad_Sahi
I have added those dependencies in pom.xml and it works.
I have added dependency for apose cell 19.11 version and it works good.it is an opensource thing or we should pay something for using it?

@shrimathi,

Good to know that your issue is sorted out. Well, Aspose.Cells is not an opensource API, see the pricing information for your reference.

In the event of any further query or issue, feel free to contact us and we will be happy to assist you soon.