OoxmlSaveOptions problem

I sent you an email with the files, meanwhile can you send me the link to download the cells version you are talking about?


Hi Luciano Oliveira,



We request you to kindly try our latest version/fix of Aspose.Cells for Java 8.3.2.1 first.

Or you may download the latest version here:
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/entry601680.aspx

Thank you.

With Aspose 8.3.2.1 I still have the same problem xlsx is corrupted.

I am using JDK 1.6

What else can I do?
Hi Luciano Oliveira,

Thanks for providing us further details.

Could you give us the two generated XLSX files produced on different platforms (one on AS400 and other on Windows machine) with the same application, data and version (v8.2.3.1) of Aspose.Cells for JAVA. To evaluate your issue properly, it is best that if you could provide us sample JAVA program (runnable) with template files if you have any. Or at least, you may attach both files here (as mentioned above) so that we could try to find some clue for your issue on our end.

Thank you.

Hi,


Moreover, I have received your files (produced by your older version) via email.

Well, your so called XLSX file “R56A00321-ULO012-TransitStockReport-201502021106.xlsx” is not a valid MS Excel file format, it is more like a text document and you may easily open it in notepad and check it out.

Thank you.
Hi,

loliveira8:
I am sending you in attachment the java source code and the xlsx that was produced by that code in windows using the newest version of aspose cells. In the as400 if I try to mimic the same code as the one in java I get the corruption error

I have received your generated Excel file on Windows which is fine as you mentioned and sample JAVA code segment. Could you provide the complete error trace (when you try to use the similar code of AS400), so we could evaluate it on our end soon.

Thank l you.

There is no error trace because the program in AS400 doesn’t actually fail. It runs but creates a file corrupted like the one I sent you before and to which you said looked like a plain text file.


The code in the AS400 does something like this:
workbook.save(Name of the File, 6)
I put 6 on the second parameter because I saw somewhere that it is the value in the save method to save xlsx files.
Like I showed you before, I did the same thing in the java program and it worked.

Is there anything here I am doing wrong?

Hi,

Would you please try the method Workbook.save(nameOfFile) without involving the second parameter to see whether you can get the correct result or not? We think this method should work for your situation. The constant value 6 is one type of save format which is defined in the interface SaveFormat, please pay attention to the value if you have to use the inner int value of those constants defined in Java interface because they may be changed in different versions of the product. To make sure you are using the correct value, please use Java program to first print out the correct value corresponding to specific version of Aspose.Cells that you are using, e.g., code like:
e.g.

Sample code:

System.out.println(SaveFormat.XLSX); // or any other Save Format defined in this interface

Also you can print out the version info of Aspose.Cells component to make sure you are using the correct one:
e.g.

Sample code:

CellsHelper.getVersion()

Thank you.

I sent you an email explaining that using save only with nameOfFile produced another XLSX with corrupted data.


Also I was going to try System.out.println(SaveFormat.XLSX); in my java program but SaveFormat wasn’t accepted. Did you meant System.out.println(FileFormatType.XLSX); ??

This produced a 6 in the console.

Hi,


We have received the corrupted file via email. Well, we asked you to just check the integer constant value by using the line of code in a simple JAVA program (on Windows) to get to know:
System.out.println(SaveFormat.XLSX); if you are using latest version/fix v8.3.2.1, it should print 6.

Also, could you try to print the version number on AS400 by using the APIs, i.e., CellsHelper.getVersion() and let us know the version number you get on AS400.

Thank you.


Hello again,


After a few weeks I managed to have time to have another look at this again.

So now I am sure the version of aspose being used is aspose-cells-8.3.2.1.jar, the version of java in the machine is JAVA 1.6.0 (I can’t put there another version for now).

This is what I did. I created a java program with these lines:

Utils.java

package com.TestAsposeCells;

import com.aspose.cells.OoxmlSaveOptions;
import com.aspose.cells.Workbook;

