Error in excel file generated through Aspose Cells

Hi,

We are trying to generate an Excel through the following steps(Attached is the code used for file generation) :-
1.) An Excel file is saved in the system and is being used as the template for the final output.
2.)The template is being converted into a workbook using Aspose API.
3.)The workbook is then saved into an outputstream and then subsequently in a byte array format using Apose API.
4.)Using the Byte Array the Excel is being generated.

Code:-

try{
// TemplatePage.getString(“pyFileSource”) contains the base64EncodedString of the template which is then decoded to a byte array

byte[] tempBytes = new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(TemplatePage.getString(“pyFileSource”));

//reading the data from byte arrays(tempBytes) as streams
java.io.InputStream tempIS = new java.io.ByteArrayInputStream(tempBytes);

//Creating the workbook
com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(tempIS);

//capturing the data written to a stream
java.io.ByteArrayOutputStream outStream = new java.io.ByteArrayOutputStream();

//Saving the Workbook

workbook.save(outStream, com.aspose.cells.SaveFormat.
//Converting outStream to byteArray
byte[] xlBytes = outStream.toByteArray();

//Sending file to browser
String result=tools.sendFile(xlBytes,FileName,false,null,true);

}catch(Exception e){System.out.println(“Exception”+e);}

Error:- When the generated file is opened it through an error stating that Excel found unreadable content in Generated file.

Attached is the original Excel File that was being used as a template and will display no error while opening.
Along with that the generated file is also attached that displays the error on opening the file.

The version of Aspose Cells being used is 8.8.0.0

Please provide a resolution for the same.
Aspose Cells Issue.zip (1.7 MB)

@rhustead,

Thanks for the template file and sample code segment.

Please try our latest version/fix: Aspose.Cells for Java v17.9.3

I have tested using the following sample code with v17.9.3, it works fine. The output XLSM file is opened fine into MS Excel:
e.g
Sample code:

import java.io.*;
import java.util.*;
//import org.apache.commons.io.FileUtils;
import org.apache.commons.io.*;

import com.aspose.cells.*;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class ErrorInExcel1

{
    public static void main(String[] args) throws Exception
    {        

/* //This works fine.
Workbook workbook = new Workbook("OriginalFile (1).xlsm"); 
workbook.save("out1OriginalFile1.xlsm");
*/

//This equally works fine.
byte[] data = FileUtils.readFileToByteArray(new File("f:\\files\\OriginalFile (1).xlsm"));
            ByteArrayInputStream inStream =  new ByteArrayInputStream(data);
            final Workbook doc = new Workbook(inStream);
            // Save the modified document into out stream
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            doc.save(baos, SaveFormat.XLSM);
 
            //You can then get the PDF document back into the InputStream as follows
            final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
            inputStream.close();

            // Use this to convert the stream to a .pdf file
            final OutputStream outputStream = new FileOutputStream("f:/files/out1.xlsm");
            IOUtils.copy(inputStream, outputStream);
            outputStream.close();

    }    
}

Hope, this helps a bit.