Error Opening Excel -2007 Containg Smart Art

Hi,

I upload a .xlsx document containing Smart Arts and Pivot. I get the byte[] of that file and now i want to add a new worksheet to the same document. So i do the following

AddWorksheets(byte[] DocObject)

{

Aspose.Cells.Workbook wrkBook = new Aspose.Cells.Workbook();

if (DocObject != null)

{

Stream sRead = new MemoryStream(DocObject);

sRead.ReadByte();

/*Check whether the upload excel is present */

if (sRead != null)

{

/*Error at the below line*/

wrkBook.Open(sRead, Aspose.Cells.FileFormatType.Excel2007Xlsx);

}

}

}

I get a exception in the above code where i have mentioned error at the below line and my workbook doesnot open and my application crashes.

I use 4.8.0.0 Version of Aspose.dll

Hi Mehul,

We have tried to reproduce the issue using your mentioned version of Aspose.Cells in the same way as described by you in the code snippet. We are unable to reproduce the issue. The code we have used is given below.

On the other hand, please send us your sample Excel file so that we can perform testing on it. Furthermore, in order to use more option please use our updated version of Aspose.Cells Aspose.Cells5.1.4.1.zip attached with this reply.

Code snippet:
MemoryStream ms = new MemoryStream(File.ReadAllBytes(sFilePath));

Workbook workbook = new Workbook();

workbook.Open(ms, FileFormatType.Excel2007Xlsx);

workbook.Worksheets.Add("New Test Sheet");

workbook.Save(sSaveFilePath);


Thanks,

Hi Salman,

I tried the code given by you with V 4.8 of Aspose and still i am getting an error. I have attached my sample xlsx file for your reference.

Thanks,

Mehul

Hi,

Please try the attached latest version, it works fine with your file using the following sample code:
MemoryStream ms = new MemoryStream(File.ReadAllBytes(“e:\test\Sample.xlsx”));
Workbook workbook = new Workbook(ms, new LoadOptions(LoadFormat.Xlsx));
workbook.Worksheets.Add(“New Test Sheet”);
workbook.Save(“e:\test\outSample.xlsx”);


It is possible v4.8.x that you are using has some issue regarding this file, so you need to use the latest version /fix v5.1.4.1.

Thank you.


Thanks Amjad it worked with the latest version

Hi,

I used the above code and tried and it worked with few excels. I have a excel which i have attached, when i try do the same as mentioned above it takes lot of time and the above code is under .net transaction and my transaction fails because of time out error. And also i am not able to figure out why its taking lot of time as the file is very small.

Thanks,

Mehul

Hi,

Thanks for providing us template file.

I can find the issue as you have mentioned by your file.

I have logged your issue into our issue tracking system with an id: CELLSNET-21094. We will figure it out soon.

Thank you.

Hi,

Please try the attached version v5.1.4.5, we have improved the performance of opening the file.

Thank you.

Hi Mehul,

For your consideration, we are sending you a start and end time stamp of IO operation on the file sent by you. Please go through the screen shot and let us know if any explanation is required.

Thanks,

Thanks Salman, its working fine. We will get back to you incase we have any issues.