public class Utils {

public String createBothFiles()
{
String returnResult = “NOK”;
try {
//Create xls
Workbook workbook = new Workbook();
String stringFilePath = “//home//ulo012//chart.xls”;
workbook.save(stringFilePath);
//Create xlsx
//stringFilePath = “//home//ulo012//chart.xlsx”;
//OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
// workbook.save(stringFilePath, saveOptions);
returnResult = “OK”;
} catch (Exception e) {
// TODO Auto-generated catch block
// e.printStackTrace();
returnResult = “NOK - “+e.toString()+””;
}
return returnResult;
}
}

And a class with the main called Main.java
package com.TestAsposeCells;

public class Main {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Utils ut = new Utils();
System.out.println(ut.createBothFiles());
}

}


I sent this to the AS400 and after I runned it doing in qshell:
java com.TestAsposeCells.Main
This created the file in the folder described without any problem //home//ulo012//chart.xls


The problem starts when I try to do this to xlsx, so in the code Utils.java I uncomented the lines:
//stringFilePath = “//home//ulo012//chart.xlsx”;
//OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
// workbook.save(stringFilePath, saveOptions);

Uploaded the result to AS400 and try to run again with the command:
java com.TestAsposeCells.Main

And I have this error…
Exception in thread “Thread-0” java.lang.SecurityException: class “com.aspose.cells.Workbook”'s signer information does not match signer information of other classes in the same package at java.lang.Throwable.(Throwable.java:196) at java.lang.Exception.(Exception.java:41) at java.lang.RuntimeException.(RuntimeException.java:43) at java.lang.SecurityException.(SecurityException.java:35) at java.lang.ClassLoader.checkCerts(ClassLoader.java:807) at java.lang.ClassLoader.preDefineClass(ClassLoader.java:519) at java.lang.ClassLoader.defineClass(ClassLoader.java:646) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:170) at java.net.URLClassLoader.defineClass(URLClassLoader.java:317) at java.net.URLClassLoader.access$100(URLClassLoader.java:87) at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:653) at com.ibm.as400.system.nativ.AccessController.doPrivilegedInner(AccessController.java:93) at com.ibm.as400.system.nativ.AccessController.doPrivileged(AccessController.java:67) at java.net.URLClassLoader.findClass(URLClassLoader.java:223) at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229) at java.lang.ClassLoader.loadClass(ClassLoader.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:283) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:351) at com.TestAsposeCells.Main.main(Main.java:10)


So now I don’t know what else I can do… because I am either not using the constructor for the OoxmlSaveOptions correctly or something odd is on the classes with the version I am using. Can you please help me out with this?

Hi,

Thanks for using Aspose.Cells.

Do you mean that on the same machine and environment your program can work fine if only use the Workbook for saving xls file but gave error when in the code you use class OoxmlSaveOptions? Commonly signer issue of the classes is caused by that there are some other classes using the package com.aspose.cells out of the Aspose.Cells.jar. Please check your classpath used when running your program. Maybe there are some other jar/class files are included in your default class path and in those files there are another copy of aspose.cells related classes.

You can try to put only three files(with their directory structure for your two classes): com/TestAsposeCells/Utils.class, com/TestAsposeCells/ Main.class and aspose-cells-8.3.2.1.jar into one empty directory and then in this directory execute your program again by command:

java -cp .:aspose-cells-8.3.2.1.jar com.TestAsposeCells.Main

to see whether you can get the expected result. If not, please check your JDK and JRE’s lib directory and make sure there is no jar or classes of aspose.cells in it(if your AS400 has installed multiple versions of JDK/JRE, please check all of them or confirm you have checked at least the one you used to run your program).

Hello again,


So this was what was happening, in the defaults of the machine there was an Aspose.Cells.jar an older version I don’t even know what version that was. And in my project for test I had the the new aspose-cells-8.3.2.1.jar associated with it. Once I substituted that old Aspose.Cells.jar for the new one with the same name as the old one we started getting the xlsx without any corruption.

I am not sure why this is happening but for future reference, this has resolved my inicial issue.

Thank you.


PS.: Now I have other problems but that is regarding methods that were on Workbook before and now they don’t exist. For example setCalculationMode and setCalculateBeforeSave are not in the version aspose-cells-8.3.2.1.jar. Is there any place where I can check what is the equivalent of this method now?


Thank you
Hi,

Good to know that your issue is sorted out now.

loliveira8:

....Now I have other problems but that is regarding methods that were on Workbook before and now they don't exist. For example setCalculationMode and setCalculateBeforeSave are not in the version aspose-cells-8.3.2.1.jar. Is there any place where I can check what is the equivalent of this method now?

Please try using WorkbookSettings.setCalcMode() and WorkbookSettings.setReCalculateBeforeSave() methods in the newer versions of the product for your needs. Please see the sample line of code for your reference:
e.g
Sample code:

..........
workbook.getSettings().setReCalculateBeforeSave(true);

Thank you.

Hello again,


I don’t know if this is the correct place for this, if not please tell me where it is.

If we are going to update for the new version of Aspose.Cells there are several classes and methods that I need to know the new names. I have done a listing of all the classes and methods that we use now and that we will need to know what are the names in the new version.

The classes that are missing and I didn’t found an equivalent are:
NamedRange
CategoryAxis -> Axis (is this correct?)
ValueAxis -> Axis (is this correct?)
com.aspose.cells.cs.setVisible(boolean) (I don’t know where the .cs is)
com.aspose.cells.cY.getArea (I don’t know where the cY is)
Palette
ShapeFill

And the methods that I couldn’t find any equivalents are:
Workbook.open
Workbook.getPallet
Workbook.protectFile
Workbook.protectWorkbook
Worksheet.getNamedRanges
Worksheet.getRow
Cells.createNamedRange
Cells.setRangeStyle
CellStyle.setFont
CellStyle.setPatternColor
CellStyle.setBordercolor
CellStyle.setColor
CellArea.getEndColumn
VPageBreaks.size
HPageBreak.setRow
VPageBreak.setColumn
PivotTables.size
Charts.size
NSeries.size
Area.setVisible
Title.setFont
CondForms.siz
CondForms.delete
FormConds.sizeOfConditionList
PageSetup.setLeftHeader
PageSetup.setCenterHeader
PageSetup.setCenterFooter
PageSetup.setRightFooter
PageSetup.setRightHeader
Shapes.addOleObject(int, int, int, int, InputStream, InputStream, int, javastring)

Please either provide me the new names for each of them or at least tell me where I can find this information myself.
Thank you


Hi,

Thanks for your posting and using Aspose.Cells.

Please see the section General API Set from the following document. It should help you in migrating your code from the older to newer version.

( How to Migrate to Aspose.Cells 7.0.0 or Higher|Documentation )

Thank you for the document it really is helping a lot.


But I still have classes and methods that are not in the document you sent.

Class missing
com.aspose.cells.cs.setVisible(boolean)
com.aspose.cells.cY.getArea

Method missing
PivotTables.size (Nothing found on migration document)??
Title.setFont (Nothing found on migration document)??

Can you help me with this please?

Hi,

Thanks for your posting and using Aspose.Cells.

Please provide us portions of your old sample code using these classes so that we could look into it and find the alternative replacement code compatible with new version.

Thanks for your cooperation.

Hello,

Having another look at this issue after Some time, I still believe the method is missing in the Java version of aspose.cells.

Is this “overload” of the “save”-method available as public method ?
“Workbook.save” (javastring;OoxmlSaveOptions) is not available as usable method !!

Can this be checked please ?
Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

OoxmlSaveOptions is a derived class of SaveOptions, so you should use the following method instead.

void save(java.lang.String fileName, SaveOptions saveOptions)

Please see the following sample code which works fine for your reference.

Java


OoxmlSaveOptions opts = new OoxmlSaveOptions(SaveFormat.XLSX);

workbook.save(“output.xlsx”, opts);